"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sljit/sljitExecAllocator.c" between
pcre-8.43.tar.bz2 and pcre-8.44.tar.bz2

About: The PCRE library implements Perl compatible regular expression pattern matching.

sljitExecAllocator.c  (pcre-8.43.tar.bz2):sljitExecAllocator.c  (pcre-8.44.tar.bz2)
skipping to change at line 121 skipping to change at line 121
of macOS where it's OK to have more than one JIT block. On non-macOS s ystems, returns of macOS where it's OK to have more than one JIT block. On non-macOS s ystems, returns
MAP_JIT if it is defined. */ MAP_JIT if it is defined. */
static int map_jit_flag = -1; static int map_jit_flag = -1;
/* The following code is thread safe because multiple initialization /* The following code is thread safe because multiple initialization
sets map_jit_flag to the same value and the code has no side-effects. sets map_jit_flag to the same value and the code has no side-effects.
Changing the kernel version witout system restart is (very) unlikely. */ Changing the kernel version witout system restart is (very) unlikely. */
if (map_jit_flag == -1) { if (map_jit_flag == -1) {
struct utsname name; struct utsname name;
map_jit_flag = 0;
uname(&name); uname(&name);
/* Kernel version for 10.14.0 (Mojave) */ /* Kernel version for 10.14.0 (Mojave) */
map_jit_flag = (atoi(name.release) >= 18) ? MAP_JIT : 0; if (atoi(name.release) >= 18) {
/* Only use MAP_JIT if a hardened runtime is used, becaus
e MAP_JIT is incompatible with fork(). */
void *ptr = mmap(NULL, getpagesize(), PROT_WRITE|PROT_EXE
C, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (ptr == MAP_FAILED) {
map_jit_flag = MAP_JIT;
} else {
munmap(ptr, getpagesize());
}
}
} }
return map_jit_flag; return map_jit_flag;
#else /* !TARGET_OS_OSX */ #else /* !TARGET_OS_OSX */
return MAP_JIT; return MAP_JIT;
#endif /* TARGET_OS_OSX */ #endif /* TARGET_OS_OSX */
} }
#endif /* MAP_JIT */ #endif /* MAP_JIT */
#endif /* __APPLE__ */ #endif /* __APPLE__ */
static SLJIT_INLINE void* alloc_chunk(sljit_uw size) static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
{ {
void *retval; void *retval;
const int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
#ifdef MAP_ANON #ifdef MAP_ANON
int flags = MAP_PRIVATE | MAP_ANON; int flags = MAP_PRIVATE | MAP_ANON;
#ifdef MAP_JIT #ifdef MAP_JIT
flags |= get_map_jit_flag(); flags |= get_map_jit_flag();
#endif #endif
retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, flags, -1, 0); retval = mmap(NULL, size, prot, flags, -1, 0);
#else /* !MAP_ANON */ #else /* !MAP_ANON */
if (dev_zero < 0) { if (dev_zero < 0) {
if (open_dev_zero()) if (open_dev_zero())
return NULL; return NULL;
} }
retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE , dev_zero, 0); retval = mmap(NULL, size, prot, MAP_PRIVATE, dev_zero, 0);
#endif /* MAP_ANON */ #endif /* MAP_ANON */
return (retval != MAP_FAILED) ? retval : NULL; if (retval == MAP_FAILED)
retval = NULL;
else {
if (mprotect(retval, size, prot) < 0) {
munmap(retval, size);
retval = NULL;
}
}
return retval;
} }
static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
{ {
munmap(chunk, size); munmap(chunk, size);
} }
#endif #endif
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
 End of changes. 6 change blocks. 
4 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)