From 5fce15a2a3cd94427bb9979d73acf14013ec7f31 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 14 Nov 2014 12:55:23 -0500 Subject: [dev.cc] runtime: fix lfstack for amd64 addresses in top half of addr space While we are here, add the linux/power64 version. LGTM=austin R=austin CC=aram, dvyukov, golang-codereviews https://golang.org/cl/177750043 --- src/runtime/lfstack_32bit.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/runtime/lfstack_32bit.go') diff --git a/src/runtime/lfstack_32bit.go b/src/runtime/lfstack_32bit.go index 0eebbd9740..61d8678d9c 100644 --- a/src/runtime/lfstack_32bit.go +++ b/src/runtime/lfstack_32bit.go @@ -6,8 +6,16 @@ package runtime +import "unsafe" + // On 32-bit systems, the stored uint64 has a 32-bit pointer and 32-bit count. -const ( - lfPtrBits = 32 - lfCountMask = 1<<32 - 1 -) + +func lfstackPack(node *lfnode, cnt uintptr) uint64 { + return uint64(uintptr(unsafe.Pointer(node)))<<32 | uint64(cnt) +} + +func lfstackUnpack(val uint64) (node *lfnode, cnt uintptr) { + node = (*lfnode)(unsafe.Pointer(uintptr(val >> 32))) + cnt = uintptr(val) + return +} -- cgit v1.3