summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-12-06 19:51:28 -0800
committerH.J. Lu <hjl.tools@gmail.com>2011-12-09 13:03:47 -0800
commit4116d0b040fb69947d27a72489b6c6025a77b9a9 (patch)
tree1f0fb9fe2a11fef306054973f5994757a49b4b9f
parent5d6637fcceef27395ea81afeae30e9c55252f095 (diff)
downloadgcc-4116d0b040fb69947d27a72489b6c6025a77b9a9.tar.gz
Fix libffi for x32.
2011-12-06 H.J. Lu <hongjiu.lu@intel.com> * src/x86/ffi64.c (ffi_call): Cast the return value to unsigned long. * src/x86/ffitarget.h (ffi_arg): Set to unsigned long long for x32. (ffi_sarg): Set to long for x32.
-rw-r--r--libffi/ChangeLog.x328
-rw-r--r--libffi/src/x86/ffi64.c2
-rw-r--r--libffi/src/x86/ffitarget.h5
3 files changed, 14 insertions, 1 deletions
diff --git a/libffi/ChangeLog.x32 b/libffi/ChangeLog.x32
new file mode 100644
index 00000000000..c73378999a1
--- /dev/null
+++ b/libffi/ChangeLog.x32
@@ -0,0 +1,8 @@
+2011-12-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * src/x86/ffi64.c (ffi_call): Cast the return value to
+ unsigned long.
+
+ * src/x86/ffitarget.h (ffi_arg): Set to unsigned long long for
+ x32.
+ (ffi_sarg): Set to long for x32.
diff --git a/libffi/src/x86/ffi64.c b/libffi/src/x86/ffi64.c
index bd907d7208c..4d87ddba062 100644
--- a/libffi/src/x86/ffi64.c
+++ b/libffi/src/x86/ffi64.c
@@ -426,7 +426,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
/* If the return value is passed in memory, add the pointer as the
first integer argument. */
if (ret_in_memory)
- reg_args->gpr[gprcount++] = (long) rvalue;
+ reg_args->gpr[gprcount++] = (unsigned long) rvalue;
avn = cif->nargs;
arg_types = cif->arg_types;
diff --git a/libffi/src/x86/ffitarget.h b/libffi/src/x86/ffitarget.h
index b85016cc01b..7a7d7a5f70e 100644
--- a/libffi/src/x86/ffitarget.h
+++ b/libffi/src/x86/ffitarget.h
@@ -53,9 +53,14 @@ typedef unsigned long long ffi_arg;
typedef long long ffi_sarg;
#endif
#else
+#if defined __x86_64__ && !defined __LP64__
+typedef unsigned long long ffi_arg;
+typedef long long ffi_sarg;
+#else
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
#endif
+#endif
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,