Floating-point variadic function call

Damien Thébault damien@dtbo.net
Mon Oct 10 07:27:00 GMT 2016


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



More information about the Libffi-discuss mailing list