memory

package
v0.0.0-...-6f9c769 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const PtrSize = 4 << (^uintptr(0) >> 63)

PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant. It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).

Variables

This section is empty.

Functions

func Cmp

func Cmp(a, b string) int

func Compare

func Compare(a, b unsafe.Pointer, n uintptr) int

func Copy

func Copy(dst, src unsafe.Pointer, n uintptr)

func Equals

func Equals(a, b unsafe.Pointer, size uintptr) bool

func Fastrand

func Fastrand() uint32

func FloorToPowerOfTwo

func FloorToPowerOfTwo(n int) int

FloorToPowerOfTwo returns the greatest power of two integer value less than or equal to n.

func Free

func Free(p Pointer)

Free calls Free on the system allocator

func GCAlloc

func GCAlloc(size uintptr) unsafe.Pointer

func GCAllocZeroed

func GCAllocZeroed(size uintptr) unsafe.Pointer

func Init

func Init()

func Int16LE

func Int16LE(p unsafe.Pointer) int16

func IsPowerOfTwo

func IsPowerOfTwo(n int) bool

IsPowerOfTwo reports whether given integer is a power of two.

func LogarithmicRange

func LogarithmicRange(min, max int, cb func(int))

LogarithmicRange iterates from ceiled to power of two min to max, calling cb on each iteration.

func Move

func Move(to, from unsafe.Pointer, n uintptr)

Move copies n bytes from "from" to "to".

Move ensures that any pointer in "from" is written to "to" with an indivisible write, so that racy reads cannot observe a half-written pointer. This is necessary to prevent the garbage collector from observing invalid pointers, and differs from Memmove in unmanaged languages. However, Memmove is only required to do this if "from" and "to" may contain pointers, which can only be the case if "from", "to", and "n" are all be word-aligned.

Implementations are in memmove_*.s.

func Sizeof

func Sizeof(ptr Pointer) uintptr

func Uint16LE

func Uint16LE(p unsafe.Pointer) uint16

func Zero

func Zero(ptr unsafe.Pointer, n uintptr)

Zero clears n bytes starting at ptr.

Usually you should use typedmemclr. memclrNoHeapPointers should be used only when the caller knows that *ptr contains no heap pointers because either:

*ptr is initialized memory and its type is pointer-free, or

