bitfield

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package bitfield provides bit-field access helpers.

Bit numbering: bit k of the memory at base is bit (k % 8) of byte (k / 8), where bit 0 of a byte is its least significant bit (little-endian bit allocation, as on x86-64 and AArch64).

Unsigned, Signed and Set require 1 <= width <= 64 and touch only the bytes that contain at least one bit of the range [off, off+width). A range of up to 64 bits can span 9 bytes when it is not byte-aligned; that case is handled explicitly. The helpers are not atomic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(base unsafe.Pointer, off, width uintptr, v uint64)

Set replaces bits off .. off+width-1 of the memory at base with the low width bits of v. All other bits are left unchanged.

func Signed

func Signed(base unsafe.Pointer, off, width uintptr) int64

Signed returns the same bits as Unsigned, sign-extended from bit width-1.

func Unsigned

func Unsigned(base unsafe.Pointer, off, width uintptr) uint64

Unsigned returns bits off .. off+width-1 of the memory at base, zero-extended into the low bits of the result.

Types

This section is empty.

Jump to

Keyboard shortcuts

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