Source file
src/runtime/mem_aix.go
1
2
3
4
5 package runtime
6
7 import (
8 "unsafe"
9 )
10
11
12
13
14
15 func sysAllocOS(n uintptr) unsafe.Pointer {
16 p, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
17 if err != 0 {
18 if err == _EACCES {
19 print("runtime: mmap: access denied\n")
20 exit(2)
21 }
22 if err == _EAGAIN {
23 print("runtime: mmap: too much locked memory (check 'ulimit -l').\n")
24 exit(2)
25 }
26 return nil
27 }
28 return p
29 }
30
31 func sysUnusedOS(v unsafe.Pointer, n uintptr) {
32 madvise(v, n, _MADV_DONTNEED)
33 }
34
35 func sysUsedOS(v unsafe.Pointer, n uintptr) {
36 }
37
38 func sysHugePageOS(v unsafe.Pointer, n uintptr) {
39 }
40
41 func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
42 }
43
44 func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) {
45 }
46
47
48
49
50
51 func sysFreeOS(v unsafe.Pointer, n uintptr) {
52 munmap(v, n)
53 }
54
55 func sysFaultOS(v unsafe.Pointer, n uintptr) {
56 mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE|_MAP_FIXED, -1, 0)
57 }
58
59 func sysReserveOS(v unsafe.Pointer, n uintptr) unsafe.Pointer {
60 p, err := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
61 if err != 0 {
62 return nil
63 }
64 return p
65 }
66
67 func sysMapOS(v unsafe.Pointer, n uintptr) {
68
69
70
71
72
73 _, err := mprotect(v, n, _PROT_READ|_PROT_WRITE)
74 if err == _ENOMEM {
75 throw("runtime: out of memory")
76 }
77 if err != 0 {
78 print("runtime: mprotect(", v, ", ", n, ") returned ", err, "\n")
79 throw("runtime: cannot map pages in arena address space")
80 }
81 }
82
View as plain text