Source File
cgo_mmap.go
Belonging Package
runtime
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Support for memory sanitizer. See runtime/cgo/mmap.go.
//go:build (linux && (amd64 || arm64 || loong64)) || (freebsd && amd64)
package runtime
import
// _cgo_mmap is filled in by runtime/cgo when it is linked into the
// program, so it is only non-nil when using cgo.
//
//go:linkname _cgo_mmap _cgo_mmap
var _cgo_mmap unsafe.Pointer
// _cgo_munmap is filled in by runtime/cgo when it is linked into the
// program, so it is only non-nil when using cgo.
//
//go:linkname _cgo_munmap _cgo_munmap
var _cgo_munmap unsafe.Pointer
// mmap is used to route the mmap system call through C code when using cgo, to
// support sanitizer interceptors. Don't allow stack splits, since this function
// (used by sysAlloc) is called in a lot of low-level parts of the runtime and
// callers often assume it won't acquire any locks.
//
//go:nosplit
func mmap( unsafe.Pointer, uintptr, , , int32, uint32) (unsafe.Pointer, int) {
if _cgo_mmap != nil {
// Make ret a uintptr so that writing to it in the
// function literal does not trigger a write barrier.
// A write barrier here could break because of the way
// that mmap uses the same value both as a pointer and
// an errno value.
var uintptr
systemstack(func() {
= callCgoMmap(, , , , , )
})
if < 4096 {
return nil, int()
}
return unsafe.Pointer(), 0
}
return sysMmap(, , , , , )
}
func munmap( unsafe.Pointer, uintptr) {
if _cgo_munmap != nil {
systemstack(func() { callCgoMunmap(, ) })
return
}
sysMunmap(, )
}
// sysMmap calls the mmap system call. It is implemented in assembly.
func sysMmap( unsafe.Pointer, uintptr, , , int32, uint32) ( unsafe.Pointer, int)
// callCgoMmap calls the mmap function in the runtime/cgo package
// using the GCC calling convention. It is implemented in assembly.
func callCgoMmap( unsafe.Pointer, uintptr, , , int32, uint32) uintptr
// sysMunmap calls the munmap system call. It is implemented in assembly.
func sysMunmap( unsafe.Pointer, uintptr)
// callCgoMunmap calls the munmap function in the runtime/cgo package
// using the GCC calling convention. It is implemented in assembly.
func callCgoMunmap( unsafe.Pointer, uintptr)
The pages are generated with Golds v0.7.3-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |