mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-07 04:26:29 +00:00
Add trivial set_bit_le in bitops.h
We're going to need to start setting bloom filters bits in mkfs so we'll add this trivial inline. It might grow later. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
20
utils/src/bitops.h
Normal file
20
utils/src/bitops.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _BITOPS_H_
|
||||
#define _BITOPS_H_
|
||||
|
||||
#define BITS_PER_LONG (sizeof(long) * 8)
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define BITOP_LE_SWIZZLE 0
|
||||
#else
|
||||
#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
|
||||
#endif
|
||||
|
||||
static inline void set_bit_le(int nr, void *addr)
|
||||
{
|
||||
u64 *dwords = addr;
|
||||
|
||||
nr ^= BITOP_LE_SWIZZLE;
|
||||
|
||||
dwords[nr / 64] |= 1 << (nr & 63);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user