26 #define DEFAULT_PAGESIZE 4096; 56 prot = PROT_READ | PROT_WRITE;
60 flags = MAP_PRIVATE | MAP_ANON;
61 #elif defined(MAP_ANONYMOUS) 62 flags = MAP_PRIVATE | MAP_ANONYMOUS;
65 fd = open(
"/dev/zero", O_RDWR);
67 str = strerror(errno);
68 EMSG(
"%s: open /dev/null failed: %s", __func__, str);
73 addr = mmap(
NULL, size, prot, flags, fd, 0);
74 if (addr == MAP_FAILED) {
75 str = strerror(errno);
76 EMSG(
"%s: mmap failed: %s", __func__, str);
86 TMSG(MMAP,
"%s: size = %ld, fd = %d, addr = %p",
87 __func__, size, fd, addr);
96 static bool init_done =
false;
103 if ((ans = sysconf(_SC_PAGESIZE)) > 0) {
104 TMSG(MMAP,
"sysconf gives pagesize = %ld", ans);
void hpcrun_mmap_init(void)
static size_t hpcrun_align_pagesize(size_t size)
void * hpcrun_mmap_anon(size_t size)