Source file src/runtime/cgo/cgo_unix.go

     1  // Copyright 2026 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 goexperiment.cgobindings && (darwin || (linux && !android && (amd64 || arm64)))
     6  
     7  package cgo
     8  
     9  import (
    10  	"internal/cpu"
    11  	"unsafe"
    12  )
    13  
    14  const offsetX86HasAVX = unsafe.Offsetof(cpu.X86.HasAVX)
    15  
    16  //go:linkname _cgo_tsan_acquire_fn _cgo_tsan_acquire_fn
    17  var _cgo_tsan_acquire_fn uintptr
    18  
    19  //go:linkname _cgo_tsan_release_fn _cgo_tsan_release_fn
    20  var _cgo_tsan_release_fn uintptr
    21  
    22  //go:linkname _cgo_msan_unpoison_fn _cgo_msan_unpoison_fn
    23  var _cgo_msan_unpoison_fn uintptr
    24  
    25  //go:nosplit
    26  //go:norace
    27  func tsanAcquire() {
    28  	if _cgo_tsan_acquire_fn != 0 {
    29  		callC(_cgo_tsan_acquire_fn, 0, 0, 0, 0, 0, 0)
    30  	}
    31  }
    32  
    33  //go:nosplit
    34  //go:norace
    35  func tsanRelease() {
    36  	if _cgo_tsan_release_fn != 0 {
    37  		callC(_cgo_tsan_release_fn, 0, 0, 0, 0, 0, 0)
    38  	}
    39  }
    40  
    41  //go:nosplit
    42  //go:norace
    43  func msanUnpoison(addr unsafe.Pointer, size uintptr) {
    44  	if _cgo_msan_unpoison_fn != 0 {
    45  		callC(_cgo_msan_unpoison_fn, uintptr(addr), size, 0, 0, 0, 0)
    46  	}
    47  }
    48  
    49  // callC calls a C function pointer fn with up to 6 integer/pointer arguments
    50  // using the platform C ABI and returns its integer/pointer result.
    51  //
    52  //go:noescape
    53  func callC(fn, a0, a1, a2, a3, a4, a5 uintptr) uintptr
    54  

View as plain text