Source file src/runtime/tagptr_32bit.go

     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  //go:build 386 || arm || mips || mipsle
     6  
     7  package runtime
     8  
     9  import "unsafe"
    10  
    11  // The number of bits stored in the numeric tag of a taggedPointer
    12  const taggedPointerBits = 32
    13  
    14  // The number of bits allowed in a tag.
    15  const tagBits = 32
    16  
    17  // On 32-bit systems, taggedPointer has a 32-bit pointer and 32-bit count.
    18  
    19  // taggedPointerPack created a taggedPointer from a pointer and a tag.
    20  // Tag bits that don't fit in the result are discarded.
    21  func taggedPointerPack(ptr unsafe.Pointer, tag uintptr) taggedPointer {
    22  	return taggedPointer(uintptr(ptr))<<32 | taggedPointer(tag)
    23  }
    24  
    25  // Pointer returns the pointer from a taggedPointer.
    26  func (tp taggedPointer) pointer() unsafe.Pointer {
    27  	return unsafe.Pointer(uintptr(tp >> 32))
    28  }
    29  
    30  // Tag returns the tag from a taggedPointer.
    31  func (tp taggedPointer) tag() uintptr {
    32  	return uintptr(tp)
    33  }
    34  

View as plain text