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:
Zach Brown
2016-03-23 14:00:07 -07:00
parent f3de3b1817
commit 8471134328

20
utils/src/bitops.h Normal file
View 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