diff options
author | Russ Cox <rsc@golang.org> | 2014-11-14 11:37:54 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-11-14 11:37:54 -0500 |
commit | f4110c2e9cc8f316e14f3a4a35789bc821b326bf (patch) | |
tree | 3a2b461d76cc134f7b71e5e1ef63bc37e7d25059 /src/runtime/lfstack.c | |
parent | 78d351d121615f1101f28f88920029f20884c689 (diff) | |
parent | 4664f7441b495d8fa8aa5001755cb5f85e790b19 (diff) | |
download | go-f4110c2e9cc8f316e14f3a4a35789bc821b326bf.tar.gz |
[dev.garbage] all: merge default (f38460037b72) into dev.garbage
This is the revision that dev.cc is branched from.
LGTM=austin
R=austin
CC=golang-codereviews
https://codereview.appspot.com/169590043
Diffstat (limited to 'src/runtime/lfstack.c')
-rw-r--r-- | src/runtime/lfstack.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/runtime/lfstack.c b/src/runtime/lfstack.c index 57e0af282..0ced839c2 100644 --- a/src/runtime/lfstack.c +++ b/src/runtime/lfstack.c @@ -46,7 +46,7 @@ runtime·lfstackpush(uint64 *head, LFNode *node) new = (uint64)(uintptr)node|(((uint64)node->pushcnt&CNT_MASK)<<PTR_BITS); for(;;) { old = runtime·atomicload64(head); - node->next = (LFNode*)(uintptr)(old&PTR_MASK); + node->next = old; if(runtime·cas64(head, old, new)) break; } @@ -55,19 +55,17 @@ runtime·lfstackpush(uint64 *head, LFNode *node) LFNode* runtime·lfstackpop(uint64 *head) { - LFNode *node, *node2; - uint64 old, new; + LFNode *node; + uint64 old, next; for(;;) { old = runtime·atomicload64(head); if(old == 0) return nil; node = (LFNode*)(uintptr)(old&PTR_MASK); - node2 = runtime·atomicloadp(&node->next); - new = 0; - if(node2 != nil) - new = (uint64)(uintptr)node2|(((uint64)node2->pushcnt&CNT_MASK)<<PTR_BITS); - if(runtime·cas64(head, old, new)) + next = runtime·atomicload64(&node->next); + + if(runtime·cas64(head, old, next)) return node; } } |