BITX64(9F) Kernel Functions for Drivers BITX64(9F)
NAME
bitx8,
bitx16,
bitx32,
bitx64 - extract bits from an integer
SYNOPSIS
#include <sys/bitext.h> uint8_t bitx8(
uint8_t value,
uint_t high,
uint_t low);
uint16_t bitx16(
uint16_t value,
uint_t high,
uint_t low);
uint32_t bitx32(
uint32_t value,
uint_t high,
uint_t low);
uint64_t bitx64(
uint64_t value,
uint_t high,
uint_t low);
INTERFACE LEVEL
Volatile - This interface is still evolving in illumos. API and ABI
stability is not guaranteed.
PARAMETERS
value An integer to extract a value from.
high The high end, inclusive, of the bit range to extract from
value.
low The low end, inclusive, of the bit range to extract from
value.
DESCRIPTION
The
bitx8(),
bitx16(),
bitx32(), and
bitx64() functions are used to
extract a range of bits from on an 8, 16, 32, and 64-bit value
respectively. These functions are all implementations of a classical
application of a bitwise-AND of a mask and a logical right shift. More
specifically, the arguments
high and
low describe an inclusive range of
bits ([
low,
high]) to extract from
value. The extracted bits are all
shifted right such that the resulting value starts at bit 0 (that is,
shifted over by
low).
Each of the variants here operates on a specifically sized integer.
high and
low must fit within the bit range that the integer implies.
For example, the valid range for
bitx32 is from 0 to 31.
high must not
be less than
low.
CONTEXT
These functions may be called in all contexts,
user,
kernel, and
interrupt.
RETURN VALUES
Upon successful completion, the
bitx8(),
bitx16(),
bitx32(), and
bitx64() functions all return the indicated portion of
val.
SEE ALSO
bitdel64(9F),
bitset64(9F)illumos April 12, 2022 illumos