From 8471134328b646f4ba5b9b8de32e8e55f6ed3f2b Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 23 Mar 2016 14:00:07 -0700 Subject: [PATCH] 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 --- utils/src/bitops.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 utils/src/bitops.h diff --git a/utils/src/bitops.h b/utils/src/bitops.h new file mode 100644 index 00000000..dfe46a1c --- /dev/null +++ b/utils/src/bitops.h @@ -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