1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 09:47:17 +00:00

MAP_ANON(YMOUS) not strictly needed.

This commit is contained in:
Calvin Rose 2022-12-03 11:45:33 -06:00
parent 9ba2b40e87
commit 6c9c1cdb30

View File

@ -1294,9 +1294,12 @@ JANET_CORE_FN(cfun_ffi_jitfn,
void *ptr = VirtualAlloc(NULL, bytes.len, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); void *ptr = VirtualAlloc(NULL, bytes.len, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
#elif defined(MAP_ANONYMOUS) #elif defined(MAP_ANONYMOUS)
void *ptr = mmap(0, bytes.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); void *ptr = mmap(0, bytes.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#else #elif defined(MAP_ANON)
/* macos doesn't have MAP_ANONYMOUS */ /* macos doesn't have MAP_ANONYMOUS */
void *ptr = mmap(0, bytes.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); void *ptr = mmap(0, bytes.len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
#else
/* -std=c99 gets in the way */
void *ptr = mmap(0, bytes.len, PROT_READ | PROT_WRITE, MAP_PRIVATE, -1, 0);
#endif #endif
if (!ptr) { if (!ptr) {
janet_panic("failed to memory map writable memory"); janet_panic("failed to memory map writable memory");