Simple fixed-size bitset implementation. More...
Data Structures | |
| struct | fixed_bitset_t |
| Base type for a fixed-size bitset. More... | |
Macros | |
| #define | fixed_bitset_type(N) |
| Macro used to define a fixed-size bitset of a given size. | |
| #define | fixed_bitset_with_fill(type, N, fill) |
| Macro used to create a bitset with all bits set to a value. | |
| #define | fixed_bitset_init(ptr, type, N, fill) |
| Initialize a bitset. | |
Functions | |
| static uint | fixed_bitset_size (const fixed_bitset_t *bitset) |
| Get the size of the bitset. | |
| static uint | fixed_bitset_word_size (const fixed_bitset_t *bitset) |
| Get the size of the bitset in words. | |
| static void | check_fixed_bitset (__unused const fixed_bitset_t *bitset) |
| Check that the bitset is valid. | |
| static fixed_bitset_t * | fixed_bitset_write_word (fixed_bitset_t *bitset, uint word_num, uint32_t value) |
| Write a word in the bitset. | |
| static uint32_t | fixed_bitset_read_word (const fixed_bitset_t *bitset, uint word_num) |
| Read a word in the bitset. | |
| static fixed_bitset_t * | fixed_bitset_clear_all (fixed_bitset_t *bitset) |
| Clear all bits in the bitset. | |
| static fixed_bitset_t * | fixed_bitset_set_all (fixed_bitset_t *bitset) |
| Set all bits in the bitset. | |
| fixed_bitset_t * | fixed_bitset_flip_all (fixed_bitset_t *bitset) |
| Flip all bits in the bitset. | |
| bool | fixed_bitset_is_empty (fixed_bitset_t *bitset) |
| Determine if bitset is empty. | |
| static fixed_bitset_t * | fixed_bitset_set (fixed_bitset_t *bitset, uint bit_index) |
| Set a single bit in the bitset. | |
| static fixed_bitset_t * | fixed_bitset_clear (fixed_bitset_t *bitset, uint bit_index) |
| Clear a single bit in the bitset. | |
| static fixed_bitset_t * | fixed_bitset_flip (fixed_bitset_t *bitset, uint bit_index) |
| Flip a single bit in the bitset. | |
| static bool | fixed_bitset_get (const fixed_bitset_t *bitset, uint bit_index) |
| Get the value of a single bit in the bitset. | |
| static bool | fixed_bitset_equal (const fixed_bitset_t *bitset1, const fixed_bitset_t *bitset2) |
| Check if two bitsets are equal. | |
Simple fixed-size bitset implementation.
| #define fixed_bitset_init | ( | ptr, | |
| type, | |||
| N, | |||
| fill ) |
Initialize a bitset.
| ptr | the bitset to initialize |
| type | the type of the bitset |
| N | the number of bits in the bitset |
| fill | the value to fill the bitset with (0 or 1) |
| #define fixed_bitset_type | ( | N | ) |
Macro used to define a fixed-size bitset of a given size.
This macro is used to declare the type of a fixed-size bitset. It is used as follows:
will define a new bitset type called my_bitset_t that can hold 17 boolean values.
The type can be used as my_bitset_t bitset; to declare a new bitset.
| N | the number of boolean values in the bitset |
| #define fixed_bitset_with_fill | ( | type, | |
| N, | |||
| fill ) |
Macro used to create a bitset with all bits set to a value.
| type | the type of the bitset |
| N | the number of bits in the bitset |
| fill | the value to set the bits to (0 or 1) |
|
inlinestatic |
Check that the bitset is valid.
This function will assert if the bitset is not valid.
| bitset | the bitset to check |
|
inlinestatic |
Clear a single bit in the bitset.
| bitset | the bitset |
| bit_index | the bit to clear |
|
inlinestatic |
Clear all bits in the bitset.
| bitset | the bitset |
|
inlinestatic |
Check if two bitsets are equal.
| bitset1 | the first bitset to check |
| bitset2 | the second bitset to check |
|
inlinestatic |
Flip a single bit in the bitset.
| bitset | the bitset |
| bit_index | the bit to flip |
| fixed_bitset_t * fixed_bitset_flip_all | ( | fixed_bitset_t * | bitset | ) |
Flip all bits in the bitset.
| bitset | the bitset |
|
inlinestatic |
Get the value of a single bit in the bitset.
| bitset | the bitset |
| bit_index | the bit to get the value of |
| bool fixed_bitset_is_empty | ( | fixed_bitset_t * | bitset | ) |
Determine if bitset is empty.
| bitset | the bitset |
|
inlinestatic |
Read a word in the bitset.
| bitset | the bitset |
| word_num | the word number to read from |
|
inlinestatic |
Set a single bit in the bitset.
| bitset | the bitset |
| bit_index | the bit to set |
|
inlinestatic |
Set all bits in the bitset.
| bitset | the bitset |
|
inlinestatic |
Get the size of the bitset.
| bitset | the bitset to get the size of |
|
inlinestatic |
Get the size of the bitset in words.
| bitset | the bitset to get the size of |
|
inlinestatic |
Write a word in the bitset.
| bitset | the bitset to write to |
| word_num | the word number to write to |
| value | the value to write to the word |