NAME
KS_clamp,
KS_u8_clamp, KS_u16_clamp,
KS_u32_clamp,
KS_extract_and_deposit —
bit manipulation functions
SYNOPSIS
#include
<libks/bit.h>
KS_clamp(uint64_t
x, int nbits);
uint8_t
KS_u8_clamp(uint64_t
x);
uint16_t
KS_u16_clamp(uint64_t
x);
uint32_t
KS_u32_clamp(uint64_t
x);
uint64_t
KS_extract_and_deposit(uint64_t
val, uint64_t extract_mask,
uint64_t deposit_mask);
DESCRIPTION
The
KS_clamp()
macro clamps x to nbits number
of bits. Its return type will be proportional to an
nbits wide integer.
The
KS_u8_clamp()
function clamps x to an 8-bit integer.
The
KS_u16_clamp()
function clamps x to an 16-bit integer.
The
KS_u32_clamp()
function clamps x to an 32-bit integer.
The
KS_extract_and_deposit()
function extracts the bits in val according to the
extract_mask. The placement of the extracted bits in
the return value is determined by the deposit_mask in
which the first extracted bit will be placed at the first non-zero bit in
deposit_mask and so forth.
AUTHORS
Anton Lindqvist <anton@basename.se>