public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: "Damien Thébault" <damien@dtbo.net>,
	"Andrew Pinski" <pinskia@gcc.gnu.org>
Cc: "libffi-discuss@sourceware.org" <libffi-discuss@sourceware.org>
Subject: Re: Floating-point variadic function call
Date: Tue, 11 Oct 2016 13:27:00 -0000	[thread overview]
Message-ID: <a0f9ac7b-832d-3954-b74e-6c849bfa4d3b@redhat.com> (raw)
In-Reply-To: <20161010072746.GA12478@han>

On 10/10/2016 02:27 AM, Damien Thébault wrote:
> 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 ?

You must do the mandatory C promotion yourself.  Put ffi_type_double.


r~

  reply	other threads:[~2016-10-11 13:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10  7:04 Damien Thébault
2016-10-10  7:17 ` Andrew Pinski
2016-10-10  7:27   ` Damien Thébault
2016-10-11 13:27     ` Richard Henderson [this message]
2016-10-11 19:12       ` Damien Thébault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0f9ac7b-832d-3954-b74e-6c849bfa4d3b@redhat.com \
    --to=rth@redhat.com \
    --cc=damien@dtbo.net \
    --cc=libffi-discuss@sourceware.org \
    --cc=pinskia@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).