Bit array data structure. More...
Functions | |
uint32_t | spdk_bit_array_capacity (const struct spdk_bit_array *ba) |
Return the number of bits that a bit array is currently sized to hold. | |
struct spdk_bit_array * | spdk_bit_array_create (uint32_t num_bits) |
Create a bit array. | |
void | spdk_bit_array_free (struct spdk_bit_array **bap) |
Free a bit array and set the pointer to NULL. | |
int | spdk_bit_array_resize (struct spdk_bit_array **bap, uint32_t num_bits) |
Create or resize a bit array. | |
bool | spdk_bit_array_get (const struct spdk_bit_array *ba, uint32_t bit_index) |
Get the value of a bit from the bit array. | |
int | spdk_bit_array_set (struct spdk_bit_array *ba, uint32_t bit_index) |
Set (to 1) a bit in the bit array. | |
void | spdk_bit_array_clear (struct spdk_bit_array *ba, uint32_t bit_index) |
Clear (to 0) a bit in the bit array. | |
uint32_t | spdk_bit_array_find_first_set (const struct spdk_bit_array *ba, uint32_t start_bit_index) |
Find the index of the first set bit in the array. | |
uint32_t | spdk_bit_array_find_first_clear (const struct spdk_bit_array *ba, uint32_t start_bit_index) |
Find the index of the first cleared bit in the array. | |
uint32_t | spdk_bit_array_count_set (const struct spdk_bit_array *ba) |
Count the number of set bits in the array. | |
uint32_t | spdk_bit_array_count_clear (const struct spdk_bit_array *ba) |
Count the number of cleared bits in the array. | |
void | spdk_bit_array_store_mask (const struct spdk_bit_array *ba, void *mask) |
Store bitmask from bit array. | |
void | spdk_bit_array_load_mask (struct spdk_bit_array *ba, const void *mask) |
Load bitmask to bit array. | |
void | spdk_bit_array_clear_mask (struct spdk_bit_array *ba) |
Clear (to 0) bit array bitmask. | |
Bit array data structure.
uint32_t spdk_bit_array_capacity | ( | const struct spdk_bit_array * | ba | ) |
Return the number of bits that a bit array is currently sized to hold.
ba | Bit array to query. |
void spdk_bit_array_clear | ( | struct spdk_bit_array * | ba, |
uint32_t | bit_index ) |
Clear (to 0) a bit in the bit array.
If bit_index is beyond the end of the bit array, no action is taken. Bits beyond the end of the bit array are implicitly 0.
ba | Bit array to clear a bit. |
bit_index | The index of a bit to clear. |
void spdk_bit_array_clear_mask | ( | struct spdk_bit_array * | ba | ) |
Clear (to 0) bit array bitmask.
ba | Bit array. |
uint32_t spdk_bit_array_count_clear | ( | const struct spdk_bit_array * | ba | ) |
Count the number of cleared bits in the array.
ba | The bit array to search. |
uint32_t spdk_bit_array_count_set | ( | const struct spdk_bit_array * | ba | ) |
Count the number of set bits in the array.
ba | The bit array to search. |
struct spdk_bit_array * spdk_bit_array_create | ( | uint32_t | num_bits | ) |
Create a bit array.
num_bits | Number of bits that the bit array is sized to hold. |
All bits in the array will be cleared.
uint32_t spdk_bit_array_find_first_clear | ( | const struct spdk_bit_array * | ba, |
uint32_t | start_bit_index ) |
Find the index of the first cleared bit in the array.
ba | The bit array to search. |
start_bit_index | The bit index from which to start searching (0 to start from the beginning of the array). |
uint32_t spdk_bit_array_find_first_set | ( | const struct spdk_bit_array * | ba, |
uint32_t | start_bit_index ) |
Find the index of the first set bit in the array.
ba | The bit array to search. |
start_bit_index | The bit index from which to start searching (0 to start from the beginning of the array). |
void spdk_bit_array_free | ( | struct spdk_bit_array ** | bap | ) |
Free a bit array and set the pointer to NULL.
bap | Bit array to free. |
bool spdk_bit_array_get | ( | const struct spdk_bit_array * | ba, |
uint32_t | bit_index ) |
Get the value of a bit from the bit array.
If bit_index is beyond the end of the current size of the bit array, this function will return false (i.e. bits beyond the end of the array are implicitly 0).
ba | Bit array to query. |
bit_index | The index of a bit to query. |
void spdk_bit_array_load_mask | ( | struct spdk_bit_array * | ba, |
const void * | mask ) |
Load bitmask to bit array.
ba | Bit array. |
mask | Source mask. Mask and bit array capacity must be equal. |
int spdk_bit_array_resize | ( | struct spdk_bit_array ** | bap, |
uint32_t | num_bits ) |
Create or resize a bit array.
To create a new bit array, pass a pointer to a spdk_bit_array pointer that is NULL for bap.
The bit array will be sized to hold at least num_bits.
If num_bits is smaller than the previous size of the bit array, any data beyond the new num_bits size will be cleared.
If num_bits is larger than the previous size of the bit array, any data beyond the old num_bits size will be cleared.
bap | Bit array to create/resize. |
num_bits | Number of bits that the bit array is sized to hold. |
int spdk_bit_array_set | ( | struct spdk_bit_array * | ba, |
uint32_t | bit_index ) |
Set (to 1) a bit in the bit array.
If bit_index is beyond the end of the bit array, this function will return -EINVAL.
ba | Bit array to set a bit. |
bit_index | The index of a bit to set. |
void spdk_bit_array_store_mask | ( | const struct spdk_bit_array * | ba, |
void * | mask ) |
Store bitmask from bit array.
ba | Bit array. |
mask | Destination mask. Mask and bit array capacity must be equal. |