Add a truncate test case
[omfsprogs.git] / bits.h
blob72d05c845dffd2d4eff09388eacd4d9bf7c61a44
1 #ifndef _BITS_H
2 #define _BITS_H
4 inline int test_bit(u8* buf, u64 offset)
6 return buf[offset >> 3] & (1<<(offset & 7));
9 inline void init_bit(u8* buf, u64 offset, int value)
11 int mask = ((value & 1) << (offset & 7));
12 buf[offset >> 3] &= ~mask;
13 buf[offset >> 3] |= mask;
16 inline void clear_bit(u8* buf, u64 offset)
18 buf[offset >> 3] &= ~(1 << (offset & 7));
21 inline void set_bit(u8* buf, u64 offset)
23 buf[offset >> 3] |= 1 << (offset & 7);
26 #endif