Base/core/src-c/bitfield.c

32 lines
564 B
C

#include <librr/bitfield.h>
inline bool_t rr_is_bit_set(u64_t buffer, usz_t index)
{
return !!(buffer & (1 << index));
}
inline u64_t rr_set_bit(u64_t buffer, usz_t index)
{
return buffer | (1 << index);
}
u64_t rr_bitpad_lsb(usz_t count)
{
u64_t result = 0;
for(usz_t index = 0; index < count; ++index)
{
result |= 1 << index;
}
return result;
}
u64_t rr_bitpad_msb(usz_t count)
{
u64_t result = 0;
for(usz_t index = 0; index < count; ++index)
{
result |= (1 << 63) >> index;
}
return result;
}