github.com/q45/go@v0.0.0-20151101211701-a4fb8c13db3f/src/runtime/cgo_mmap.go (about)

     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  // Support for memory sanitizer.  See runtime/cgo/mmap.go.
     6  
     7  // +build linux,amd64
     8  
     9  package runtime
    10  
    11  import "unsafe"
    12  
    13  // _cgo_mmap is filled in by runtime/cgo when it is linked into the
    14  // program, so it is only non-nil when using cgo.
    15  //go:linkname _cgo_mmap _cgo_mmap
    16  var _cgo_mmap unsafe.Pointer
    17  
    18  func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (ret unsafe.Pointer) {
    19  	if _cgo_mmap != nil {
    20  		systemstack(func() {
    21  			ret = callCgoMmap(addr, n, prot, flags, fd, off)
    22  		})
    23  		return
    24  	}
    25  	return sysMmap(addr, n, prot, flags, fd, off)
    26  }
    27  
    28  // sysMmap calls the mmap system call.  It is implemented in assembly.
    29  func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) unsafe.Pointer
    30  
    31  // cgoMmap calls the mmap function in the runtime/cgo package on the
    32  // callCgoMmap calls the mmap function in the runtime/cgo package
    33  // using the GCC calling convention.  It is implemented in assembly.
    34  func callCgoMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) unsafe.Pointer