This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: variadic closures in x86/x86_64


On 05/12/13 00:54, Hogan, D. (GE Power & Water) wrote:
> Hi Philip,
> 
>> 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.
> 
> Do you mean inside of a closure?  I could access the assumed type
> information from the formatting string.  The problem would be with
> ffi_call().  I can't send in a value for a variadic argument since
> I don't have a pointer to it.
> 
No, I mean inside a regular function, as libffi doesn't (yet) support
variadic closures.

I don't know if it's possible to portably get pointers to variadic
arguments using va_arg, but if it is then you build up a list of
variadic arguments, synthesize a call using libffi by constructing a cif
with prep_cif_var if you don't already have an identical one, then call
the "real" function.

But then why not just call the "real" function?

I was (in my own convoluted way) trying to suggest a possible libffi
variadic closure implementation.

Any approach needs some hint as to the number and types of arguments to
unpack, like a format string.

Then it can do what it wants, like provide the arguments as a type/value
list, to the psuedo-variadic closure function to process.

The psuedo-variadic closure function could then have extra arguments - a
count and a type/value array pointer (or a pointer in libffi type-speak)
so you wouldn't even need a cif to call it.

Regards,
Philip Ashmore


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]