github.com/miolini/go@v0.0.0-20160405192216-fca68c8cb408/src/runtime/lfstack_linux_mips64x.go (about)

     1  // Copyright 2015 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 mips64 mips64le
     6  // +build linux
     7  
     8  package runtime
     9  
    10  import "unsafe"
    11  
    12  // On mips64, Linux limits the user address space to 40 bits (see
    13  // TASK_SIZE64 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  }