diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
commit | 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch) | |
tree | 4449f2036cccf162e8417cc5841a35815b3e7ac5 /src/pkg/runtime/mem_netbsd.c | |
parent | c8bf49ef8a92e2337b69c14b9b88396efe498600 (diff) | |
download | golang-upstream/1.3.tar.gz |
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'src/pkg/runtime/mem_netbsd.c')
-rw-r--r-- | src/pkg/runtime/mem_netbsd.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/pkg/runtime/mem_netbsd.c b/src/pkg/runtime/mem_netbsd.c index 91e36eb60..861ae90c7 100644 --- a/src/pkg/runtime/mem_netbsd.c +++ b/src/pkg/runtime/mem_netbsd.c @@ -45,32 +45,41 @@ runtime·SysFree(void *v, uintptr n, uint64 *stat) runtime·munmap(v, n); } +void +runtime·SysFault(void *v, uintptr n) +{ + runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0); +} + void* -runtime·SysReserve(void *v, uintptr n) +runtime·SysReserve(void *v, uintptr n, bool *reserved) { void *p; // On 64-bit, people with ulimit -v set complain if we reserve too // much address space. Instead, assume that the reservation is okay // and check the assumption in SysMap. - if(sizeof(void*) == 8) + if(sizeof(void*) == 8 && n > 1LL<<32) { + *reserved = false; return v; + } p = runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); if(p < (void*)4096) return nil; + *reserved = true; return p; } void -runtime·SysMap(void *v, uintptr n, uint64 *stat) +runtime·SysMap(void *v, uintptr n, bool reserved, uint64 *stat) { void *p; runtime·xadd64(stat, n); // On 64-bit, we don't actually have v reserved, so tread carefully. - if(sizeof(void*) == 8) { + if(!reserved) { p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); if(p == (void*)ENOMEM) runtime·throw("runtime: out of memory"); |