48#define BITFIELD(NAME, SIZE) uint8_t NAME[((SIZE) + 7) / 8]
56static inline void bf_set(uint8_t field[],
size_t idx)
58 field[idx / 8] |= (1u << (7 - (idx % 8)));
80static inline void bf_unset(uint8_t field[],
size_t idx)
82 field[idx / 8] &= ~(1u << (7 - (idx % 8)));
104static inline void bf_toggle(uint8_t field[],
size_t idx)
106 field[idx / 8] ^= (1u << (7 - (idx % 8)));
128static inline bool bf_isset(
const uint8_t field[],
size_t idx)
130 return (field[idx / 8] & (1u << (7 - (idx % 8))));
147static inline void bf_or(uint8_t out[],
const uint8_t a[],
const uint8_t b[],
size_t len)
151 out[len] = a[len] | b[len];
170 const uint8_t b[],
size_t len)
173 bf_or(out, a, b, len);
191static inline void bf_and(uint8_t out[],
const uint8_t a[],
const uint8_t b[],
size_t len)
195 out[len] = a[len] & b[len];
214 const uint8_t b[],
size_t len)
235static inline void bf_xor(uint8_t out[],
const uint8_t a[],
const uint8_t b[],
size_t len)
239 out[len] = a[len] ^ b[len];
258 const uint8_t b[],
size_t len)
278static inline void bf_inv(uint8_t out[],
const uint8_t a[],
size_t len)
299static inline void bf_inv_atomic(uint8_t out[],
const uint8_t a[],
size_t len)
static void bf_toggle_atomic(uint8_t field[], size_t idx)
Atomically toggle the bit.
static void bf_set(uint8_t field[], size_t idx)
Set the bit to 1.
static void bf_inv_atomic(uint8_t out[], const uint8_t a[], size_t len)
Atomically perform a bitwise NOT operation on a bitfield out = ~a
static void bf_unset_atomic(uint8_t field[], size_t idx)
Atomically clear the bit.
static void bf_or_atomic(uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len)
Atomically perform a bitwise OR operation on two bitfields out = a | b
static void bf_clear_all_atomic(uint8_t field[], size_t size)
Atomically clear all bits in the bitfield to 0.
static void bf_set_all_atomic(uint8_t field[], size_t size)
Atomically set all bits in the bitfield to 1.
int bf_find_first_unset(const uint8_t field[], size_t size)
Get the index of the zero bit in the field.
void bf_clear_all(uint8_t field[], size_t size)
Clear all bits in the bitfield to 0.
static void bf_and_atomic(uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len)
Atomically perform a bitwise AND operation on two bitfields out = a & b
static void bf_xor(uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len)
Perform a bitwise XOR operation on two bitfields out = a ^ b
static void bf_set_atomic(uint8_t field[], size_t idx)
Atomically set the bit to 1.
static void bf_toggle(uint8_t field[], size_t idx)
Toggle the bit.
static void bf_and(uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len)
Perform a bitwise AND operation on two bitfields out = a & b
int bf_find_first_set(const uint8_t field[], size_t size)
Get the index of the first set bit in the field.
static void bf_xor_atomic(uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len)
Atomically perform a bitwise XOR operation on two bitfields out = a ^ b
static void bf_unset(uint8_t field[], size_t idx)
Clear the bit.
static void bf_or(uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len)
Perform a bitwise OR operation on two bitfields out = a | b
unsigned bf_popcnt(const uint8_t field[], size_t size)
Count set bits in the bitfield.
static void bf_inv(uint8_t out[], const uint8_t a[], size_t len)
Perform a bitwise NOT operation on a bitfield out = ~a
static bool bf_isset(const uint8_t field[], size_t idx)
Check if the bet is set.
void bf_set_all(uint8_t field[], size_t size)
Set all bits in the bitfield to 1.
int bf_get_unset(uint8_t field[], size_t len)
Atomically get the number of an unset bit and set it.
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.