Revision: 1743
http://vcs.pcre.org/viewvc?view=rev&revision=1743
Author: zherczeg
Date: 2018-12-13 13:24:22 +0000 (Thu, 13 Dec 2018)
Log Message:
-----------
Fix MAP_JIT issues on Mac. Patch by Carlo Arenas.
Modified Paths:
--------------
code/trunk/sljit/sljitExecAllocator.c
Modified: code/trunk/sljit/sljitExecAllocator.c
===================================================================
--- code/trunk/sljit/sljitExecAllocator.c 2018-11-25 17:09:20 UTC (rev 1742)
+++ code/trunk/sljit/sljitExecAllocator.c 2018-12-13 13:24:22 UTC (rev 1743)
@@ -96,32 +96,31 @@
#ifdef MAP_JIT
+#ifdef __APPLE__
+#include <sys/utsname.h>
+#endif /* __APPLE__ */
+
static SLJIT_INLINE int get_map_jit_flag()
{
-#ifdef TARGET_OS_MAC
+#ifdef __APPLE__
/* On macOS systems, returns MAP_JIT if it is defined _and_ we're running on a version
of macOS where it's OK to have more than one JIT block. On non-macOS systems, returns
MAP_JIT if it is defined. */
+ static int map_jit_flag = -1;
- static dispatch_once_t _inited;
- static int map_jit_flag;
+ if (map_jit_flag == -1) {
+ struct utsname name;
- dispatch_once(&_inited,
- ^() {
- struct utsname name;
+ uname(&name);
- uname(&name);
+ /* Kernel version for 10.14.0 (Mojave) */
+ map_jit_flag = (atoi(name.release) >= 18) ? MAP_JIT : 0;
+ }
- /* Kernel version for 10.14.0 (Mojave) */
- if (atoi(name.release) >= 18)
- map_jit_flag = MAP_JIT;
- }
- );
-
return map_jit_flag;
-#else /* !TARGET_OS_MAC */
+#else /* !__APPLE__ */
return MAP_JIT;
-#endif /* TARGET_OS_MAC */
+#endif /* __APPLE__ */
}
#endif /* MAP_JIT */