github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sync/race_unsafe.go (about) 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 // +build race 7 8 package sync 9 10 import ( 11 "runtime" 12 "unsafe" 13 ) 14 15 // RaceEnabled is true if the Go data race detector is enabled. 16 const RaceEnabled = true 17 18 // RaceDisable has the same semantics as runtime.RaceDisable. 19 func RaceDisable() { 20 runtime.RaceDisable() 21 } 22 23 // RaceEnable has the same semantics as runtime.RaceEnable. 24 func RaceEnable() { 25 runtime.RaceEnable() 26 } 27 28 // RaceAcquire has the same semantics as runtime.RaceAcquire. 29 func RaceAcquire(addr unsafe.Pointer) { 30 runtime.RaceAcquire(addr) 31 } 32 33 // RaceRelease has the same semantics as runtime.RaceRelease. 34 func RaceRelease(addr unsafe.Pointer) { 35 runtime.RaceRelease(addr) 36 } 37 38 // RaceReleaseMerge has the same semantics as runtime.RaceReleaseMerge. 39 func RaceReleaseMerge(addr unsafe.Pointer) { 40 runtime.RaceReleaseMerge(addr) 41 } 42 43 // RaceUncheckedAtomicCompareAndSwapUintptr is equivalent to 44 // sync/atomic.CompareAndSwapUintptr, but is not checked by the race detector. 45 // This is necessary when implementing gopark callbacks, since no race context 46 // is available during their execution. 47 func RaceUncheckedAtomicCompareAndSwapUintptr(ptr *uintptr, old, new uintptr) bool