diff options
author | Martin Storsjö <martin@martin.st> | 2020-04-26 04:58:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 21:58:33 -0400 |
commit | c06468fa6674d3783a0edb1d0fae9afc8bc28513 (patch) | |
tree | e3a38584748199bd06b45a74b110dafcf2394d67 /src/closures.c | |
parent | 8c50837f0b58ba5b2bcb1b424a2a4bfa01559fb2 (diff) | |
download | libffi-c06468fa6674d3783a0edb1d0fae9afc8bc28513.tar.gz |
Fix building for aarch64 windows with mingw toolchains (#555)
* aarch64: Check _WIN32 instead of _M_ARM64 for detecting windows
This fixes building for aarch64 with mingw toolchains. _M_ARM64 is
predefined by MSVC, while mingw compilers predefine __aarch64__.
In aarch64 specific code, change checks for _M_ARM64 into checks for
_WIN32.
In arch independent code, check for
(defined(_M_ARM64) || defined(__aarch64__)) && defined(_WIN32)
instead of just _M_ARM64.
In src/closures.c, coalesce checks like
defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64)
into plain defined(_WIN32). Technically, this enables code for
ARM32 windows where it wasn't, but as far as I can see it, those
codepaths should be fine for that architecture variant as well.
* aarch64: Only use armasm source when building with MSVC
When building for windows/arm64 with clang, the normal gas style .S
source works fine. sysv.S and win64_armasm.S seem to be functionally
equivalent, with only differences being due to assembler syntax.
Diffstat (limited to 'src/closures.c')
-rw-r--r-- | src/closures.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/closures.c b/src/closures.c index b5eb2bb..4fe6158 100644 --- a/src/closures.c +++ b/src/closures.c @@ -123,7 +123,7 @@ ffi_closure_free (void *ptr) # define FFI_MMAP_EXEC_WRIT 1 # define HAVE_MNTENT 1 # endif -# if defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__) +# if defined(_WIN32) || defined(__OS2__) /* Windows systems may have Data Execution Protection (DEP) enabled, which requires the use of VirtualMalloc/VirtualFree to alloc/free executable memory. */ @@ -392,7 +392,7 @@ ffi_closure_free (void *ptr) #endif #include <string.h> #include <stdio.h> -#if !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(_M_ARM64) +#if !defined(_WIN32) #ifdef HAVE_MNTENT #include <mntent.h> #endif /* HAVE_MNTENT */ @@ -518,11 +518,11 @@ static int dlmalloc_trim(size_t) MAYBE_UNUSED; static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED; static void dlmalloc_stats(void) MAYBE_UNUSED; -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) /* Use these for mmap and munmap within dlmalloc.c. */ static void *dlmmap(void *, size_t, int, int, int, off_t); static int dlmunmap(void *, size_t); -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ #define mmap dlmmap #define munmap dlmunmap @@ -532,7 +532,7 @@ static int dlmunmap(void *, size_t); #undef mmap #undef munmap -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) /* A mutex used to synchronize access to *exec* variables in this file. */ static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -914,7 +914,7 @@ segment_holding_code (mstate m, char* addr) } #endif -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(_M_ARM64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(_WIN32) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ /* Allocate a chunk of memory with the given size. Returns a pointer to the writable address, and sets *CODE to the executable |