From a94c999ba0d51ed8ec88685233f5b1ae38e894ea Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Sun, 19 Mar 2017 07:36:07 -0400 Subject: [PATCH] Handle fastcall declaration differently for some Microsoft compilers --- src/x86/ffi.c | 22 +++++++++++++--------- src/x86/sysv.S | 7 +++++-- 2 files changed, 18 insertions(+), 11 deletions(-) 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 @@ -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__ -- 2.7.4