Handle win32 ABIs for struct return
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
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index f867c20..b8bb178 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -117,34 +117,37 @@ ffi_prep_cif_machdep(ffi_cif *cif)
flags = X86_RET_INT64;
break;
case FFI_TYPE_STRUCT:
-#ifndef X86
- if (cif->rtype->size == 1)
- flags = X86_RET_STRUCT_1B;
- else if (cif->rtype->size == 2)
- flags = X86_RET_STRUCT_2B;
- else if (cif->rtype->size == 4)
- flags = X86_RET_INT32;
- else if (cif->rtype->size == 8)
- flags = X86_RET_INT64;
- else
+ {
+#ifdef X86_WIN32
+ size_t size = cif->rtype->size;
+ if (size == 1)
+ flags = X86_RET_STRUCT_1B;
+ else if (size == 2)
+ flags = X86_RET_STRUCT_2B;
+ else if (size == 4)
+ flags = X86_RET_INT32;
+ else if (size == 8)
+ flags = X86_RET_INT64;
+ else
#endif
- {
- do_struct:
- switch (cabi)
- {
- case FFI_THISCALL:
- case FFI_FASTCALL:
- case FFI_STDCALL:
- case FFI_MS_CDECL:
- flags = X86_RET_STRUCTARG;
- break;
- default:
- flags = X86_RET_STRUCTPOP;
- break;
- }
- /* Allocate space for return value pointer. */
- bytes += FFI_ALIGN (sizeof(void*), FFI_SIZEOF_ARG);
- }
+ {
+ do_struct:
+ switch (cabi)
+ {
+ case FFI_THISCALL:
+ case FFI_FASTCALL:
+ case FFI_STDCALL:
+ case FFI_MS_CDECL:
+ flags = X86_RET_STRUCTARG;
+ break;
+ default:
+ flags = X86_RET_STRUCTPOP;
+ break;
+ }
+ /* Allocate space for return value pointer. */
+ bytes += FFI_ALIGN (sizeof(void*), FFI_SIZEOF_ARG);
+ }
+ }
break;
case FFI_TYPE_COMPLEX:
switch (cif->rtype->elements[0]->type)