From: Dmitriy Vyukov Date: Thu, 18 Sep 2014 04:22:11 +0000 (-0700) Subject: sync/atomic: remove unnecessary race instrumentation in Value X-Git-Tag: go1.4beta1~366 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8c2484ec11d27324423e3cf27cc9ac6b34394c7d;p=gostls13.git 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 --- diff --git a/src/sync/atomic/norace.go b/src/sync/atomic/norace.go deleted file mode 100644 index 1866fd16cb..0000000000 --- a/src/sync/atomic/norace.go +++ /dev/null @@ -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) { -} diff --git a/src/sync/atomic/race.go b/src/sync/atomic/race.go deleted file mode 100644 index a833d9e7f4..0000000000 --- a/src/sync/atomic/race.go +++ /dev/null @@ -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) -} diff --git a/src/sync/atomic/value.go b/src/sync/atomic/value.go index c290fdab85..ab46d9a240 100644 --- a/src/sync/atomic/value.go +++ b/src/sync/atomic/value.go @@ -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 {