From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1057 invoked by alias); 5 Dec 2013 13:03:38 -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 1041 invoked by uid 89); 5 Dec 2013 13:03:37 -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 autolearn=ham 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; Thu, 05 Dec 2013 13:03:36 +0000 Received: from [192.168.0.10] (unknown [176.61.108.16]) (Authenticated sender: contact@philipashmore.com) by philipashmore.com (Postfix) with ESMTPSA id 2B89160647 for ; Thu, 5 Dec 2013 13:07:04 +0000 (UTC) Message-ID: <52A0799A.6070500@philipashmore.com> Date: Thu, 05 Dec 2013 13:03: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> <529F0C88.3000604@philipashmore.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013/txt/msg00238.txt.bz2 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