diff options
author | Michael Matloob <matloob@golang.org> | 2015-11-02 14:09:24 -0500 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2015-11-10 17:38:04 +0000 |
commit | 67faca7d9c54b367aee5fdeef2d5dd609fcf99d0 (patch) | |
tree | 5c6e8b4e243286311bbc4743d6a8e86f16dda85f /src/runtime/chan.go | |
parent | d33360571f46b46724b908a5603520dce1e8a81c (diff) | |
download | go-67faca7d9c54b367aee5fdeef2d5dd609fcf99d0.tar.gz go-67faca7d9c54b367aee5fdeef2d5dd609fcf99d0.zip |
runtime: break atomics out into package runtime/internal/atomic
This change breaks out most of the atomics functions in the runtime
into package runtime/internal/atomic. It adds some basic support
in the toolchain for runtime packages, and also modifies linux/arm
atomics to remove the dependency on the runtime's mutex. The mutexes
have been replaced with spinlocks.
all trybots are happy!
In addition to the trybots, I've tested on the darwin/arm64 builder,
on the darwin/arm builder, and on a ppc64le machine.
Change-Id: I6698c8e3cf3834f55ce5824059f44d00dc8e3c2f
Reviewed-on: https://go-review.googlesource.com/14204
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/chan.go')
-rw-r--r-- | src/runtime/chan.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/runtime/chan.go b/src/runtime/chan.go index 839e235a9e..5be18beb23 100644 --- a/src/runtime/chan.go +++ b/src/runtime/chan.go @@ -11,7 +11,10 @@ package runtime // For buffered channels, also: // c.qcount > 0 implies that c.recvq is empty. // c.qcount < c.dataqsiz implies that c.sendq is empty. -import "unsafe" +import ( + "runtime/internal/atomic" + "unsafe" +) const ( maxAlign = 8 @@ -393,8 +396,8 @@ func chanrecv(t *chantype, c *hchan, ep unsafe.Pointer, block bool) (selected, r // The order of operations is important here: reversing the operations can lead to // incorrect behavior when racing with a close. if !block && (c.dataqsiz == 0 && c.sendq.first == nil || - c.dataqsiz > 0 && atomicloaduint(&c.qcount) == 0) && - atomicload(&c.closed) == 0 { + c.dataqsiz > 0 && atomic.Loaduint(&c.qcount) == 0) && + atomic.Load(&c.closed) == 0 { return } @@ -669,7 +672,7 @@ func (q *waitq) dequeue() *sudog { // if sgp participates in a select and is already signaled, ignore it if sgp.selectdone != nil { // claim the right to signal - if *sgp.selectdone != 0 || !cas(sgp.selectdone, 0, 1) { + if *sgp.selectdone != 0 || !atomic.Cas(sgp.selectdone, 0, 1) { continue } } |