diff options
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r-- | include/linux/bitops.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index a3b6b82108b9..abc9ca778456 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -4,12 +4,23 @@ | |||
4 | 4 | ||
5 | #ifdef __KERNEL__ | 5 | #ifdef __KERNEL__ |
6 | #define BIT(nr) (1UL << (nr)) | 6 | #define BIT(nr) (1UL << (nr)) |
7 | #define BIT_ULL(nr) (1ULL << (nr)) | ||
7 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | 8 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) |
8 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) | 9 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) |
10 | #define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) | ||
11 | #define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) | ||
9 | #define BITS_PER_BYTE 8 | 12 | #define BITS_PER_BYTE 8 |
10 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) | 13 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) |
11 | #endif | 14 | #endif |
12 | 15 | ||
16 | /* | ||
17 | * Create a contiguous bitmask starting at bit position @l and ending at | ||
18 | * position @h. For example | ||
19 | * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. | ||
20 | */ | ||
21 | #define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l)) | ||
22 | #define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l)) | ||
23 | |||
13 | extern unsigned int __sw_hweight8(unsigned int w); | 24 | extern unsigned int __sw_hweight8(unsigned int w); |
14 | extern unsigned int __sw_hweight16(unsigned int w); | 25 | extern unsigned int __sw_hweight16(unsigned int w); |
15 | extern unsigned int __sw_hweight32(unsigned int w); | 26 | extern unsigned int __sw_hweight32(unsigned int w); |