Handle fastcall declaration differently for some Microsoft compilers
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 70 71 72 73 74 75 76
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index feb5cbb..4c2dd08 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -1,5 +1,6 @@
/* -----------------------------------------------------------------------
- ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc.
+ ffi.c - Copyright (c) 2017 Anthony Green
+ Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc.
Copyright (c) 2002 Ranjit Mathew
Copyright (c) 2002 Bo Thorsen
Copyright (c) 2002 Roger Sayle
@@ -234,11 +235,17 @@ static const struct abi_params abi_params[FFI_LAST_ABI] = {
[FFI_MS_CDECL] = { 1, R_ECX, 0 }
};
-extern void ffi_call_i386(struct call_frame *, char *)
-#if HAVE_FASTCALL
- __declspec(fastcall)
+#ifdef HAVE_FASTCALL
+ #ifdef _MSC_VER
+ #define FFI_DECLARE_FASTCALL __fastcall
+ #else
+ #define FFI_DECLARE_FASTCALL __declspec(fastcall)
+ #endif
+#else
+ #define FFI_DECLARE_FASTCALL
#endif
- FFI_HIDDEN;
+
+extern void FFI_DECLARE_FASTCALL ffi_call_i386(struct call_frame *, char *) FFI_HIDDEN;
static void
ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
@@ -395,10 +402,7 @@ struct closure_frame
void *user_data; /* 36 */
};
-int FFI_HIDDEN
-#if HAVE_FASTCALL
-__declspec(fastcall)
-#endif
+int FFI_HIDDEN FFI_DECLARE_FASTCALL
ffi_closure_inner (struct closure_frame *frame, char *stack)
{
ffi_cif *cif = frame->cif;
diff --git a/src/x86/sysv.S b/src/x86/sysv.S
index 78f245b..116e908 100644
--- a/src/x86/sysv.S
+++ b/src/x86/sysv.S
@@ -1,6 +1,7 @@
/* -----------------------------------------------------------------------
- sysv.S - Copyright (c) 2013 The Written Word, Inc.
- - Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc.
+ sysv.S - Copyright (c) 2017 Anthony Green
+ - Copyright (c) 2013 The Written Word, Inc.
+ - Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc.
X86 Foreign Function Interface
@@ -26,6 +27,7 @@
----------------------------------------------------------------------- */
#ifndef __x86_64__
+#ifndef _MSC_VER
#define LIBFFI_ASM
#include <fficonfig.h>
@@ -1033,6 +1035,7 @@ L(SFDE9):
L(EFDE9):
#endif /* !FFI_NO_RAW_API */
+#endif /* ifndef _MSC_VER */
#endif /* ifndef __x86_64__ */
#if defined __ELF__ && defined __linux__