diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-01-25 23:43:23 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-01-25 23:43:23 +0000 |
commit | 263d438231a3b46389373b0ea53d4a782106add7 (patch) | |
tree | aa68d861ae8100544810f30bcb815d0e76511eb2 /libgo/runtime/lfstack.c | |
parent | c4e0613eb427e516f1b6c1b919e68be64a9015fd (diff) | |
download | gcc-263d438231a3b46389373b0ea53d4a782106add7.tar.gz |
PR other/56076
runtime: Support sparc64 in lfstack.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195479 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/runtime/lfstack.c')
-rw-r--r-- | libgo/runtime/lfstack.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libgo/runtime/lfstack.c b/libgo/runtime/lfstack.c index 0f8ea6ea6bc..783595abe7a 100644 --- a/libgo/runtime/lfstack.c +++ b/libgo/runtime/lfstack.c @@ -15,6 +15,15 @@ # define PTR_BITS 32 #endif #define PTR_MASK ((1ull<<PTR_BITS)-1) +#define CNT_MASK (0ull-1) + +#if __SIZEOF_POINTER__ == 8 && defined(__sparc__) +// SPARC64 uses all 64 bits of virtual addresses. Use low-order three +bits as ABA counter. +#define PTR_BITS 0 +#define CNT_MASK 7 +#define PTR_MASK ((0ull-1)<<3) +#endif void runtime_lfstackpush(uint64 *head, LFNode *node) @@ -27,7 +36,7 @@ runtime_lfstackpush(uint64 *head, LFNode *node) } node->pushcnt++; - new = (uint64)(uintptr)node|(((uint64)node->pushcnt)<<PTR_BITS); + new = (uint64)(uintptr)node|(((uint64)node->pushcnt&CNT_MASK)<<PTR_BITS); old = runtime_atomicload64(head); for(;;) { node->next = (LFNode*)(uintptr)(old&PTR_MASK); @@ -50,7 +59,7 @@ runtime_lfstackpop(uint64 *head) node2 = runtime_atomicloadp(&node->next); new = 0; if(node2 != nil) - new = (uint64)(uintptr)node2|(((uint64)node2->pushcnt)<<PTR_BITS); + new = (uint64)(uintptr)node2|(((uint64)node2->pushcnt&CNT_MASK)<<PTR_BITS); if(runtime_cas64(head, &old, new)) return node; } |