...

Source file src/runtime/tagptr_32bit.go

Documentation: runtime

     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  // On 32-bit systems, taggedPointer has a 32-bit pointer and 32-bit count.
    15  
    16  // taggedPointerPack created a taggedPointer from a pointer and a tag.
    17  // Tag bits that don't fit in the result are discarded.
    18  func taggedPointerPack(ptr unsafe.Pointer, tag uintptr) taggedPointer {
    19  	return taggedPointer(uintptr(ptr))<<32 | taggedPointer(tag)
    20  }
    21  
    22  // Pointer returns the pointer from a taggedPointer.
    23  func (tp taggedPointer) pointer() unsafe.Pointer {
    24  	return unsafe.Pointer(uintptr(tp >> 32))
    25  }
    26  
    27  // Tag returns the tag from a taggedPointer.
    28  func (tp taggedPointer) tag() uintptr {
    29  	return uintptr(tp)
    30  }
    31  

View as plain text