Index: libffi/doc/libffi.texi
===================================================================
--- libffi.orig/doc/libffi.texi
+++ libffi/doc/libffi.texi
@@ -171,7 +171,9 @@ discarded.
 @var{avalues} is a vector of @code{void *} pointers that point to the
 memory locations holding the argument values for a call.  If @var{cif}
 declares that the function has no arguments (i.e., @var{nargs} was 0),
-then @var{avalues} is ignored.
+then @var{avalues} is ignored.  Note that argument values may be
+modified by the callee (for instance, structs passed by value); the
+burden of copying pass-by-value arguments is placed on the caller.
 @end defun
 
 
Index: libffi/src/x86/ffi.c
===================================================================
--- libffi.orig/src/x86/ffi.c
+++ libffi/src/x86/ffi.c
@@ -291,27 +291,8 @@ void ffi_call(ffi_cif *cif, void (*fn)(v
     {
 #ifdef X86_WIN64
     case FFI_WIN64:
-      {
-        /* Make copies of all struct arguments
-           NOTE: not sure if responsibility should be here or in caller */
-        unsigned int i;
-        for (i=0; i < cif->nargs;i++) {
-          size_t size = cif->arg_types[i]->size;
-          if ((cif->arg_types[i]->type == FFI_TYPE_STRUCT
-               && (size != 1 && size != 2 && size != 4 && size != 8))
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-              || cif->arg_types[i]->type == FFI_TYPE_LONGDOUBLE
-#endif
-              )
-            {
-              void *local = alloca(size);
-              memcpy(local, avalue[i], size);
-              avalue[i] = local;
-            }
-        }
-        ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
-                       cif->flags, ecif.rvalue, fn);
-      }
+      ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
+                     cif->flags, ecif.rvalue, fn);
       break;
 #elif defined(X86_WIN32)
     case FFI_SYSV:
Index: libffi/ChangeLog
===================================================================
--- libffi.orig/ChangeLog
+++ libffi/ChangeLog
@@ -238,6 +238,14 @@
 	* fficonfig.h.in: Regenerate.
 	* src/x86/sysv.S (.eh_frame): Use .ascii, .string or error.
 
+2010-05-11  Dan Witte  <dwitte@mozilla.com>
+
+	* doc/libffi.tex: Document previous change.
+
+2010-05-11  Makoto Kato <m_kato@ga2.so-net.ne.jp>
+
+	* src/x86/ffi.c (ffi_call): Don't copy structs passed by value.
+
 2010-05-05  Michael Kohler <michaelkohler@live.com>
 
 	* src/dlmalloc.c (dlfree): Fix spelling.
Index: libffi/doc/libffi.info
===================================================================
--- libffi.orig/doc/libffi.info
+++ libffi/doc/libffi.info
@@ -147,7 +147,9 @@ To prepare a call interface object, use
      AVALUES is a vector of `void *' pointers that point to the memory
      locations holding the argument values for a call.  If CIF declares
      that the function has no arguments (i.e., NARGS was 0), then
-     AVALUES is ignored.
+     AVALUES is ignored.  Note that argument values may be modified by
+     the callee (for instance, structs passed by value); the burden of
+     copying pass-by-value arguments is placed on the caller.
 
 
 File: libffi.info,  Node: Simple Example,  Next: Types,  Prev: The Basics,  Up: Using libffi
@@ -577,15 +579,15 @@ Node: Top724
 Node: Introduction1466
 Node: Using libffi3102
 Node: The Basics3588
-Node: Simple Example6195
-Node: Types7222
-Node: Primitive Types7505
-Node: Structures9325
-Node: Type Example10185
-Node: Multiple ABIs11408
-Node: The Closure API11779
-Node: Closure Example14723
-Node: Missing Features16282
-Node: Index16775
+Node: Simple Example6374
+Node: Types7401
+Node: Primitive Types7684
+Node: Structures9504
+Node: Type Example10364
+Node: Multiple ABIs11587
+Node: The Closure API11958
+Node: Closure Example14902
+Node: Missing Features16461
+Node: Index16954
 
 End Tag Table
