summaryrefslogtreecommitdiff
path: root/src/runtime/lfstack.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-29 11:54:48 -0400
committerRuss Cox <rsc@golang.org>2014-10-29 11:54:48 -0400
commit40520a21d8b050635a417666db959f75d757fff5 (patch)
tree212a0b7c0bdeab8ee517584b3ddf33222878258d /src/runtime/lfstack.c
parent7d8c40f1a65329094210933bca66b8862b0c28b8 (diff)
parent9232cbb6a6aaa8a4197b22819406128ff0f99265 (diff)
downloadgo-40520a21d8b050635a417666db959f75d757fff5.tar.gz
[dev.garbage] all: merge default (dd5014ed9b01) into dev.garbage
LGTM=rlh R=rlh CC=golang-codereviews https://codereview.appspot.com/170730043
Diffstat (limited to 'src/runtime/lfstack.c')
-rw-r--r--src/runtime/lfstack.c14
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;
}
}