stdptr

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MinTagBits = 10

MinTagBits is the minimum number of tag bits that we expect.

View Source
const TaggedPointerBits = (os.IsAix * aixTagBits) + (arch.IsRiscv64 * riscv64TagBits) + ((1 - os.IsAix) * (1 - arch.IsRiscv64) * tagBits)

The number of bits stored in the numeric tag of a TaggedPointer

Variables

This section is empty.

Functions

func Add

func Add[T any, O num.Integer](p *T, off O) *T

Add adds offset off to p.

func Assign

func Assign[T any, Ptr num.Pointer](base Ptr, offset uintptr, v T)

Assign value of type T to the address: *(base+offset) = v

func Cast

func Cast[T any, Ptr num.Pointer](p Ptr) *T

Cast casts numeric pointer value to *R

func CheckAlignment

func CheckAlignment(p unsafe.Pointer, elem *abi.Type, n uintptr)

func CheckArithmetic

func CheckArithmetic(p unsafe.Pointer, originals []unsafe.Pointer)

func CheckptrBase

func CheckptrBase(p unsafe.Pointer) uintptr

CheckptrBase returns the base address for the allocation containing the address p.

Importantly, if p1 and p2 point into the same variable, then CheckptrBase(p1) == CheckptrBase(p2). However, the converse/inverse is not necessarily true as allocations can have trailing padding, and multiple variables may be packed into a single allocation.

func CheckptrStraddles

func CheckptrStraddles(ptr unsafe.Pointer, size uintptr) bool

CheckptrStraddles reports whether the first size-bytes of memory addressed by ptr is known to straddle more than one Go allocation.

func OnStack added in v0.2.0

func OnStack(ptr uintptr) bool

OnStack reports whether the pointer points to somewhere of current goroutine's stack.

Types

type TaggedPointer

type TaggedPointer uint64

TaggedPointer is a pointer with a numeric tag. The size of the numeric tag is GOARCH-dependent, currently at least 10 bits. This should only be used with pointers allocated outside the Go heap.

func TaggedPointerPack

func TaggedPointerPack(ptr unsafe.Pointer, tag uintptr) TaggedPointer

TaggedPointerPack created a TaggedPointer from a pointer and a tag. Tag bits that don't fit in the result are discarded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL