This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: Floating-point variadic function call
- From: Damien Thébault <damien at dtbo dot net>
- To: Andrew Pinski <pinskia at gcc dot gnu dot org>
- Cc: "libffi-discuss at sourceware dot org" <libffi-discuss at sourceware dot org>
- Date: Mon, 10 Oct 2016 09:27:46 +0200
- Subject: Re: Floating-point variadic function call
- Authentication-results: sourceware.org; auth=none
- References: <20161010070352.GA11072@han> <CA+=Sn1mm1s45mQ3f0MVvXMhjn4hyRrSqW6wZzAwGW-+2XkonWw@mail.gmail.com>
On Mon, Oct 10, 2016 at 12:17:03AM -0700, Andrew Pinski wrote:
> > I tested on a x86_64 computer both 64-bit and 32-bit versions (the
> > latter compiled with -m32) as well as ARM under qemu.
> > In all those cases, I didn't get the proper result with floats while
> > doubles are ok, as well as chars.
>
> That is because the variadic function ABI is different from the normal
> argument ABI on ARM hard-float EABI. Basically for variadic functions
> float are passed via the integer registers while for normal functions,
> they are passed via the vfp registers.
>
> Basically you need to use variadic function support in libff. Use
> ffi_prep_cif_var instead of ffi_prep_cif and then don't do:
>
> for(i=1 ; i<10 ; i++)
> {
> arg_types[i] = &ffi_type_float;
> }
I'm actually using ffi_prep_cif_var() for the variadic call, but what
should I put as arg_type then ?
Thanks,
--
Damien Thébault