Source file
src/runtime/mem_darwin.go
Documentation: runtime
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 v, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
17 if err != 0 {
18 return nil
19 }
20 return v
21 }
22
23 func sysUnusedOS(v unsafe.Pointer, n uintptr) {
24
25
26 madvise(v, n, _MADV_FREE_REUSABLE)
27 }
28
29 func sysUsedOS(v unsafe.Pointer, n uintptr) {
30
31
32
33 madvise(v, n, _MADV_FREE_REUSE)
34 }
35
36 func sysHugePageOS(v unsafe.Pointer, n uintptr) {
37 }
38
39 func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
40 }
41
42 func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) {
43 }
44
45
46
47
48
49 func sysFreeOS(v unsafe.Pointer, n uintptr) {
50 munmap(v, n)
51 }
52
53 func sysFaultOS(v unsafe.Pointer, n uintptr) {
54 mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE|_MAP_FIXED, -1, 0)
55 }
56
57 func sysReserveOS(v unsafe.Pointer, n uintptr) unsafe.Pointer {
58 p, err := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
59 if err != 0 {
60 return nil
61 }
62 return p
63 }
64
65 const _ENOMEM = 12
66
67 func sysMapOS(v unsafe.Pointer, n uintptr) {
68 p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
69 if err == _ENOMEM {
70 throw("runtime: out of memory")
71 }
72 if p != v || err != 0 {
73 print("runtime: mmap(", v, ", ", n, ") returned ", p, ", ", err, "\n")
74 throw("runtime: cannot map pages in arena address space")
75 }
76 }
77
View as plain text