From fb63e4fefbb1325a21f643febc97987c82fcae7a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 12 Jul 2013 00:03:32 -0400 Subject: runtime: make cas64 like cas32 and casp The current cas64 definition hard-codes the x86 behavior of updating *old with the new value when the cas fails. This is inconsistent with cas32 and casp. Make it consistent. This means that the cas64 uses will be epsilon less efficient than they might be, because they have to do an unnecessary memory load on x86. But so be it. Code clarity and consistency is more important. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/10909045 --- src/pkg/runtime/lfstack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/pkg/runtime/lfstack.c') diff --git a/src/pkg/runtime/lfstack.c b/src/pkg/runtime/lfstack.c index 1d48491aac..140384d3dc 100644 --- a/src/pkg/runtime/lfstack.c +++ b/src/pkg/runtime/lfstack.c @@ -29,10 +29,10 @@ runtime·lfstackpush(uint64 *head, LFNode *node) node->pushcnt++; new = (uint64)(uintptr)node|(((uint64)node->pushcnt&CNT_MASK)<next = (LFNode*)(uintptr)(old&PTR_MASK); - if(runtime·cas64(head, &old, new)) + if(runtime·cas64(head, old, new)) break; } } @@ -43,8 +43,8 @@ runtime·lfstackpop(uint64 *head) LFNode *node, *node2; uint64 old, new; - old = runtime·atomicload64(head); for(;;) { + old = runtime·atomicload64(head); if(old == 0) return nil; node = (LFNode*)(uintptr)(old&PTR_MASK); @@ -52,7 +52,7 @@ runtime·lfstackpop(uint64 *head) new = 0; if(node2 != nil) new = (uint64)(uintptr)node2|(((uint64)node2->pushcnt&CNT_MASK)<