public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Philip Ashmore <contact@philipashmore.com>
To: libffi-discuss@sourceware.org
Subject: Re: RFC: variadic closures in x86/x86_64
Date: Thu, 05 Dec 2013 13:03:00 -0000	[thread overview]
Message-ID: <52A0799A.6070500@philipashmore.com> (raw)
In-Reply-To: <F023C084BCC16446BDA5B664305741E8091E8B@ALPMBAPA05.e2k.ad.ge.com>

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

  parent reply	other threads:[~2013-12-05 13:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25  2:46 Hogan, D. (GE Power & Water)
2013-11-25  9:29 ` Andrew Haley
2013-11-25  9:37   ` Jakub Jelinek
2013-11-25 10:10     ` Andrew Haley
2013-11-26 14:27       ` Alan Modra
2013-12-04  8:03         ` Hogan, D. (GE Power & Water)
2013-12-04 11:05           ` Philip Ashmore
     [not found]             ` <F023C084BCC16446BDA5B664305741E8091E8B@ALPMBAPA05.e2k.ad.ge.com>
2013-12-05 13:03               ` Philip Ashmore [this message]
2013-12-04 12:21           ` Andrew Haley
2013-12-04 18:28             ` Hogan, D. (GE Power & Water)
2013-12-04 18:51               ` Andrew Haley
2013-12-05  0:47                 ` Hogan, D. (GE Power & Water)
2013-12-05  8:33                   ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52A0799A.6070500@philipashmore.com \
    --to=contact@philipashmore.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).