1 Index: libffi/doc/libffi.texi
2 ===================================================================
3 --- libffi.orig/doc/libffi.texi
4 +++ libffi/doc/libffi.texi
5 @@ -171,7 +171,9 @@ discarded.
6 @var{avalues} is a vector of @code{void *} pointers that point to the
7 memory locations holding the argument values for a call. If @var{cif}
8 declares that the function has no arguments (i.e., @var{nargs} was 0),
9 -then @var{avalues} is ignored.
10 +then @var{avalues} is ignored. Note that argument values may be
11 +modified by the callee (for instance, structs passed by value); the
12 +burden of copying pass-by-value arguments is placed on the caller.
16 Index: libffi/src/x86/ffi.c
17 ===================================================================
18 --- libffi.orig/src/x86/ffi.c
19 +++ libffi/src/x86/ffi.c
20 @@ -291,27 +291,8 @@ void ffi_call(ffi_cif *cif, void (*fn)(v
25 - /* Make copies of all struct arguments
26 - NOTE: not sure if responsibility should be here or in caller */
28 - for (i=0; i < cif->nargs;i++) {
29 - size_t size = cif->arg_types[i]->size;
30 - if ((cif->arg_types[i]->type == FFI_TYPE_STRUCT
31 - && (size != 1 && size != 2 && size != 4 && size != 8))
32 -#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
33 - || cif->arg_types[i]->type == FFI_TYPE_LONGDOUBLE
37 - void *local = alloca(size);
38 - memcpy(local, avalue[i], size);
42 - ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
43 - cif->flags, ecif.rvalue, fn);
45 + ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
46 + cif->flags, ecif.rvalue, fn);
48 #elif defined(X86_WIN32)
50 Index: libffi/ChangeLog
51 ===================================================================
52 --- libffi.orig/ChangeLog
55 * fficonfig.h.in: Regenerate.
56 * src/x86/sysv.S (.eh_frame): Use .ascii, .string or error.
58 +2010-05-11 Dan Witte <dwitte@mozilla.com>
60 + * doc/libffi.tex: Document previous change.
62 +2010-05-11 Makoto Kato <m_kato@ga2.so-net.ne.jp>
64 + * src/x86/ffi.c (ffi_call): Don't copy structs passed by value.
66 2010-05-05 Michael Kohler <michaelkohler@live.com>
68 * src/dlmalloc.c (dlfree): Fix spelling.
69 Index: libffi/doc/libffi.info
70 ===================================================================
71 --- libffi.orig/doc/libffi.info
72 +++ libffi/doc/libffi.info
74 -This is doc/libffi.info, produced by makeinfo version 4.12 from
76 +This is ../libffi/doc/libffi.info, produced by makeinfo version 4.13
77 +from ../libffi/doc/libffi.texi.
79 This manual is for Libffi, a portable foreign-function interface
82 - Copyright (C) 2008 Red Hat, Inc.
83 + Copyright (C) 2008, 2010 Red Hat, Inc.
85 Permission is granted to copy, distribute and/or modify this
86 document under the terms of the GNU General Public License as
87 @@ -13,7 +13,7 @@ library.
88 included in the section entitled "GNU General Public License".
92 +INFO-DIR-SECTION Development
94 * libffi: (libffi). Portable foreign-function interface library.
96 @@ -27,7 +27,7 @@ libffi
97 This manual is for Libffi, a portable foreign-function interface
100 - Copyright (C) 2008 Red Hat, Inc.
101 + Copyright (C) 2008, 2010 Red Hat, Inc.
103 Permission is granted to copy, distribute and/or modify this
104 document under the terms of the GNU General Public License as
105 @@ -89,6 +89,7 @@ File: libffi.info, Node: Using libffi,
106 * Types:: libffi type descriptions.
107 * Multiple ABIs:: Different passing styles on one platform.
108 * The Closure API:: Writing a generic function.
109 +* Closure Example:: A closure example.
112 File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
113 @@ -146,7 +147,9 @@ To prepare a call interface object, use
114 AVALUES is a vector of `void *' pointers that point to the memory
115 locations holding the argument values for a call. If CIF declares
116 that the function has no arguments (i.e., NARGS was 0), then
117 - AVALUES is ignored.
118 + AVALUES is ignored. Note that argument values may be modified by
119 + the callee (for instance, structs passed by value); the burden of
120 + copying pass-by-value arguments is placed on the caller.
123 File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
124 @@ -368,7 +371,7 @@ instance, the x86 platform has both `std
125 necessarily platform-specific.
128 -File: libffi.info, Node: The Closure API, Prev: Multiple ABIs, Up: Using libffi
129 +File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
133 @@ -444,6 +447,62 @@ is deprecated, as it cannot handle the n
134 executable addresses.
137 +File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
142 +A trivial example that creates a new `puts' by binding `fputs' with
148 + /* Acts like puts with the file given at time of enclosure. */
149 + void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
152 + *ret = fputs(*(char **)args[0], stream);
159 + ffi_closure *closure;
161 + int (*bound_puts)(char *);
164 + /* Allocate closure and bound_puts */
165 + closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
169 + /* Initialize the argument info vectors */
170 + args[0] = &ffi_type_pointer;
172 + /* Initialize the cif */
173 + if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
174 + &ffi_type_uint, args) == FFI_OK)
176 + /* Initialize the closure, setting stream to stdout */
177 + if (ffi_prep_closure_loc(closure, &cif, puts_binding,
178 + stdout, bound_puts) == FFI_OK)
180 + rc = bound_puts("Hello World!");
181 + /* rc now holds the result of the call to fputs */
186 + /* Deallocate both closure, and bound_puts */
187 + ffi_closure_free(closure);
193 File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
196 @@ -480,7 +539,7 @@ Index
197 * closures: The Closure API. (line 13)
198 * FFI: Introduction. (line 31)
199 * ffi_call: The Basics. (line 41)
200 -* ffi_closure_alloca: The Closure API. (line 19)
201 +* ffi_closure_alloc: The Closure API. (line 19)
202 * ffi_closure_free: The Closure API. (line 26)
203 * FFI_CLOSURES: The Closure API. (line 13)
204 * ffi_prep_cif: The Basics. (line 16)
205 @@ -516,18 +575,19 @@ Index
210 -Node: Introduction
\7f1406
211 -Node: Using libffi
\7f3042
212 -Node: The Basics
\7f3477
213 -Node: Simple Example
\7f6084
215 -Node: Primitive Types
\7f7394
216 -Node: Structures
\7f9214
217 -Node: Type Example
\7f10074
218 -Node: Multiple ABIs
\7f11297
219 -Node: The Closure API
\7f11668
220 -Node: Missing Features
\7f14588
223 +Node: Introduction
\7f1448
224 +Node: Using libffi
\7f3084
225 +Node: The Basics
\7f3570
226 +Node: Simple Example
\7f6356
228 +Node: Primitive Types
\7f7666
229 +Node: Structures
\7f9486
230 +Node: Type Example
\7f10346
231 +Node: Multiple ABIs
\7f11569
232 +Node: The Closure API
\7f11940
233 +Node: Closure Example
\7f14884
234 +Node: Missing Features
\7f16443