1 // Replacement for sys/mman.h which factors out platform differences.
5 #if defined(VGO_darwin)
6 # define MAP_ANONYMOUS MAP_ANON
13 // Map a page, then unmap it, then return that address. That
14 // guarantees to give an address which will fault when accessed,
15 // without making any assumptions about the layout of the address
18 __attribute__((unused
))
19 static void* get_unmapped_page(void)
23 long pagesz
= sysconf(_SC_PAGE_SIZE
);
24 assert(pagesz
== 4096 || pagesz
== 8192 || pagesz
== 16384 || pagesz
== 32768
26 ptr
= mmap(0, pagesz
, PROT_READ
, MAP_ANONYMOUS
|MAP_PRIVATE
, -1, 0);
27 assert(ptr
!= (void*)-1);
28 r
= munmap(ptr
, pagesz
);