|
@@ -7,6 +7,17 @@
|
|
|
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
|
|
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
|
|
|
|
|
+/*
|
|
|
+ * Create a contiguous bitmask starting at bit position @l and ending at
|
|
|
+ * position @h. For example
|
|
|
+ * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
|
|
|
+ */
|
|
|
+#define GENMASK(h, l) \
|
|
|
+ (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
|
|
|
+
|
|
|
+#define GENMASK_ULL(h, l) \
|
|
|
+ (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
|
|
|
+
|
|
|
/*
|
|
|
* ffs: find first bit set. This is defined the same way as
|
|
|
* the libc and compiler builtin ffs routines, therefore
|