mirror of
https://github.com/golang/go
synced 2024-11-23 05:00:07 -07:00
sync/atomic: remove unnecessary race instrumentation in Value
It is left from the time when Value was implemented in assembly. Now it is implemented in Go and race detector understands Go. In particular the atomic operations must provide all necessary synchronization. LGTM=adg R=golang-codereviews, adg CC=golang-codereviews, khr, rsc https://golang.org/cl/145880043
This commit is contained in:
parent
ed7db89b90
commit
8c2484ec11
@ -1,17 +0,0 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !race
|
||||
|
||||
package atomic
|
||||
|
||||
import "unsafe"
|
||||
|
||||
const raceenabled = false
|
||||
|
||||
func raceAcquire(addr unsafe.Pointer) {
|
||||
}
|
||||
|
||||
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build race
|
||||
|
||||
package atomic
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const raceenabled = true
|
||||
|
||||
func raceAcquire(addr unsafe.Pointer) {
|
||||
runtime.RaceAcquire(addr)
|
||||
}
|
||||
|
||||
func raceReleaseMerge(addr unsafe.Pointer) {
|
||||
runtime.RaceReleaseMerge(addr)
|
||||
}
|
@ -35,9 +35,6 @@ func (v *Value) Load() (x interface{}) {
|
||||
xp := (*ifaceWords)(unsafe.Pointer(&x))
|
||||
xp.typ = typ
|
||||
xp.data = data
|
||||
if raceenabled {
|
||||
raceAcquire(unsafe.Pointer(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -48,9 +45,6 @@ func (v *Value) Store(x interface{}) {
|
||||
if x == nil {
|
||||
panic("sync/atomic: store of nil value into Value")
|
||||
}
|
||||
if raceenabled {
|
||||
raceReleaseMerge(unsafe.Pointer(v))
|
||||
}
|
||||
vp := (*ifaceWords)(unsafe.Pointer(v))
|
||||
xp := (*ifaceWords)(unsafe.Pointer(&x))
|
||||
for {
|
||||
|
Loading…
Reference in New Issue
Block a user