From 198f469e91076f84ab6ac38055ad12a5490101cd Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 5 Nov 2014 16:34:41 +0100 Subject: [PATCH] x86: Add support for Complex --- src/x86/ffi.c | 27 +++++++++++++++++++++++++++ testsuite/libffi.call/call.exp | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 40e47d2..a0d0cf3 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -120,6 +120,7 @@ ffi_prep_cif_machdep(ffi_cif *cif) else #endif { + do_struct: switch (cabi) { case FFI_THISCALL: @@ -136,6 +137,32 @@ ffi_prep_cif_machdep(ffi_cif *cif) bytes += ALIGN (sizeof(void*), FFI_SIZEOF_ARG); } break; + case FFI_TYPE_COMPLEX: + switch (cif->rtype->elements[0]->type) + { + case FFI_TYPE_DOUBLE: + case FFI_TYPE_LONGDOUBLE: + case FFI_TYPE_SINT64: + case FFI_TYPE_UINT64: + goto do_struct; + case FFI_TYPE_FLOAT: + case FFI_TYPE_INT: + case FFI_TYPE_SINT32: + case FFI_TYPE_UINT32: + flags = X86_RET_INT64; + break; + case FFI_TYPE_SINT16: + case FFI_TYPE_UINT16: + flags = X86_RET_INT32; + break; + case FFI_TYPE_SINT8: + case FFI_TYPE_UINT8: + flags = X86_RET_STRUCT_2B; + break; + default: + return FFI_BAD_TYPEDEF; + } + break; default: return FFI_BAD_TYPEDEF; } diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp index 55de25c..d42dae5 100644 --- a/testsuite/libffi.call/call.exp +++ b/testsuite/libffi.call/call.exp @@ -27,7 +27,8 @@ run-many-tests $tlist "" # ??? We really should preprocess ffi.h and grep # for FFI_TARGET_HAS_COMPLEX_TYPE. if { [istarget s390*] - || [istarget x86_64*] } { + || [istarget x86_64*] + || [istarget i?86*] } { run-many-tests $ctlist "" } else { foreach test $ctlist { -- 2.7.4