1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
diff -ru libffi-3.2.1/src/x86/ffi.c libffi-3.2.1/src/x86/ffi.c
--- libffi-3.2.1/src/x86/ffi.c 2014-11-08 21:47:24.000000000 +0900
+++ libffi-3.2.1/src/x86/ffi.c 2014-12-25 18:46:14.806761900 +0900
@@ -99,11 +99,13 @@
i != 0;
i--, p_arg += dir, p_argv += dir)
{
+ size_t z;
+
/* Align if necessary */
if ((sizeof(void*) - 1) & (size_t) argp)
argp = (char *) ALIGN(argp, sizeof(void*));
- size_t z = (*p_arg)->size;
+ z = (*p_arg)->size;
#ifdef X86_WIN64
if (z > FFI_SIZEOF_ARG
@@ -202,6 +204,7 @@
on top of stack, so that those can be moved to registers by call-handler. */
if (stack_args_count > 0)
{
+ int i;
if (dir < 0 && stack_args_count > 1)
{
/* Reverse order if iterating arguments backwards */
@@ -210,7 +213,6 @@
*(ffi_arg*) p_stack_data[stack_args_count - 1] = tmp;
}
- int i;
for (i = 0; i < stack_args_count; i++)
{
if (p_stack_data[i] != argp2)
@@ -569,11 +571,12 @@
i < cif->nargs && passed_regs < max_stack_count;
i++, p_arg++)
{
+ size_t sz;
if ((*p_arg)->type == FFI_TYPE_FLOAT
|| (*p_arg)->type == FFI_TYPE_STRUCT)
continue;
- size_t sz = (*p_arg)->size;
+ sz = (*p_arg)->size;
if(sz == 0 || sz > FFI_SIZEOF_ARG)
continue;
@@ -599,11 +602,13 @@
i != 0;
i--, p_arg += dir, p_argv += dir)
{
+ size_t z;
+
/* Align if necessary */
if ((sizeof(void*) - 1) & (size_t) argp)
argp = (char *) ALIGN(argp, sizeof(void*));
- size_t z = (*p_arg)->size;
+ z = (*p_arg)->size;
#ifdef X86_WIN64
if (z > FFI_SIZEOF_ARG
@@ -642,7 +647,7 @@
#endif
}
- return (size_t)argp - (size_t)stack;
+ return (int)((size_t)argp - (size_t)stack);
}
#define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
@@ -855,11 +860,12 @@
for (i = 0; i < cif->nargs && passed_regs <= max_regs; i++)
{
+ size_t sz;
if (cif->arg_types[i]->type == FFI_TYPE_FLOAT
|| cif->arg_types[i]->type == FFI_TYPE_STRUCT)
continue;
- size_t sz = cif->arg_types[i]->size;
+ sz = cif->arg_types[i]->size;
if (sz == 0 || sz > FFI_SIZEOF_ARG)
continue;
diff -ru libffi-3.2.1/src/x86/ffitarget.h libffi-3.2.1/src/x86/ffitarget.h
--- libffi-3.2.1/src/x86/ffitarget.h 2014-11-08 21:47:24.000000000 +0900
+++ libffi-3.2.1/src/x86/ffitarget.h 2014-12-22 15:45:54.000000000 +0900
@@ -50,7 +50,9 @@
#endif
#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+#ifndef _MSC_VER
#define FFI_TARGET_HAS_COMPLEX_TYPE
+#endif
/* ---- Generic type definitions ----------------------------------------- */
diff -ru libffi-3.2.1/src/x86/win64.S libffi-3.2.1/src/x86/win64.S
--- libffi-3.2.1/src/x86/win64.S 2014-11-08 21:47:24.000000000 +0900
+++ libffi-3.2.1/src/x86/win64.S 2014-12-22 16:14:40.000000000 +0900
@@ -127,7 +127,7 @@
mov rcx, QWORD PTR RVALUE[rbp]
mov DWORD PTR [rcx], eax
- jmp ret_void$
+ jmp SHORT ret_void$
ret_struct2b$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_2B
@@ -135,7 +135,7 @@
mov rcx, QWORD PTR RVALUE[rbp]
mov WORD PTR [rcx], ax
- jmp ret_void$
+ jmp SHORT ret_void$
ret_struct1b$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_1B
@@ -143,7 +143,7 @@
mov rcx, QWORD PTR RVALUE[rbp]
mov BYTE PTR [rcx], al
- jmp ret_void$
+ jmp SHORT ret_void$
ret_uint8$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT8
@@ -152,7 +152,7 @@
mov rcx, QWORD PTR RVALUE[rbp]
movzx rax, al
mov QWORD PTR [rcx], rax
- jmp ret_void$
+ jmp SHORT ret_void$
ret_sint8$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT8
@@ -161,7 +161,7 @@
mov rcx, QWORD PTR RVALUE[rbp]
movsx rax, al
mov QWORD PTR [rcx], rax
- jmp ret_void$
+ jmp SHORT ret_void$
ret_uint16$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT16
@@ -188,7 +188,13 @@
mov rcx, QWORD PTR RVALUE[rbp]
mov eax, eax
mov QWORD PTR [rcx], rax
- jmp SHORT ret_void$
+
+ret_void$:
+ xor rax, rax
+
+ lea rsp, QWORD PTR [rbp+16]
+ pop rbp
+ ret 0
ret_sint32$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32
@@ -247,13 +253,6 @@
cdqe
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
-
-ret_void$:
- xor rax, rax
-
- lea rsp, QWORD PTR [rbp+16]
- pop rbp
- ret 0
ffi_call_win64 ENDP
_TEXT ENDS
END
diff -ru libffi-3.2.1/include/ffi.h.in libffi-3.2.1/include/ffi.h.in
--- libffi-3.2.1/include/ffi.h.in 2014-11-08 21:47:24.000000000 +0900
+++ libffi-3.2.1/include/ffi.h.in 2015-01-11 12:35:30.000000000 +0900
@@ -103,6 +103,11 @@
# undef FFI_64_BIT_MAX
# define FFI_64_BIT_MAX 9223372036854775807LL
# endif
+# ifdef _MSC_VER
+# define FFI_LONG_LONG_MAX _I64_MAX
+# undef FFI_64_BIT_MAX
+# define FFI_64_BIT_MAX 9223372036854775807I64
+# endif
# endif
#endif
|