@@ -4,7 +4,7 @@ from ../libffi/doc/libffi.texi.
44This manual is for Libffi, a portable foreign-function interface
55library.
66
7- Copyright (C) 2008, 2010 Red Hat, Inc.
7+ Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
88
99 Permission is granted to copy, distribute and/or modify this
1010 document under the terms of the GNU General Public License as
2727This manual is for Libffi, a portable foreign-function interface
2828library.
2929
30- Copyright (C) 2008, 2010 Red Hat, Inc.
30+ Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
3131
3232 Permission is granted to copy, distribute and/or modify this
3333 document under the terms of the GNU General Public License as
@@ -115,8 +115,6 @@ To prepare a call interface object, use the function `ffi_prep_cif'.
115115 want. *note Multiple ABIs:: for more information.
116116
117117 NARGS is the number of arguments that this function accepts.
118- `libffi' does not yet handle varargs functions; see *note Missing
119- Features:: for more information.
120118
121119 RTYPE is a pointer to an `ffi_type' structure that describes the
122120 return type of the function. *Note Types::.
@@ -129,6 +127,30 @@ To prepare a call interface object, use the function `ffi_prep_cif'.
129127 properly; `FFI_BAD_TYPEDEF' if one of the `ffi_type' objects is
130128 incorrect; or `FFI_BAD_ABI' if the ABI parameter is invalid.
131129
130+ If the function being called is variadic (varargs) then
131+ `ffi_prep_cif_var' must be used instead of `ffi_prep_cif'.
132+
133+ -- Function: ffi_status ffi_prep_cif_var (ffi_cif *CIF, ffi_abi
134+ varabi, unsigned int NFIXEDARGS, unsigned int varntotalargs,
135+ ffi_type *RTYPE, ffi_type **ARGTYPES)
136+ This initializes CIF according to the given parameters for a call
137+ to a variadic function. In general it's operation is the same as
138+ for `ffi_prep_cif' except that:
139+
140+ NFIXEDARGS is the number of fixed arguments, prior to any variadic
141+ arguments. It must be greater than zero.
142+
143+ NTOTALARGS the total number of arguments, including variadic and
144+ fixed arguments.
145+
146+ Note that, different cif's must be prepped for calls to the same
147+ function when different numbers of arguments are passed.
148+
149+ Also note that a call to `ffi_prep_cif_var' with
150+ NFIXEDARGS=NOTOTALARGS is NOT equivalent to a call to
151+ `ffi_prep_cif'.
152+
153+
132154 To call a function using an initialized `ffi_cif', use the
133155`ffi_call' function:
134156
@@ -147,7 +169,9 @@ To prepare a call interface object, use the function `ffi_prep_cif'.
147169 AVALUES is a vector of `void *' pointers that point to the memory
148170 locations holding the argument values for a call. If CIF declares
149171 that the function has no arguments (i.e., NARGS was 0), then
150- AVALUES is ignored.
172+ AVALUES is ignored. Note that argument values may be modified by
173+ the callee (for instance, structs passed by value); the burden of
174+ copying pass-by-value arguments is placed on the caller.
151175
152176
153177File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
@@ -294,7 +318,7 @@ is perfectly happy passing structures back and forth. You must first
294318describe the structure to `libffi' by creating a new `ffi_type' object
295319for it.
296320
297- -- ffi_type:
321+ -- Data type: ffi_type
298322 The `ffi_type' has the following members:
299323 `size_t size'
300324 This is set by `libffi'; you should initialize it to zero.
@@ -509,16 +533,17 @@ File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi,
509533`libffi' is missing a few features. We welcome patches to add support
510534for these.
511535
512- * There is no support for calling varargs functions. This may work
513- on some platforms, depending on how the ABI is defined, but it is
514- not reliable.
536+ * Variadic closures.
515537
516538 * There is no support for bit fields in structures.
517539
518540 * The closure API is
519541
520542 * The "raw" API is undocumented.
521543
544+ Note that variadic support is very new and tested on a relatively
545+ small number of platforms.
546+
522547
523548File: libffi.info, Node: Index, Prev: Missing Features, Up: Top
524549
@@ -528,19 +553,19 @@ Index
528553