# define __declspec(x) __attribute__((x))
#endif
+#if defined(_MSC_VER) && defined(_M_IX86)
+/* Stack is not 16-byte aligned on Windows. */
+#define STACK_ALIGN(bytes) (bytes)
+#else
+#define STACK_ALIGN(bytes) FFI_ALIGN (bytes, 16)
+#endif
+
/* Perform machine dependent cif processing. */
ffi_status FFI_HIDDEN
ffi_prep_cif_machdep(ffi_cif *cif)
bytes = FFI_ALIGN (bytes, t->alignment);
bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG);
}
-#if defined(_MSC_VER) && defined(_M_IX86)
- // stack is not 16-bit aligned on Windows
cif->bytes = bytes;
-#else
- cif->bytes = FFI_ALIGN (bytes, 16);
-#endif
return FFI_OK;
}
}
}
- bytes = cif->bytes;
+ bytes = STACK_ALIGN (cif->bytes);
stack = alloca(bytes + sizeof(*frame) + rsize);
argp = (dir < 0 ? stack + bytes : stack);
frame = (struct call_frame *)(stack + bytes);
rvalue = frame->rettemp;
pabi = &abi_params[cabi];
dir = pabi->dir;
- argp = (dir < 0 ? stack + cif->bytes : stack);
+ argp = (dir < 0 ? stack + STACK_ALIGN (cif->bytes) : stack);
switch (flags)
{
}
}
- bytes = cif->bytes;
+ bytes = STACK_ALIGN (cif->bytes);
argp = stack =
(void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16);
frame = (struct call_frame *)(stack + bytes);