This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
RE: RFC: variadic closures in x86/x86_64
- From: "Hogan, D. (GE Power & Water)" <D dot Hogan at ge dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: Alan Modra <amodra at gmail dot com>, Jakub Jelinek <jakub at redhat dot com>, "libffi-discuss at sourceware dot org" <libffi-discuss at sourceware dot org>
- Date: Thu, 5 Dec 2013 00:47:35 +0000
- Subject: RE: RFC: variadic closures in x86/x86_64
- Authentication-results: sourceware.org; auth=none
- References: <F023C084BCC16446BDA5B664305741E8090811 at ALPMBAPA05 dot e2k dot ad dot ge dot com> <52931854 dot 6080007 at redhat dot com> <20131125093715 dot GU892 at tucnak dot redhat dot com> <5293221D dot 4010505 at redhat dot com> <20131126142723 dot GD9211 at bubble dot grove dot modra dot org> <F023C084BCC16446BDA5B664305741E8091C7D at ALPMBAPA05 dot e2k dot ad dot ge dot com> <529F1E3E dot 4010401 at redhat dot com> <F023C084BCC16446BDA5B664305741E8091DD8 at ALPMBAPA05 dot e2k dot ad dot ge dot com> <529F7989 dot 1050000 at redhat dot com>
On Wed, Dec 04, 2013 at 00:01:51PM, Andrew Haley wrote:
> > In the libffi manual, there's a TODO about variadic closures.
>
> That's AFAIK to do with targets that have a different calling
> convention for variadic calls.
Ok, this is the source of my confusion then. I thought the manual was
saying you wanted libffi to be able to create closures that could
iterate through variadic arguments they were called with.
> > My interpretation of variadic closures is a closure which can access
> > variadic arguments without sending in the number of arguments and
> > types at the ffi_prep_cif or ffi_prep_cif_var time. Once you have a
> > variadic closure, you should be call it any number of times with any
> > number of variadic arguments.
>
> Forgive me, but that's not an answer. I have provided an example of a
> mechanism that JNA could use that would not require us to change
> libffi. Couldn't you do this in JNA? It doesn't have to be
> application-specific.
I'm sure it would work. A similar suggestion is mentioned in the CFFI
documentation. It would require a C function for every assumed
variadic processing convention. For instance, FMI requires
#<Type><valueReference># which is not a typical printf/logger
convention. I didn't go down that path because I thought the manual
was asking for patches for a different way.
Thanks for the feedback.