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: Variadic functions and libffi


On 2011/1/6 01:47, David Gilbert wrote:
> 'ffi_prep_cif_variadic'
> 
> that is just like ffi_prep_cif but also takes a 'nnamedargs' to say
> the number of fixed args (and hence which arg is the 1st variadic).
> For all architectures that don't care this can just call ffi_prep_cif
> and lose the extra arg, this should mean it won't break anything else,
> but any architecture that did need to know which were variadic args
> would have that information.

That sounds like a reasonable design, although it seems possible to do
away with the 'nnamedargs', and treat ffi_prep_cif_variadic() as
effectively just "adding an ellipse (...)", and leave the variable
argument issues to ffi_call().

This will effectively delay some of the normal ffi_prep_cif() work to
ffi_call() (things like laying out the regs/stack for the variable
arguments), and may be slower when doing the calling, but should be a
more intuitive API design; users just create the needed arg-list at each
call, rather than creating a new ffi_cif instance for each variable
argument set.

That said, I think the proposed 'nnamedargs' style is still fine, for it
should be more straightforward to implement :)

Chung-Lin


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