1
// Copyright 2010 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
15
PAGE_EXECUTE_READWRITE = 0x40,
18
#pragma dynimport runtime·VirtualAlloc VirtualAlloc "kernel32.dll"
19
#pragma dynimport runtime·VirtualFree VirtualFree "kernel32.dll"
20
extern void *runtime·VirtualAlloc;
21
extern void *runtime·VirtualFree;
24
runtime·SysAlloc(uintptr n)
27
return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
31
runtime·SysUnused(void *v, uintptr n)
38
runtime·SysFree(void *v, uintptr n)
43
r = (uintptr)runtime·stdcall(runtime·VirtualFree, 3, v, 0, MEM_RELEASE);
45
runtime·throw("runtime: failed to release pages");
49
runtime·SysReserve(void *v, uintptr n)
53
v = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
57
// Next let the kernel choose the address.
58
return runtime·stdcall(runtime·VirtualAlloc, 4, nil, n, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
62
runtime·SysMap(void *v, uintptr n)
67
p = runtime·stdcall(runtime·VirtualAlloc, 4, v, n, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
69
runtime·throw("runtime: cannot map pages in arena address space");