Skip to content

Commit

Permalink
Fix MAP_JIT issues on Mac. Patch by Carlo Arenas.
Browse files Browse the repository at this point in the history
git-svn-id: svn:https://vcs.exim.org/pcre/code/trunk@1743 2f5784b3-3f2a-0410-8824-cb99058d5e15
  • Loading branch information
zherczeg committed Dec 13, 2018
1 parent 7f71ad0 commit d1aab86
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions sljit/sljitExecAllocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,31 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)

#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;

dispatch_once(&_inited,
^() {
struct utsname name;
if (map_jit_flag == -1) {
struct utsname name;

uname(&name);
uname(&name);

/* Kernel version for 10.14.0 (Mojave) */
if (atoi(name.release) >= 18)
map_jit_flag = MAP_JIT;
}
);
/* Kernel version for 10.14.0 (Mojave) */
map_jit_flag = (atoi(name.release) >= 18) ? MAP_JIT : 0;
}

return map_jit_flag;
#else /* !TARGET_OS_MAC */
#else /* !__APPLE__ */
return MAP_JIT;
#endif /* TARGET_OS_MAC */
#endif /* __APPLE__ */
}

#endif /* MAP_JIT */
Expand Down

0 comments on commit d1aab86

Please sign in to comment.