mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
I tried using 'svn merge' to do the merge but it did a terrible job and there were bazillions of conflicts. So instead I just took the diff between the branch and trunk at r10155, applied the diff to the trunk, 'svn add'ed the added files (no files needed to be 'svn remove'd) and committed. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10156
32 lines
744 B
C
32 lines
744 B
C
// Replacement for sys/mman.h which factors out platform differences.
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#if defined(VGO_darwin)
|
|
# define MAP_ANONYMOUS MAP_ANON
|
|
#endif
|
|
|
|
|
|
#include <assert.h>
|
|
#include <unistd.h>
|
|
|
|
// Map a page, then unmap it, then return that address. That
|
|
// guarantees to give an address which will fault when accessed,
|
|
// without making any assumptions about the layout of the address
|
|
// space.
|
|
|
|
__attribute__((unused))
|
|
static void* get_unmapped_page(void)
|
|
{
|
|
void* ptr;
|
|
int r;
|
|
long pagesz = sysconf(_SC_PAGE_SIZE);
|
|
assert(pagesz == 4096 || pagesz == 65536);
|
|
ptr = mmap(0, pagesz, PROT_READ, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
|
assert(ptr != (void*)-1);
|
|
r = munmap(ptr, pagesz);
|
|
assert(r == 0);
|
|
return ptr;
|
|
}
|
|
|