7#ifndef ZEPHYR_INCLUDE_SYS_BITARRAY_H_
8#define ZEPHYR_INCLUDE_SYS_BITARRAY_H_
57#define _SYS_BITARRAY_DEFINE(name, total_bits, sba_mod) \
58 sba_mod uint32_t _sys_bitarray_bundles_##name \
59 [DIV_ROUND_UP(DIV_ROUND_UP(total_bits, 8), \
60 sizeof(uint32_t))] = {0}; \
61 sba_mod sys_bitarray_t name = { \
62 .num_bits = (total_bits), \
63 .num_bundles = DIV_ROUND_UP( \
64 DIV_ROUND_UP(total_bits, 8), sizeof(uint32_t)), \
65 .bundles = _sys_bitarray_bundles_##name, \
74#define SYS_BITARRAY_DEFINE(name, total_bits) \
75 _SYS_BITARRAY_DEFINE(name, total_bits,)
83#define SYS_BITARRAY_DEFINE_STATIC(name, total_bits) \
84 _SYS_BITARRAY_DEFINE(name, total_bits, static)
316 size_t offset,
bool to_set);
ZTEST_BMEM int count
Definition main.c:33
int sys_bitarray_find_nth_set(sys_bitarray_t *bitarray, size_t n, size_t num_bits, size_t offset, size_t *found_at)
Find nth bit set in region.
struct sys_bitarray sys_bitarray_t
Bitarray structure.
Definition bitarray.h:48
int sys_bitarray_xor(sys_bitarray_t *dst, sys_bitarray_t *other, size_t num_bits, size_t offset)
Calculates the bit-wise XOR of two bitarrays in a region.
bool sys_bitarray_is_region_cleared(sys_bitarray_t *bitarray, size_t num_bits, size_t offset)
Test if bits in a region is all cleared.
bool sys_bitarray_is_region_set(sys_bitarray_t *bitarray, size_t num_bits, size_t offset)
Test if bits in a region is all set.
int sys_bitarray_test_and_clear_bit(sys_bitarray_t *bitarray, size_t bit, int *prev_val)
Test the bit and clear it.
int sys_bitarray_set_bit(sys_bitarray_t *bitarray, size_t bit)
Set a bit in a bit array.
int sys_bitarray_clear_bit(sys_bitarray_t *bitarray, size_t bit)
Clear a bit in a bit array.
int sys_bitarray_popcount_region(sys_bitarray_t *bitarray, size_t num_bits, size_t offset, size_t *count)
Count bits set in a bit array region.
int sys_bitarray_set_region(sys_bitarray_t *bitarray, size_t num_bits, size_t offset)
Set all bits in a region.
int sys_bitarray_alloc(sys_bitarray_t *bitarray, size_t num_bits, size_t *offset)
Allocate bits in a bit array.
int sys_bitarray_clear_region(sys_bitarray_t *bitarray, size_t num_bits, size_t offset)
Clear all bits in a region.
int sys_bitarray_test_and_set_bit(sys_bitarray_t *bitarray, size_t bit, int *prev_val)
Test the bit and set it.
int sys_bitarray_test_and_set_region(sys_bitarray_t *bitarray, size_t num_bits, size_t offset, bool to_set)
Test if all bits in a region are cleared/set and set/clear them in a single atomic operation.
int sys_bitarray_test_bit(sys_bitarray_t *bitarray, size_t bit, int *val)
Test whether a bit is set or not.
int sys_bitarray_free(sys_bitarray_t *bitarray, size_t num_bits, size_t offset)
Free bits in a bit array.
static struct k_spinlock lock
Definition spinlock_error_case.c:13
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Kernel Spin Lock.
Definition spinlock.h:45