1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:20:11 -07:00

runtime: fix Windows SysUsed

Same fix as for SysUnused.
Fixes #8038.

LGTM=iant, alex.brainman
R=golang-codereviews, iant, alex.brainman
CC=golang-codereviews
https://golang.org/cl/147820043
This commit is contained in:
Russ Cox 2014-09-18 20:41:00 -04:00
parent 54245cba1f
commit 048692e5de

View File

@ -68,10 +68,22 @@ void
runtime·SysUsed(void *v, uintptr n)
{
void *r;
uintptr small;
r = runtime·stdcall4(runtime·VirtualAlloc, (uintptr)v, n, MEM_COMMIT, PAGE_READWRITE);
if(r != v)
runtime·throw("runtime: failed to commit pages");
// Commit failed. See SysUnused.
while(n > 0) {
small = n;
while(small >= 4096 && runtime·stdcall4(runtime·VirtualAlloc, (uintptr)v, small, MEM_COMMIT, PAGE_READWRITE) == nil)
small = (small / 2) & ~(4096-1);
if(small < 4096)
runtime·throw("runtime: failed to decommit pages");
v = (byte*)v + small;
n -= small;
}
}
void