1 // Copyright 2018 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.
11 // Don't split the stack as this method may be invoked without a valid G, which
12 // prevents us from allocating more stack.
15 func sysAllocOS(n uintptr) unsafe.Pointer {
16 p, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
19 print("runtime: mmap: access denied\n")
23 print("runtime: mmap: too much locked memory (check 'ulimit -l').\n")
31 func sysUnusedOS(v unsafe.Pointer, n uintptr) {
32 madvise(v, n, _MADV_DONTNEED)
35 func sysUsedOS(v unsafe.Pointer, n uintptr) {
38 func sysHugePageOS(v unsafe.Pointer, n uintptr) {
41 func sysNoHugePageOS(v unsafe.Pointer, n uintptr) {
44 func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) {
47 // Don't split the stack as this function may be invoked without a valid G,
48 // which prevents us from allocating more stack.
51 func sysFreeOS(v unsafe.Pointer, n uintptr) {
55 func sysFaultOS(v unsafe.Pointer, n uintptr) {
56 mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE|_MAP_FIXED, -1, 0)
59 func sysReserveOS(v unsafe.Pointer, n uintptr) unsafe.Pointer {
60 p, err := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
67 func sysMapOS(v unsafe.Pointer, n uintptr) {
68 // AIX does not allow mapping a range that is already mapped.
69 // So, call mprotect to change permissions.
70 // Note that sysMap is always called with a non-nil pointer
71 // since it transitions a Reserved memory region to Prepared,
72 // so mprotect is always possible.
73 _, err := mprotect(v, n, _PROT_READ|_PROT_WRITE)
75 throw("runtime: out of memory")
78 print("runtime: mprotect(", v, ", ", n, ") returned ", err, "\n")
79 throw("runtime: cannot map pages in arena address space")