x86: Add support for Complex
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
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 {