8 #define MAP_ANON MAP_ANONYMOUS
16 static int dev_zero = -1;
20 runtime_SysAlloc(uintptr n)
29 dev_zero = open("/dev/zero", O_RDONLY);
31 printf("open /dev/zero: errno=%d\n", errno);
38 p = runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, fd, 0);
39 if (p == MAP_FAILED) {
41 printf("mmap: access denied\n");
42 printf("If you're running SELinux, enable execmem for this process.\n");
44 printf("mmap: errno=%d\n", errno);
52 runtime_SysUnused(void *v, uintptr n)
56 // TODO(rsc): call madvise MADV_DONTNEED
60 runtime_SysFree(void *v, uintptr n)
67 runtime_SysMemInit(void)
69 // Code generators assume that references to addresses
70 // on the first page will fault. Map the page explicitly with
71 // no permissions, to head off possible bugs like the system
72 // allocating that page as the virtual address space fills.
73 // Ignore any error, since other systems might be smart
74 // enough to never allow anything there.
75 runtime_mmap(nil, 4096, PROT_NONE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);