*ptr is uninitialized memory (e.g., memory that's being reused for a new allocation) and hence contains only "junk".

memclrNoHeapPointers ensures that if ptr is pointer-aligned, and n is a multiple of the pointer size, then any pointer-aligned, pointer-sized portion is cleared atomically. Despite the function name, this is necessary because this function is the underlying implementation of typedmemclr and memclrHasPointers. See the doc of Memmove for more details.

The (CPU-specific) implementations of this function are in memclr_*.s.

Types

type Pointer

type Pointer uintptr

Pointer is a wrapper around a raw pointer that is not unsafe.Pointer so Go won't confuse it for a potential GC managed pointer.

func Alloc

func Alloc(size uintptr) Pointer

Alloc calls Alloc on the system allocator

func AllocCap

func AllocCap(size uintptr) (Pointer, uintptr)

func AllocZeroed

func AllocZeroed(size uintptr) Pointer

func AllocZeroedCap

func AllocZeroedCap(size uintptr) (Pointer, uintptr)

func Calloc

func Calloc(num, size uintptr) Pointer

Alloc calls Alloc on the system allocator

func CallocCap

func CallocCap(num, size uintptr) (Pointer, uintptr)

func PointerOfString

func PointerOfString(s string) Pointer

func Realloc

func Realloc(p Pointer, size uintptr) Pointer

Realloc calls Realloc on the system allocator

func ReallocCap

func ReallocCap(p Pointer, size uintptr) (Pointer, uintptr)

func (Pointer) Add

func (p Pointer) Add(offset int) Pointer

Add is Pointer arithmetic.

func (Pointer) AsFloat32BE

func (p Pointer) AsFloat32BE() float32

func (Pointer) AsFloat32LE

func (p Pointer) AsFloat32LE() float32

func (Pointer) AsFloat64BE

func (p Pointer) AsFloat64BE() float64

func (Pointer) AsFloat64LE

func (p Pointer) AsFloat64LE() float64

func (Pointer) AsInt16BE

func (p Pointer) AsInt16BE() int16

func (Pointer) AsInt16LE

func (p Pointer) AsInt16LE() int16

func (Pointer) AsInt32BE

func (p Pointer) AsInt32BE() int32

func (Pointer) AsInt32LE

func (p Pointer) AsInt32LE() int32

func (Pointer) AsInt64BE

func (p Pointer) AsInt64BE() int64

func (Pointer) AsInt64LE

func (p Pointer) AsInt64LE() int64

func (Pointer) AsUint16BE

func (p Pointer) AsUint16BE() uint16

func (Pointer) AsUint16LE

func (p Pointer) AsUint16LE() uint16

func (Pointer) AsUint32BE

func (p Pointer) AsUint32BE() uint32

func (Pointer) AsUint32LE

func (p Pointer) AsUint32LE() uint32

func (Pointer) AsUint64BE

func (p Pointer) AsUint64BE() uint64

func (Pointer) AsUint64LE

func (p Pointer) AsUint64LE() uint64

func (Pointer) Byte

func (p Pointer) Byte(offset int) byte

func (Pointer) Bytes

func (p Pointer) Bytes(offset, length, capacity int) []byte

func (Pointer) Clone

func (p Pointer) Clone(offset, size int) Pointer

Clone the memory starting at offset for size number of bytes and return the new Pointer.

func (Pointer) Compare

func (p Pointer) Compare(offset, size int, to Pointer) int

func (Pointer) Copy

func (p Pointer) Copy(offset, size int, to Pointer)

func (Pointer) Equals

func (p Pointer) Equals(offset, size int, to Pointer) bool

func (Pointer) Float32

func (p Pointer) Float32(offset int) float32

func (Pointer) Float32BE

func (p Pointer) Float32BE(offset int) float32

func (Pointer) Float32LE

func (p Pointer) Float32LE(offset int) float32

func (Pointer) Float64

func (p Pointer) Float64(offset int) float64

func (Pointer) Float64BE

func (p Pointer) Float64BE(offset int) float64

func (Pointer) Float64LE

func (p Pointer) Float64LE(offset int) float64

func (*Pointer) Free

func (p *Pointer) Free()

Free deallocates memory pointed by Pointer

func (Pointer) Hash64

func (p Pointer) Hash64(length int) uint64

func (Pointer) Hash64At

func (p Pointer) Hash64At(offset, length int) uint64

func (Pointer) Int

func (p Pointer) Int(offset int) int

func (Pointer) Int16

func (p Pointer) Int16(offset int) int16

func (Pointer) Int16BE

func (p Pointer) Int16BE(offset int) int16

func (Pointer) Int16LE

func (p Pointer) Int16LE(offset int) int16

func (Pointer) Int24

func (p Pointer) Int24(offset int) int32

func (Pointer) Int24BE

func (p Pointer) Int24BE(offset int) int32

func (Pointer) Int24LE

func (p Pointer) Int24LE(offset int) int32

func (Pointer) Int32

func (p Pointer) Int32(offset int) int32

func (Pointer) Int32Alt

func (p Pointer) Int32Alt(offset uintptr) int32

func (Pointer) Int32BE

func (p Pointer) Int32BE(offset int) int32

func (Pointer) Int32LE

func (p Pointer) Int32LE(offset int) int32

func (Pointer) Int40

func (p Pointer) Int40(offset int) int64

func (Pointer) Int40BE

func (p Pointer) Int40BE(offset int) int64

func (Pointer) Int40LE

func (p Pointer) Int40LE(offset int) int64

func (Pointer) Int48

func (p Pointer) Int48(offset int) int64

func (Pointer) Int48BE

func (p Pointer) Int48BE(offset int) int64

func (Pointer) Int48LE

func (p Pointer) Int48LE(offset int) int64

func (Pointer) Int56

func (p Pointer) Int56(offset int) int64

func (Pointer) Int56BE

func (p Pointer) Int56BE(offset int) int64

func (Pointer) Int56LE

func (p Pointer) Int56LE(offset int) int64

func (Pointer) Int64

func (p Pointer) Int64(offset int) int64

func (Pointer) Int64BE

func (p Pointer) Int64BE(offset int) int64

func (Pointer) Int64LE

func (p Pointer) Int64LE(offset int) int64

func (Pointer) Int8

func (p Pointer) Int8(offset int) int8

func (Pointer) Move

func (p Pointer) Move(offset, size int, to Pointer)

func (Pointer) Pointer

func (p Pointer) Pointer(offset int) Pointer

func (Pointer) SetByte

func (p Pointer) SetByte(offset int, v byte)

func (Pointer) SetBytes

func (p Pointer) SetBytes(offset int, value []byte)

func (Pointer) SetFloat32

func (p Pointer) SetFloat32(offset int, v float32)

func (Pointer) SetFloat32BE

func (p Pointer) SetFloat32BE(offset int, v float32)

func (Pointer) SetFloat32LE

func (p Pointer) SetFloat32LE(offset int, v float32)

func (Pointer) SetFloat64

func (p Pointer) SetFloat64(offset int, v float64)

func (Pointer) SetFloat64BE

func (p Pointer) SetFloat64BE(offset int, v float64)

func (Pointer) SetFloat64LE

func (p Pointer) SetFloat64LE(offset int, v float64)

func (Pointer) SetInt

func (p Pointer) SetInt(offset int, v int)

func (Pointer) SetInt16

func (p Pointer) SetInt16(offset int, v int16)

func (Pointer) SetInt16BE

func (p Pointer) SetInt16BE(offset int, v int16)

func (Pointer) SetInt16LE

func (p Pointer) SetInt16LE(offset int, v int16)

func (Pointer) SetInt24

func (p Pointer) SetInt24(offset int, v int32)

func (Pointer) SetInt24BE

func (p Pointer) SetInt24BE(offset int, v int32)

func (Pointer) SetInt24LE

func (p Pointer) SetInt24LE(offset int, v int32)

func (Pointer) SetInt32

func (p Pointer) SetInt32(offset int, v int32)

func (Pointer) SetInt32BE

func (p Pointer) SetInt32BE(offset int, v int32)

func (Pointer) SetInt32LE

func (p Pointer) SetInt32LE(offset int, v int32)

func (Pointer) SetInt40

func (p Pointer) SetInt40(offset int, v int64)

func (Pointer) SetInt40BE

func (p Pointer) SetInt40BE(offset int, v int64)

func (Pointer) SetInt40LE

func (p Pointer) SetInt40LE(offset int, v int64)

func (Pointer) SetInt48

func (p Pointer) SetInt48(offset int, v int64)

func (Pointer) SetInt48BE

func (p Pointer) SetInt48BE(offset int, v int64)

func (Pointer) SetInt48LE

func (p Pointer) SetInt48LE(offset int, v int64)

func (Pointer) SetInt56

func (p Pointer) SetInt56(offset int, v int64)

func (Pointer) SetInt56BE

func (p Pointer) SetInt56BE(offset int, v int64)

func (Pointer) SetInt56LE

func (p Pointer) SetInt56LE(offset int, v int64)

func (Pointer) SetInt64

func (p Pointer) SetInt64(offset int, v int64)

func (Pointer) SetInt64BE

func (p Pointer) SetInt64BE(offset int, v int64)

func (Pointer) SetInt64LE

func (p Pointer) SetInt64LE(offset int, v int64)

func (Pointer) SetInt8

func (p Pointer) SetInt8(offset int, v int8)

func (Pointer) SetPointer

func (p Pointer) SetPointer(offset int, v Pointer)

func (Pointer) SetString

func (p Pointer) SetString(offset int, value string)

func (Pointer) SetUint

func (p Pointer) SetUint(offset int, v uint)

func (Pointer) SetUint16

func (p Pointer) SetUint16(offset int, v uint16)

func (Pointer) SetUint16BE

func (p Pointer) SetUint16BE(offset int, v uint16)

func (Pointer) SetUint16LE

func (p Pointer) SetUint16LE(offset int, v uint16)

func (Pointer) SetUint24

func (p Pointer) SetUint24(offset int, v uint32)

func (Pointer) SetUint24BE

func (p Pointer) SetUint24BE(offset int, v uint32)

func (Pointer) SetUint24LE

func (p Pointer) SetUint24LE(offset int, v uint32)

func (Pointer) SetUint32

func (p Pointer) SetUint32(offset int, v uint32)

func (Pointer) SetUint32BE

func (p Pointer) SetUint32BE(offset int, v uint32)

func (Pointer) SetUint32LE

func (p Pointer) SetUint32LE(offset int, v uint32)

func (Pointer) SetUint40

func (p Pointer) SetUint40(offset int, v uint64)

func (Pointer) SetUint40BE

func (p Pointer) SetUint40BE(offset int, v uint64)

func (Pointer) SetUint40LE

func (p Pointer) SetUint40LE(offset int, v uint64)

func (Pointer) SetUint48

func (p Pointer) SetUint48(offset int, v uint64)

func (Pointer) SetUint48BE

func (p Pointer) SetUint48BE(offset int, v uint64)

func (Pointer) SetUint48LE

func (p Pointer) SetUint48LE(offset int, v uint64)

func (Pointer) SetUint56

func (p Pointer) SetUint56(offset int, v uint64)

func (Pointer) SetUint56BE

func (p Pointer) SetUint56BE(offset int, v uint64)

func (Pointer) SetUint56LE

func (p Pointer) SetUint56LE(offset int, v uint64)

func (Pointer) SetUint64

func (p Pointer) SetUint64(offset int, v uint64)

func (Pointer) SetUint64BE

func (p Pointer) SetUint64BE(offset int, v uint64)

func (Pointer) SetUint64LE

func (p Pointer) SetUint64LE(offset int, v uint64)

func (Pointer) SetUint8

func (p Pointer) SetUint8(offset int, v uint8)

func (Pointer) SetUintptr

func (p Pointer) SetUintptr(offset int, v uintptr)

func (Pointer) SizeOf

func (p Pointer) SizeOf() uintptr

Sizeof returns the size of the allocation provided by the platform allocator.

func (Pointer) String

func (p Pointer) String(offset, size int) string

func (Pointer) Uint

func (p Pointer) Uint(offset int) uint

func (Pointer) Uint16

func (p Pointer) Uint16(offset int) uint16

func (Pointer) Uint16BE

func (p Pointer) Uint16BE(offset int) uint16

func (Pointer) Uint16LE

func (p Pointer) Uint16LE(offset int) uint16

func (Pointer) Uint24

func (p Pointer) Uint24(offset int) uint32

func (Pointer) Uint24BE

func (p Pointer) Uint24BE(offset int) uint32

func (Pointer) Uint24LE

func (p Pointer) Uint24LE(offset int) uint32

func (Pointer) Uint32

func (p Pointer) Uint32(offset int) uint32

func (Pointer) Uint32BE

func (p Pointer) Uint32BE(offset int) uint32

func (Pointer) Uint32BESlow

func (p Pointer) Uint32BESlow() uint32

func (Pointer) Uint32LE

func (p Pointer) Uint32LE(offset int) uint32

func (Pointer) Uint40

func (p Pointer) Uint40(offset int) uint64

func (Pointer) Uint40BE

func (p Pointer) Uint40BE(offset int) uint64

func (Pointer) Uint40LE

func (p Pointer) Uint40LE(offset int) uint64

func (Pointer) Uint48

func (p Pointer) Uint48(offset int) uint64

func (Pointer) Uint48BE

func (p Pointer) Uint48BE(offset int) uint64

func (Pointer) Uint48LE

func (p Pointer) Uint48LE(offset int) uint64

func (Pointer) Uint56

func (p Pointer) Uint56(offset int) uint64

func (Pointer) Uint56BE

func (p Pointer) Uint56BE(offset int) uint64

func (Pointer) Uint56LE

func (p Pointer) Uint56LE(offset int) uint64

func (Pointer) Uint64

func (p Pointer) Uint64(offset int) uint64

func (Pointer) Uint64BE

func (p Pointer) Uint64BE(offset int) uint64

func (Pointer) Uint64LE

func (p Pointer) Uint64LE(offset int) uint64

func (Pointer) Uint8

func (p Pointer) Uint8(offset int) uint8

func (Pointer) Uintptr

func (p Pointer) Uintptr(offset int) uintptr

func (Pointer) Unsafe

func (p Pointer) Unsafe() unsafe.Pointer

func (Pointer) Zero

func (p Pointer) Zero(size uintptr)

Zero zeroes out the entire allocation.

Directories

Path Synopsis
cmd
lib
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
lib/darwin_amd64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
lib/darwin_arm64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
lib/linux_amd64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.

Jump to

Keyboard shortcuts

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