From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32322 invoked by alias); 4 Dec 2013 11:05:57 -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 32301 invoked by uid 89); 4 Dec 2013 11:05:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=BAYES_50,RDNS_NONE autolearn=no version=3.3.2 X-HELO: philipashmore.com Received: from Unknown (HELO philipashmore.com) (199.231.215.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Dec 2013 11:05:56 +0000 Received: from [192.168.0.10] (unknown [176.61.108.16]) (Authenticated sender: contact@philipashmore.com) by philipashmore.com (Postfix) with ESMTPSA id 2C1E5607DD for ; Wed, 4 Dec 2013 11:09:13 +0000 (UTC) Message-ID: <529F0C88.3000604@philipashmore.com> Date: Wed, 04 Dec 2013 11:05:00 -0000 From: Philip Ashmore User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130922 Icedove/17.0.9 MIME-Version: 1.0 To: libffi-discuss@sourceware.org Subject: Re: RFC: variadic closures in x86/x86_64 References: <52931854.6080007@redhat.com> <20131125093715.GU892@tucnak.redhat.com> <5293221D.4010505@redhat.com> <20131126142723.GD9211@bubble.grove.modra.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013/txt/msg00232.txt.bz2 On 04/12/13 08:02, Hogan, D. (GE Power & Water) wrote: > 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. > I may be talking through my hat but if there's a format argument then couldn't you provide a function to parse it and then prepare other cifs on an as-needed basis? The key would be the concatenation of all the types in the format argument. That way you wouldn't need to modify libffi. Regards, Philip Ashmore