comp.lang.ada
 help / color / mirror / Atom feed
* Importing C function with variable argument list
@ 2012-04-10  9:21 Maxim Reznik
  2012-04-10 11:22 ` Patrick
                   ` (4 more replies)
  0 siblings, 5 replies; 34+ messages in thread
From: Maxim Reznik @ 2012-04-10  9:21 UTC (permalink / raw)


Hi, All

It seems it's impossible to call C function variable argument lists
from Ada.
Even when one knows in advace all arguments at compile time.

Functions with Variable Argument Lists have their own ABI. For
instance, in x86_64:

> When a function taking variable-arguments is called, %rax must be set to the
> total number of floating point parameters passed to the function in vector registers.

But it's impossible to specify this fact in pragma Import (C, ...

Small example:

C declaration:
void syslog (int __pri, __const char *__fmt, ...);

Supposed Import declaration:

procedure C_Syslog (Priority : int; Format : chars_ptr; Msg :
chars_ptr);
pragma Import (C, C_Syslog, "syslog");

Call to C_Syslog fails, because %rax has not zero value.

What do you think?



^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2012-05-14 20:55 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-10  9:21 Importing C function with variable argument list Maxim Reznik
2012-04-10 11:22 ` Patrick
2012-04-10 13:09   ` Maxim Reznik
2012-04-10 13:50     ` Georg Bauhaus
2012-04-10 13:18 ` Markus Schöpflin
2012-04-10 16:47   ` Simon Wright
2012-04-12 10:08     ` Markus Schöpflin
2012-04-12 16:58       ` Adam Beneschan
2012-04-12 20:47         ` Randy Brukardt
2012-04-13  8:43           ` Markus Schöpflin
2012-04-13 23:01             ` Randy Brukardt
2012-04-27  8:24           ` Natasha Kerensikova
2012-04-27  9:18             ` Jacob Sparre Andersen
2012-04-27 16:48               ` Natasha Kerensikova
2012-05-03 20:15             ` sbelmont700
2012-05-13  4:18               ` David Thompson
2012-05-13  9:03                 ` Simon Wright
2012-05-13 17:01                   ` Jeffrey Carter
2012-05-13 18:20                     ` Simon Wright
2012-05-13 19:11                       ` Jeffrey Carter
2012-05-13 19:55                         ` Ludovic Brenta
2012-05-14  0:52                           ` Jeffrey Carter
2012-05-13 21:12                         ` Simon Wright
2012-05-13 23:57                           ` Georg Bauhaus
2012-05-14  0:54                           ` Jeffrey Carter
2012-05-14  8:10                             ` Nomen Nescio
2012-05-14 15:21               ` Natasha Kerensikova
2012-05-14 20:53                 ` sbelmont700
2012-04-13  4:08         ` Tero Koskinen
2012-04-13  8:04           ` Markus Schöpflin
2012-04-10 20:02 ` Tero Koskinen
2012-04-13  3:28   ` Tero Koskinen
2012-04-10 20:25 ` sbelmont700
2012-04-11 23:24 ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox