Base/core/src-c/bitfield.c

32 lines
564 B
C
Raw Normal View History

2023-12-06 17:15:32 +00:00
#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;
2023-12-06 17:15:32 +00:00
}
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;
2023-12-06 17:15:32 +00:00
}