norace_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  	"sync/atomic"
  13  	"unsafe"
  14  )
  15  
  16  // RaceEnabled is true if the Go data race detector is enabled.
  17  const RaceEnabled = false
  18  
  19  // RaceDisable has the same semantics as runtime.RaceDisable.
  20  func RaceDisable() {
  21  }
  22  
  23  // RaceEnable has the same semantics as runtime.RaceEnable.
  24  func RaceEnable() {
  25  }
  26  
  27  // RaceAcquire has the same semantics as runtime.RaceAcquire.
  28  func RaceAcquire(addr unsafe.Pointer) {
  29  }
  30  
  31  // RaceRelease has the same semantics as runtime.RaceRelease.
  32  func RaceRelease(addr unsafe.Pointer) {
  33  }
  34  
  35  // RaceReleaseMerge has the same semantics as runtime.RaceReleaseMerge.
  36  func RaceReleaseMerge(addr unsafe.Pointer) {
  37  }
  38  
  39  // RaceUncheckedAtomicCompareAndSwapUintptr is equivalent to
  40  // sync/atomic.CompareAndSwapUintptr, but is not checked by the race detector.
  41  // This is necessary when implementing gopark callbacks, since no race context
  42  // is available during their execution.
  43  func RaceUncheckedAtomicCompareAndSwapUintptr(ptr *uintptr, old, new uintptr) bool {
  44  	// Use atomic.CompareAndSwapUintptr outside of race builds for
  45  	// inlinability.
  46  	return atomic.CompareAndSwapUintptr(ptr, old, new)
  47  }
  48