re PR libffi/52221 ([libffi] r183675,r184021 needs to be fixed.)
authorKai Tietz <ktietz@redhat.com>
Mon, 13 Feb 2012 15:18:14 +0000 (16:18 +0100)
committerKai Tietz <ktietz@gcc.gnu.org>
Mon, 13 Feb 2012 15:18:14 +0000 (16:18 +0100)
        PR libffi/52221
        * src/x86/ffi.c (ffi_prep_raw_closure_loc): Add thiscall
        support for X86_WIN32.
        (FFI_INIT_TRAMPOLINE_THISCALL): Fix displacement.

From-SVN: r184155

libffi/ChangeLog
libffi/src/x86/ffi.c

index c10a000e1bb58ba480c1744fc6bf3cd27c421b6f..3b3167ae77bc949e920518f4c2f1275c1a8f4696 100644 (file)
@@ -1,3 +1,10 @@
+2012-02-13  Kai Tietz  <ktietz@redhat.com>
+
+       PR libffi/52221
+       * src/x86/ffi.c (ffi_prep_raw_closure_loc): Add thiscall
+       support for X86_WIN32.
+       (FFI_INIT_TRAMPOLINE_THISCALL): Fix displacement.
+
 2012-02-11  Eric Botcazou  <ebotcazou@adacore.com>
 
        * src/sparc/v9.S (STACKFRAME): Bump to 176.
index 7c01c57c4db81f3682aec2915b6905ef10fc964d..88edbc102f9fb8eab3b5bb834f4e052d981818bd 100644 (file)
@@ -614,7 +614,7 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
 { unsigned char *__tramp = (unsigned char*)(TRAMP); \
    unsigned int  __fun = (unsigned int)(FUN); \
    unsigned int  __ctx = (unsigned int)(CTX); \
-   unsigned int  __dis = __fun - (__ctx + 22);  \
+   unsigned int  __dis = __fun - (__ctx + 49);  \
    unsigned short __size = (unsigned short)(SIZE); \
    *(unsigned int *) &__tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \
    *(unsigned int *) &__tramp[4] = 0x4c890cec; /* sub $12, %esp */ \
@@ -720,6 +720,9 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
   int i;
 
   if (cif->abi != FFI_SYSV) {
+#ifdef X86_WIN32
+    if (cif->abi != FFI_THISCALL)
+#endif
     return FFI_BAD_ABI;
   }
 
@@ -734,10 +737,20 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
       FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
     }
   
-
+#ifdef X86_WIN32
+  if (cif->abi == FFI_SYSV)
+    {
+#endif
   FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
                        codeloc);
-    
+#ifdef X86_WIN32
+    }
+  else if (cif->abi == FFI_THISCALL)
+    {
+      FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0], &ffi_closure_raw_SYSV,
+                                   codeloc, cif->bytes);
+    }
+#endif
   closure->cif  = cif;
   closure->user_data = user_data;
   closure->fun  = fun;