aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.goc
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-02-09 15:08:30 -0500
committerRuss Cox <rsc@golang.org>2011-02-09 15:08:30 -0500
commit1cc8c87dc12e6d1722acc7a3749e63848d8ea26a (patch)
treea53526d94be3c77df6642dd2e656f5a1b542bc5b /src/pkg/runtime/malloc.goc
parent5b1b2ba9c79e54b3b34d066d43e88d1a4c330790 (diff)
downloadgo-1cc8c87dc12e6d1722acc7a3749e63848d8ea26a.tar.xz
runtime: fix memory allocation on 386
BSD and Darwin require an extra page between end and the first mapping, and Windows has various memory in the way too. Fixes #1464. R=r, r2 CC=golang-dev https://golang.org/cl/4167041
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
-rw-r--r--src/pkg/runtime/malloc.goc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc
index 8899b01195..18652d71a6 100644
--- a/src/pkg/runtime/malloc.goc
+++ b/src/pkg/runtime/malloc.goc
@@ -286,10 +286,16 @@ runtime·mallocinit(void)
// of address space, which is probably too much in a 32-bit world.
bitmap_size = MaxArena32 / (sizeof(void*)*8/4);
arena_size = 512<<20;
-
- p = (void*)(((uintptr)end + 64*1024 - 1) & ~(64*1024-1));
- if(runtime·SysReserve(p, bitmap_size + arena_size) != p)
- runtime·throw("runtime: cannot reserve memory bitmap virtual address space");
+
+ // SysReserve treats the address we ask for, end, as a hint,
+ // not as an absolute requirement. If we ask for the end
+ // of the data segment but the operating system requires
+ // a little more space before we can start allocating, it will
+ // give out a slightly higher pointer. That's fine.
+ // Run with what we get back.
+ p = runtime·SysReserve(end, bitmap_size + arena_size);
+ if(p == nil)
+ runtime·throw("runtime: cannot reserve arena virtual address space");
}
runtime·mheap.bitmap = p;
runtime·mheap.arena_start = p + bitmap_size;