bitfields operations on bitfields of arbitrary length More...
bitfields operations on bitfields of arbitrary length
Definition in file bitfield.h.
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
#define | BITFIELD(NAME, SIZE) uint8_t NAME[((SIZE) + 7) / 8] |
Declare a bitfield of a given size. More... | |
static void | bf_set (uint8_t field[], size_t idx) |
Set the bit to 1. More... | |
static void | bf_unset (uint8_t field[], size_t idx) |
Clear the bit. More... | |
static void | bf_toggle (uint8_t field[], size_t idx) |
Toggle the bit. More... | |
static bool | bf_isset (uint8_t field[], size_t idx) |
Check if the bet is set. More... | |
int | bf_get_unset (uint8_t field[], int size) |
Atomically get the number of an unset bit and set it. More... | |
#define BITFIELD | ( | NAME, | |
SIZE | |||
) | uint8_t NAME[((SIZE) + 7) / 8] |
Declare a bitfield of a given size.
Definition at line 46 of file bitfield.h.
int bf_get_unset | ( | uint8_t | field[], |
int | size | ||
) |
Atomically get the number of an unset bit and set it.
This function can be used to record e.g., empty entries in an array.
[in,out] | field | The bitfield |
[in] | size | The size of the bitfield |
|
inlinestatic |
Check if the bet is set.
[in,out] | field | The bitfield |
[in] | idx | The number of the bit to check |
Definition at line 87 of file bitfield.h.
|
inlinestatic |
Set the bit to 1.
[in,out] | field | The bitfield |
[in] | idx | The number of the bit to set |
Definition at line 54 of file bitfield.h.
|
inlinestatic |
Toggle the bit.
[in,out] | field | The bitfield |
[in] | idx | The number of the bit to toggle |
Definition at line 76 of file bitfield.h.
|
inlinestatic |
Clear the bit.
[in,out] | field | The bitfield |
[in] | idx | The number of the bit to clear |
Definition at line 65 of file bitfield.h.