From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80920 invoked by alias); 11 Oct 2016 13:27:08 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 80902 invoked by uid 89); 11 Oct 2016 13:27:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-2.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=arg_type, 03AM, Th=e9bault, th=e9bault?= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Oct 2016 13:27:06 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE04A3D971; Tue, 11 Oct 2016 13:27:04 +0000 (UTC) Received: from bigtime.twiddle.net (ovpn-116-159.phx2.redhat.com [10.3.116.159]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9BDR33i020372; Tue, 11 Oct 2016 09:27:04 -0400 Subject: Re: Floating-point variadic function call To: =?UTF-8?Q?Damien_Th=c3=a9bault?= , Andrew Pinski References: <20161010070352.GA11072@han> <20161010072746.GA12478@han> Cc: "libffi-discuss@sourceware.org" From: Richard Henderson Message-ID: Date: Tue, 11 Oct 2016 13:27:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20161010072746.GA12478@han> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2016/txt/msg00045.txt.bz2 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~