diff options
author | Hans <h-c-mueller@users.noreply.github.com> | 2022-09-18 01:56:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 19:56:25 -0400 |
commit | ee22ecbd11f52f8de1adbb2a6561aee2125a576a (patch) | |
tree | 7db565ad12b2bc7ec66a5b20b964e377415bb67c /src | |
parent | 5e010474cf2e30fa053f0a1a460a752f06438cf7 (diff) | |
download | libffi-ee22ecbd11f52f8de1adbb2a6561aee2125a576a.tar.gz |
Add MSYS configuration files (#728)
* Add MSYS configuration files
MSYS behaves very similiar to Cygwin, e.g. also __CYGWIN__ is defined.
Now 'make check' passes on MSYS without extra patches.
* Fix warning extra tokens at end of #endif in closures.c
Extra tokens converted into a comment. Also nearby indentations corrected.
* Fix missing prototype warning mkostemp() on Cygwin
Cygwin requires also _GNU_SOURCE to be defined to enable mkostemp() prototype.
* Fix warning label ‘out’ defined but not used in ffi functions
Define same preprocessor conditions for goto and label visibility.
* Fix warning label ‘out’ defined but not used and related indentations.
Define same preprocessor conditions for goto and label visibility. Correct also
related indentations.
Co-authored-by: Hannes Müller <>
Diffstat (limited to 'src')
-rw-r--r-- | src/aarch64/ffi.c | 20 | ||||
-rw-r--r-- | src/arm/ffi.c | 26 | ||||
-rw-r--r-- | src/closures.c | 18 | ||||
-rw-r--r-- | src/loongarch64/ffi.c | 2 | ||||
-rw-r--r-- | src/x86/ffi.c | 2 | ||||
-rw-r--r-- | src/x86/ffi64.c | 2 | ||||
-rw-r--r-- | src/x86/ffiw64.c | 2 |
7 files changed, 42 insertions, 30 deletions
diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c index 76d2938..83e5653 100644 --- a/src/aarch64/ffi.c +++ b/src/aarch64/ffi.c @@ -832,14 +832,14 @@ ffi_prep_closure_loc (ffi_closure *closure, start = ffi_closure_SYSV; #if FFI_EXEC_TRAMPOLINE_TABLE -#ifdef __MACH__ -#ifdef HAVE_PTRAUTH +# ifdef __MACH__ +# ifdef HAVE_PTRAUTH codeloc = ptrauth_auth_data(codeloc, ptrauth_key_function_pointer, 0); -#endif +# endif void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE); config[0] = closure; config[1] = start; -#endif +# endif #else static const unsigned char trampoline[16] = { 0x90, 0x00, 0x00, 0x58, /* ldr x16, tramp+16 */ @@ -848,7 +848,7 @@ ffi_prep_closure_loc (ffi_closure *closure, }; char *tramp = closure->tramp; -#if defined(FFI_EXEC_STATIC_TRAMP) +# if defined(FFI_EXEC_STATIC_TRAMP) if (ffi_tramp_is_present(closure)) { /* Initialize the static trampoline's parameters. */ @@ -859,7 +859,7 @@ ffi_prep_closure_loc (ffi_closure *closure, ffi_tramp_set_parms (closure->ftramp, start, closure); goto out; } -#endif +# endif /* Initialize the dynamic trampoline. */ memcpy (tramp, trampoline, sizeof(trampoline)); @@ -869,15 +869,17 @@ ffi_prep_closure_loc (ffi_closure *closure, ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE); /* Also flush the cache for code mapping. */ -#ifdef _WIN32 +# ifdef _WIN32 // Not using dlmalloc.c for Windows ARM64 builds // so calling ffi_data_to_code_pointer() isn't necessary unsigned char *tramp_code = tramp; - #else +# else unsigned char *tramp_code = ffi_data_to_code_pointer (tramp); - #endif +# endif ffi_clear_cache (tramp_code, tramp_code + FFI_TRAMPOLINE_SIZE); +# if defined(FFI_EXEC_STATIC_TRAMP) out: +# endif #endif closure->cif = cif; diff --git a/src/arm/ffi.c b/src/arm/ffi.c index 985dbee..cfd3e9d 100644 --- a/src/arm/ffi.c +++ b/src/arm/ffi.c @@ -626,7 +626,7 @@ ffi_prep_closure_loc (ffi_closure * closure, config[1] = closure_func; #else -#if defined(FFI_EXEC_STATIC_TRAMP) +# if defined(FFI_EXEC_STATIC_TRAMP) if (ffi_tramp_is_present(closure)) { /* Initialize the static trampoline's parameters. */ @@ -637,31 +637,33 @@ ffi_prep_closure_loc (ffi_closure * closure, ffi_tramp_set_parms (closure->ftramp, closure_func, closure); goto out; } -#endif +# endif /* Initialize the dynamic trampoline. */ -#ifndef _WIN32 +# ifndef _WIN32 memcpy(closure->tramp, ffi_arm_trampoline, 8); -#else +# else // cast away function type so MSVC doesn't set the lower bit of the function pointer memcpy(closure->tramp, (void*)((uintptr_t)ffi_arm_trampoline & 0xFFFFFFFE), FFI_TRAMPOLINE_CLOSURE_OFFSET); -#endif +# endif -#if defined(__QNX__) +# if defined(__QNX__) msync (closure->tramp, 8, MS_INVALIDATE_ICACHE); /* clear data map */ msync (codeloc, 8, MS_INVALIDATE_ICACHE); /* clear insn map */ -#elif defined(_WIN32) +# elif defined(_WIN32) FlushInstructionCache(GetCurrentProcess(), closure->tramp, FFI_TRAMPOLINE_SIZE); -#else +# else __clear_cache(closure->tramp, closure->tramp + 8); /* clear data map */ __clear_cache(codeloc, codeloc + 8); /* clear insn map */ -#endif -#ifdef _WIN32 +# endif +# ifdef _WIN32 *(void(**)(void))(closure->tramp + FFI_TRAMPOLINE_CLOSURE_FUNCTION) = closure_func; -#else +# else *(void (**)(void))(closure->tramp + 8) = closure_func; -#endif +# endif +# if defined(FFI_EXEC_STATIC_TRAMP) out: +# endif #endif closure->cif = cif; diff --git a/src/closures.c b/src/closures.c index e2bc651..3b7a0ac 100644 --- a/src/closures.c +++ b/src/closures.c @@ -27,7 +27,7 @@ DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- */ -#if defined __linux__ && !defined _GNU_SOURCE +#if (defined __linux__ || defined __CYGWIN__) && !defined _GNU_SOURCE #define _GNU_SOURCE 1 #endif @@ -142,17 +142,17 @@ ffi_tramp_is_present (__attribute__((unused)) void *ptr) #endif #if FFI_MMAP_EXEC_WRIT && defined(__linux__) && !defined(__ANDROID__) -# if !defined FFI_MMAP_EXEC_SELINUX -/* When defined to 1 check for SELinux and if SELinux is active, - don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that - might cause audit messages. */ -# define FFI_MMAP_EXEC_SELINUX 1 +# if !defined FFI_MMAP_EXEC_SELINUX +/* When defined to 1 check for SELinux and if SELinux is active, + don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that + might cause audit messages. */ +# define FFI_MMAP_EXEC_SELINUX 1 # endif /* !defined FFI_MMAP_EXEC_SELINUX */ # if !defined FFI_MMAP_PAX -/* Also check for PaX MPROTECT */ -# define FFI_MMAP_PAX 1 +/* Also check for PaX MPROTECT */ +# define FFI_MMAP_PAX 1 # endif /* !defined FFI_MMAP_PAX */ -#endif FFI_MMAP_EXEC_WRIT && defined(__linux__) && !defined(__ANDROID__) +#endif /* FFI_MMAP_EXEC_WRIT && defined(__linux__) && !defined(__ANDROID__) */ #if FFI_CLOSURES diff --git a/src/loongarch64/ffi.c b/src/loongarch64/ffi.c index ed9c15f..140be3b 100644 --- a/src/loongarch64/ffi.c +++ b/src/loongarch64/ffi.c @@ -538,7 +538,9 @@ ffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif, __builtin___clear_cache (codeloc, codeloc + FFI_TRAMPOLINE_SIZE); +#if defined(FFI_EXEC_STATIC_TRAMP) out: +#endif closure->cif = cif; closure->fun = fun; closure->user_data = user_data; diff --git a/src/x86/ffi.c b/src/x86/ffi.c index 3da6716..b82d8c0 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -614,7 +614,9 @@ ffi_prep_closure_loc (ffi_closure* closure, tramp[9] = 0xe9; *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14); +#if defined(FFI_EXEC_STATIC_TRAMP) out: +#endif closure->cif = cif; closure->fun = fun; closure->user_data = user_data; diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c index 22d43f5..6a8e37f 100644 --- a/src/x86/ffi64.c +++ b/src/x86/ffi64.c @@ -799,7 +799,9 @@ ffi_prep_closure_loc (ffi_closure* closure, memcpy (tramp, trampoline, sizeof(trampoline)); *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)dest; +#if defined(FFI_EXEC_STATIC_TRAMP) out: +#endif closure->cif = cif; closure->fun = fun; closure->user_data = user_data; diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c index 263aa5b..8271658 100644 --- a/src/x86/ffiw64.c +++ b/src/x86/ffiw64.c @@ -263,7 +263,9 @@ EFI64(ffi_prep_closure_loc)(ffi_closure* closure, memcpy (tramp, trampoline, sizeof(trampoline)); *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)ffi_closure_win64; +#if defined(FFI_EXEC_STATIC_TRAMP) out: +#endif closure->cif = cif; closure->fun = fun; closure->user_data = user_data; |