race_unsafe.go raw

   1  // Copyright 2019 The gVisor Authors.
   2  //
   3  // Use of this source code is governed by a BSD-style
   4  // license that can be found in the LICENSE file.
   5  
   6  //go:build race
   7  // +build race
   8  
   9  package sync
  10  
  11  import (
  12  	"runtime"
  13  	"unsafe"
  14  )
  15  
  16  // RaceEnabled is true if the Go data race detector is enabled.
  17  const RaceEnabled = true
  18  
  19  // RaceDisable has the same semantics as runtime.RaceDisable.
  20  func RaceDisable() {
  21  	runtime.RaceDisable()
  22  }
  23  
  24  // RaceEnable has the same semantics as runtime.RaceEnable.
  25  func RaceEnable() {
  26  	runtime.RaceEnable()
  27  }
  28  
  29  // RaceAcquire has the same semantics as runtime.RaceAcquire.
  30  func RaceAcquire(addr unsafe.Pointer) {
  31  	runtime.RaceAcquire(addr)
  32  }
  33  
  34  // RaceRelease has the same semantics as runtime.RaceRelease.
  35  func RaceRelease(addr unsafe.Pointer) {
  36  	runtime.RaceRelease(addr)
  37  }
  38  
  39  // RaceReleaseMerge has the same semantics as runtime.RaceReleaseMerge.
  40  func RaceReleaseMerge(addr unsafe.Pointer) {
  41  	runtime.RaceReleaseMerge(addr)
  42  }
  43  
  44  // RaceUncheckedAtomicCompareAndSwapUintptr is equivalent to
  45  // sync/atomic.CompareAndSwapUintptr, but is not checked by the race detector.
  46  // This is necessary when implementing gopark callbacks, since no race context
  47  // is available during their execution.
  48  func RaceUncheckedAtomicCompareAndSwapUintptr(ptr *uintptr, old, new uintptr) bool
  49