From: Ian Lance Taylor Date: Sun, 27 Jan 2013 02:16:43 +0000 (-0800) Subject: runtime: use new CNT_MASK in lfstack X-Git-Tag: go1.1rc2~1285 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e65c0a82ce6c8c8fe06622f95bf713d1a962eee0;p=gostls13.git runtime: use new CNT_MASK in lfstack This is for SPARC64, a 64-bit processor that uses all 64-bits of virtual addresses. The idea is to use the low order 3 bits to at least get a small ABA counter. That should work since pointers are aligned. The idea is for SPARC64 to set CNT_MASK == 7, PTR_BITS == 0, PTR_MASK == 0xffffffffffffff8. Also add uintptr casts to avoid GCC warnings. The gccgo runtime code is compiled with GCC, and GCC warns when casting between a pointer and a type of a different size. R=dvyukov CC=golang-dev https://golang.org/cl/7225043 --- diff --git a/src/pkg/runtime/lfstack.c b/src/pkg/runtime/lfstack.c index e4ea6e83da..1d48491aac 100644 --- a/src/pkg/runtime/lfstack.c +++ b/src/pkg/runtime/lfstack.c @@ -15,22 +15,23 @@ # define PTR_BITS 32 #endif #define PTR_MASK ((1ull<pushcnt++; - new = (uint64)node|(((uint64)node->pushcnt)<pushcnt&CNT_MASK)<next = (LFNode*)(old&PTR_MASK); + node->next = (LFNode*)(uintptr)(old&PTR_MASK); if(runtime·cas64(head, &old, new)) break; } @@ -46,11 +47,11 @@ runtime·lfstackpop(uint64 *head) for(;;) { if(old == 0) return nil; - node = (LFNode*)(old&PTR_MASK); + node = (LFNode*)(uintptr)(old&PTR_MASK); node2 = runtime·atomicloadp(&node->next); new = 0; if(node2 != nil) - new = (uint64)node2|(((uint64)node2->pushcnt)<pushcnt&CNT_MASK)<