1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build ppc64 ppc64le 6 // +build linux 7 8 package runtime 9 10 import "unsafe" 11 12 // On ppc64, Linux limits the user address space to 46 bits (see 13 // TASK_SIZE_USER64 in the Linux kernel). This has grown over time, 14 // so here we allow 48 bit addresses. 15 // 16 // In addition to the 16 bits taken from the top, we can take 3 from the 17 // bottom, because node must be pointer-aligned, giving a total of 19 bits 18 // of count. 19 const ( 20 addrBits = 48 21 cntBits = 64 - addrBits + 3 22 ) 23 24 func lfstackPack(node *lfnode, cnt uintptr) uint64 { 25 return uint64(uintptr(unsafe.Pointer(node)))<<(64-addrBits) | uint64(cnt&(1<<cntBits-1)) 26 } 27 28 func lfstackUnpack(val uint64) (node *lfnode, cnt uintptr) { 29 node = (*lfnode)(unsafe.Pointer(uintptr(val >> cntBits << 3))) 30 cnt = uintptr(val & (1<<cntBits - 1)) 31 return 32 } 33