5 #include <ctu_base_api.h>
31 #define CT_BITSET_ARRAY(arr) { sizeof(arr), arr }
#define CT_PUREFN
mark a function as pure, always returns the same value for the same arguments
#define CT_NODISCARD
mark a function as returning a value that must be used
#define STA_READS(size)
annotate a parameter as reading expr elements
CT_PUREFN CT_BASE_API size_t bitset_len(bitset_t set)
get the number of bits in a bitset
CT_PUREFN CT_BASE_API bool bitset_test(bitset_t set, size_t index)
test if a bit is set
CT_PUREFN CT_BASE_API bool bitset_any(bitset_t set, bitset_t mask)
test if any bits in a given mask are set
CT_NODISCARD CT_BASE_API size_t bitset_set_first(bitset_t set, size_t start)
scan for the next free bit and set it
CT_BASE_API void bitset_reset(bitset_t set)
reset all bits in a bitset
CT_PUREFN CT_BASE_API bool bitset_all(bitset_t set, bitset_t mask)
test if all bits in a given mask are set
CT_BASE_API void bitset_set(bitset_t set, size_t index)
set a bit
CT_NODISCARD CT_BASE_API bitset_t bitset_of(STA_READS(words) void *data, size_t words)
create a bitset from a buffer
CT_BASE_API void bitset_clear(bitset_t set, size_t index)
clear a bit
STA_FIELD_SIZE(words) void *data
the data for the bitset
STA_FIELD_RANGE(0, SIZE_MAX) size_t words
the number of bytes in data