aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/lfstack_32bit.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-11-14 12:55:23 -0500
committerRuss Cox <rsc@golang.org>2014-11-14 12:55:23 -0500
commit5fce15a2a3cd94427bb9979d73acf14013ec7f31 (patch)
treea49b9ffa5eac49d991e820b27da919aadd9e010b /src/runtime/lfstack_32bit.go
parenta87e4a2d01097c7f2430df0427aaae9c0b6f2031 (diff)
downloadgo-5fce15a2a3cd94427bb9979d73acf14013ec7f31.tar.xz
[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
Diffstat (limited to 'src/runtime/lfstack_32bit.go')
-rw-r--r--src/runtime/lfstack_32bit.go16
1 files changed, 12 insertions, 4 deletions
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
+}