]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: complete windows SysReserve
authorRuss Cox <rsc@golang.org>
Thu, 10 Feb 2011 20:39:08 +0000 (15:39 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 10 Feb 2011 20:39:08 +0000 (15:39 -0500)
Should fix windows/386 build.

R=brainman
CC=golang-dev
https://golang.org/cl/4170041

src/pkg/runtime/windows/mem.c

index c523195a46ae8af585c6132dc43ed3e53fd7f562..54d77da37e2f0d0da5b1b631e6efb6995f6850f9 100644 (file)
@@ -48,7 +48,14 @@ runtime·SysFree(void *v, uintptr n)
 void*
 runtime·SysReserve(void *v, uintptr n)
 {
-       return runtime·stdcall(runtime·VirtualAlloc, 4, v, n, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+       // v is just a hint.
+       // First try at v.
+       v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+       if(v != nil)
+               return v;
+       
+       // Next let the kernel choose the address.
+       return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
 }
 
 void