Rebase
[platform/upstream/libffi.git] / patches / stdcall-x86-closure-fix
1 Index: libffi/ChangeLog
2 ===================================================================
3 --- libffi.orig/ChangeLog
4 +++ libffi/ChangeLog
5 @@ -65,6 +65,14 @@
6         * testsuite/libffi.call/cls_longdouble.c: Likewise.
7         * testsuite/libffi.call/huge_struct.c: Likewise.
8  
9 +2010-08-04  Dan Witte  <dwitte@mozilla.com>
10 +
11 +       * src/x86/ffitarget.h: Add X86_ANY define for all x86/x86_64
12 +       platforms.
13 +       * src/x86/ffi.c: Remove redundant ifdef checks.
14 +       * src/prep_cif.c: Push stack space computation into src/x86/ffi.c
15 +       for X86_ANY so return value space doesn't get added twice.
16 +
17  2010-07-22  Dan Witte  <dwitte@mozilla.com>
18  
19         * src/*/ffitarget.h: Make FFI_LAST_ABI one past the last valid ABI.
20 Index: libffi/src/prep_cif.c
21 ===================================================================
22 --- libffi.orig/src/prep_cif.c
23 +++ libffi/src/prep_cif.c
24 @@ -110,7 +110,7 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff
25    FFI_ASSERT_VALID_TYPE(cif->rtype);
26  
27    /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */
28 -#if !defined M68K && !defined __i386__ && !defined __x86_64__ && !defined S390 && !defined PA
29 +#if !defined M68K && !defined X86_ANY && !defined S390 && !defined PA
30    /* Make space for the return structure pointer */
31    if (cif->rtype->type == FFI_TYPE_STRUCT
32  #ifdef SPARC
33 @@ -131,7 +131,7 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff
34          check after the initialization.  */
35        FFI_ASSERT_VALID_TYPE(*ptr);
36  
37 -#if !defined __i386__ && !defined __x86_64__ && !defined S390 && !defined PA
38 +#if !defined X86_ANY && !defined S390 && !defined PA
39  #ifdef SPARC
40        if (((*ptr)->type == FFI_TYPE_STRUCT
41            && ((*ptr)->size > 16 || cif->abi != FFI_V9))
42 Index: libffi/src/x86/ffi.c
43 ===================================================================
44 --- libffi.orig/src/x86/ffi.c
45 +++ libffi/src/x86/ffi.c
46 @@ -155,12 +155,10 @@ ffi_status ffi_prep_cif_machdep(ffi_cif 
47    switch (cif->rtype->type)
48      {
49      case FFI_TYPE_VOID:
50 -#if defined(X86) || defined (X86_WIN32) || defined(X86_FREEBSD) || defined(X86_DARWIN) || defined(X86_WIN64)
51      case FFI_TYPE_UINT8:
52      case FFI_TYPE_UINT16:
53      case FFI_TYPE_SINT8:
54      case FFI_TYPE_SINT16:
55 -#endif
56  #ifdef X86_WIN64
57      case FFI_TYPE_UINT32:
58      case FFI_TYPE_SINT32:
59 Index: libffi/src/x86/ffitarget.h
60 ===================================================================
61 --- libffi.orig/src/x86/ffitarget.h
62 +++ libffi/src/x86/ffitarget.h
63 @@ -31,6 +31,9 @@
64  
65  /* ---- System specific configurations ----------------------------------- */
66  
67 +/* For code common to all platforms on x86 and x86_64. */
68 +#define X86_ANY
69 +
70  #if defined (X86_64) && defined (__i386__)
71  #undef X86_64
72  #define X86
73 @@ -67,16 +70,14 @@ typedef enum ffi_abi {
74    FFI_LAST_ABI,
75    /* TODO: Add fastcall support for the sake of completeness */
76    FFI_DEFAULT_ABI = FFI_SYSV
77 -#endif
78  
79 -#ifdef X86_WIN64
80 +#elif defined(X86_WIN64)
81    FFI_WIN64,
82    FFI_LAST_ABI,
83    FFI_DEFAULT_ABI = FFI_WIN64
84 -#else
85  
86 +#else
87    /* ---- Intel x86 and AMD x86-64 - */
88 -#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__) || defined(__i386) || defined(__amd64))
89    FFI_SYSV,
90    FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
91    FFI_LAST_ABI,
92 @@ -86,7 +87,6 @@ typedef enum ffi_abi {
93    FFI_DEFAULT_ABI = FFI_UNIX64
94  #endif
95  #endif
96 -#endif /* X86_WIN64 */
97  } ffi_abi;
98  #endif
99