From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31780 invoked by alias); 4 Dec 2013 08:03:07 -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 31765 invoked by uid 89); 4 Dec 2013 08:03:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.2 required=5.0 tests=AWL,BAYES_50,RDNS_NONE autolearn=no version=3.3.2 X-HELO: exprod5og117.obsmtp.com Received: from Unknown (HELO exprod5og117.obsmtp.com) (64.18.0.149) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) SMTP; Wed, 04 Dec 2013 08:03:06 +0000 Received: from alpmlip10.e2k.ad.ge.com ([12.43.191.1]) (using TLSv1) by exprod5ob117.postini.com ([64.18.4.12]) with SMTP ID DSNKUp7hsnuB1syfOC6ZCMnkjI4QYhkErfNd@postini.com; Wed, 04 Dec 2013 00:03:05 PST Received: from unknown (HELO ALPMBHT01.e2k.ad.ge.com) ([3.159.19.194]) by alpmlip10.e2k.ad.ge.com with ESMTP/TLS/AES128-SHA; 04 Dec 2013 03:02:57 -0500 Received: from ALPURTP01.e2k.ad.ge.com (3.159.16.200) by ALPMBHT01.e2k.ad.ge.com (3.159.19.194) with Microsoft SMTP Server (TLS) id 14.3.146.0; Wed, 4 Dec 2013 03:02:57 -0500 Received: from ALPMBCND04.e2k.ad.ge.com (3.159.19.21) by ALPURTP01.e2k.ad.ge.com (3.159.16.200) with Microsoft SMTP Server (TLS) id 14.3.146.0; Wed, 4 Dec 2013 03:02:56 -0500 Received: from ALPMBAPA05.e2k.ad.ge.com ([169.254.5.229]) by ALPMBCND04.e2k.ad.ge.com ([169.254.10.252]) with mapi id 14.03.0146.000; Wed, 4 Dec 2013 03:02:47 -0500 From: "Hogan, D. (GE Power & Water)" To: Alan Modra , Andrew Haley CC: Jakub Jelinek , "libffi-discuss@sourceware.org" Subject: RE: RFC: variadic closures in x86/x86_64 Date: Wed, 04 Dec 2013 08:03:00 -0000 Message-ID: References: <52931854.6080007@redhat.com> <20131125093715.GU892@tucnak.redhat.com> <5293221D.4010505@redhat.com> <20131126142723.GD9211@bubble.grove.modra.org> In-Reply-To: <20131126142723.GD9211@bubble.grove.modra.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2013/txt/msg00231.txt.bz2 On Wed, Nov 27, 2013 at 00:57:23PM +1030, Alan Modra wrote: > The claim to fame looks to be the ability to call variadic functions > without describing the arguments via ffi_prep_cif_var at the point of > call. Instead you do so in the function consuming the args. I'm not > sure what that gains you.. This is specifically for variadic callbacks. If it wasn't a callback, I could use ffi_prep_cif_var. To give a little background, FMI is a standard for (among other things) model exchange so you can use a dynamic system model in various modeling or simulation environments. The model is exposed as a C shared library. The shared library executes callbacks (some variadic) provided by a FMU driver. JFMI allows you to drive a FMU from Java. The Java FMU driver provides a Java implementation for the C callbacks. The nonvariadic callbacks were already supported by JFMI through libffi and JNA. In order to handle variadic callbacks, libffi and JNA need to be modified so you can access the variadic arguments inside of a callback. This patch adds the libffi support. I cannot construct a ffi_prep_cif_var because the model's C shared library is the one running a variadic callback in the driver. I don't know how many arguments or what types it will provide in the calls. I have to rely on printf style formatting flags in order to know what to access from inside of the callback. > The patch suffers from the same flaw as my first attempt at adding > variadic argument support for PowerPC64 ELFv2, namely that you cannot > add fields to ffi_cif without breaking ABI compatibility. > Applications linked against an older version of libffi.so will supply > the old ffi_cif to a new shared library.. That's a good point. This should be changed to avoid breaking the ABI.