This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ada in gcc-3.4.3 on x86_64


> It is not possible to interface to variadic C functions from standard
> >         Ada if the calling convetion for variadic and non-variadic function
> >         differs.
> >         
> >         I don't think GNAT offers a non-standard extension which provides this
> >         functionality.  Maybe it should.
> >         
> > 
> That would certainly be a reasonable possible language extension. Presumably
> the way to do this would be to introduce a convention called C_Varargs or
> something like that. This is not a trivial addition :-)

The only difference I see in the x86-64 ABI is that variadic functions 
must also use %al, so the calls are compatible.

Ada could always set %al for all calls to C. It can be set either to the actual
number of registers or always to 8.

An extension should not be necessary. From an Ada perspective it is supposed 
to work with pragma Import (C, certainly if Ada and C are from the same vendor.
The Ada 95 LRM Annex B.3 Interfacing with C has a specific reminder on handling 
variadic calls:

(12) A C function that takes a variable number of arguments can correspond 
to several Ada subprograms, taking various specific numbers and types of 
parameters.

So, the LRM is saying that the proper approach is to use overloaded Ada 
subprograms to call variadic C routines.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]