diff options
Diffstat (limited to 'src/runtime/lfstack.go')
| -rw-r--r-- | src/runtime/lfstack.go | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/runtime/lfstack.go b/src/runtime/lfstack.go index c5dc94f073..4a20fff9d8 100644 --- a/src/runtime/lfstack.go +++ b/src/runtime/lfstack.go @@ -9,23 +9,12 @@ package runtime import "unsafe" -const ( - // lfPtrBits and lfCountMask are defined in lfstack_*.go. - lfPtrMask = 1<<lfPtrBits - 1 -) - func lfstackpush(head *uint64, node *lfnode) { - unode := uintptr(unsafe.Pointer(node)) - if unode&^lfPtrMask != 0 { - print("p=", node, "\n") - gothrow("lfstackpush: invalid pointer") - } - node.pushcnt++ - new := uint64(unode) | (uint64(node.pushcnt)&lfCountMask)<<lfPtrBits + new := lfstackPack(node, node.pushcnt) for { old := atomicload64(head) - node.next = (*lfnode)(unsafe.Pointer(uintptr(old & lfPtrMask))) + node.next, _ = lfstackUnpack(old) if cas64(head, old, new) { break } @@ -38,11 +27,11 @@ func lfstackpop(head *uint64) unsafe.Pointer { if old == 0 { return nil } - node := (*lfnode)(unsafe.Pointer(uintptr(old & lfPtrMask))) + node, _ := lfstackUnpack(old) node2 := (*lfnode)(atomicloadp(unsafe.Pointer(&node.next))) new := uint64(0) if node2 != nil { - new = uint64(uintptr(unsafe.Pointer(node2))) | uint64(node2.pushcnt&lfCountMask)<<lfPtrBits + new = lfstackPack(node2, node2.pushcnt) } if cas64(head, old, new) { return unsafe.Pointer(node) |
