Source file src/runtime/cgo/mmap.go

     1  // Copyright 2015 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  //go:build (linux && (amd64 || arm64 || loong64)) || (freebsd && amd64)
     6  
     7  package cgo
     8  
     9  // Import "unsafe" because we use go:linkname.
    10  import _ "unsafe"
    11  
    12  // When using cgo, call the C library for mmap, so that we call into
    13  // any sanitizer interceptors. This supports using the memory
    14  // sanitizer with Go programs. The memory sanitizer only applies to
    15  // C/C++ code; this permits that code to see the Go code as normal
    16  // program addresses that have been initialized.
    17  
    18  // To support interceptors that look for both mmap and munmap,
    19  // also call the C library for munmap.
    20  
    21  //go:cgo_import_static x_cgo_mmap
    22  //go:linkname x_cgo_mmap x_cgo_mmap
    23  //go:linkname _cgo_mmap _cgo_mmap
    24  var x_cgo_mmap byte
    25  var _cgo_mmap = &x_cgo_mmap
    26  
    27  //go:cgo_import_static x_cgo_munmap
    28  //go:linkname x_cgo_munmap x_cgo_munmap
    29  //go:linkname _cgo_munmap _cgo_munmap
    30  var x_cgo_munmap byte
    31  var _cgo_munmap = &x_cgo_munmap
    32  

View as plain text