...

Source file src/runtime/mem_aix.go

     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.
     4	
     5	package runtime
     6	
     7	import (
     8		"unsafe"
     9	)
    10	
    11	// Don't split the stack as this method may be invoked without a valid G, which
    12	// prevents us from allocating more stack.
    13	//go:nosplit
    14	func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {
    15		p, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
    16		if err != 0 {
    17			if err == _EACCES {
    18				print("runtime: mmap: access denied\n")
    19				exit(2)
    20			}
    21			if err == _EAGAIN {
    22				print("runtime: mmap: too much locked memory (check 'ulimit -l').\n")
    23				exit(2)
    24			}
    25			return nil
    26		}
    27		mSysStatInc(sysStat, n)
    28		return p
    29	}
    30	
    31	func sysUnused(v unsafe.Pointer, n uintptr) {
    32		madvise(v, n, _MADV_DONTNEED)
    33	}
    34	
    35	func sysUsed(v unsafe.Pointer, n uintptr) {
    36	}
    37	
    38	func sysHugePage(v unsafe.Pointer, n uintptr) {
    39	}
    40	
    41	// Don't split the stack as this function may be invoked without a valid G,
    42	// which prevents us from allocating more stack.
    43	//go:nosplit
    44	func sysFree(v unsafe.Pointer, n uintptr, sysStat *uint64) {
    45		mSysStatDec(sysStat, n)
    46		munmap(v, n)
    47	
    48	}
    49	
    50	func sysFault(v unsafe.Pointer, n uintptr) {
    51		mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE|_MAP_FIXED, -1, 0)
    52	}
    53	
    54	func sysReserve(v unsafe.Pointer, n uintptr) unsafe.Pointer {
    55		p, err := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
    56		if err != 0 {
    57			return nil
    58		}
    59		return p
    60	}
    61	
    62	func sysMap(v unsafe.Pointer, n uintptr, sysStat *uint64) {
    63		mSysStatInc(sysStat, n)
    64	
    65		// AIX does not allow mapping a range that is already mapped.
    66		// So always unmap first even if it is already unmapped.
    67		munmap(v, n)
    68		p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
    69	
    70		if err == _ENOMEM {
    71			throw("runtime: out of memory")
    72		}
    73		if p != v || err != 0 {
    74			throw("runtime: cannot map pages in arena address space")
    75		}
    76	}
    77	

View as plain text