summaryrefslogtreecommitdiff
path: root/src/types.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2013-11-21 06:12:35 -0500
committerAnthony Green <green@moxielogic.com>2013-11-21 21:24:56 -0500
commitab79d6e21992dd86139ba07530ff888833b78a04 (patch)
tree3ed261655ba53cd2269dba583d6f3bf561adb34d /src/types.c
parent69df91cfb4fa6bcb644350a80bff970f27478a6a (diff)
downloadlibffi-ab79d6e21992dd86139ba07530ff888833b78a04.tar.gz
This separates the 32-bit sysv/linux/bsd code from the 64-bit linux
code, and makes it possible to link code compiled with different options to those used to compile libffi. For example, a -mlong-double-128 libffi can be used with -mlong-double-64 code. Using the return value area as a place to pass parameters wasn't such a good idea, causing a failure of cls_ulonglong.c. I didn't see this when running the mainline gcc libffi testsuite because that version of the test is inferior to the upstreamm libffi test. Using NUM_FPR_ARG_REGISTERS rather than NUM_FPR_ARG_REGISTERS64 meant that a parameter save area could be allocated before it was strictly necessary. Wrong but harmless. Found when splitting apart ffi.c into 32-bit and 64-bit support.
Diffstat (limited to 'src/types.c')
-rw-r--r--src/types.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/types.c b/src/types.c
index 0a11eb0..0de5994 100644
--- a/src/types.c
+++ b/src/types.c
@@ -44,6 +44,17 @@ const ffi_type ffi_type_##name = { \
id, NULL \
}
+#define FFI_NONCONST_TYPEDEF(name, type, id) \
+struct struct_align_##name { \
+ char c; \
+ type x; \
+}; \
+ffi_type ffi_type_##name = { \
+ sizeof(type), \
+ offsetof(struct struct_align_##name, x), \
+ id, NULL \
+}
+
/* Size and alignment are fake here. They must not be 0. */
const ffi_type ffi_type_void = {
1, 1, FFI_TYPE_VOID, NULL
@@ -73,5 +84,9 @@ FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE);
# endif
const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+# if HAVE_LONG_DOUBLE_VARIANT
+FFI_NONCONST_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
+# else
FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
+# endif
#endif