]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/linux/bits.h
1 /* SPDX-License-Identifier: GPL-2.0 */
4 #include <asm/bitsperlong.h>
6 #define BIT(nr) (1UL << (nr))
7 #define BIT_ULL(nr) (1ULL << (nr))
8 #define BIT_MASK(nr) (1UL << ((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)
12 #define BITS_PER_BYTE 8
15 * Create a contiguous bitmask starting at bit position @l and ending at
16 * position @h. For example
17 * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
19 #define GENMASK(h, l) \
20 (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
22 #define GENMASK_ULL(h, l) \
23 (((~0ULL) - (1ULL << (l)) + 1) & \
24 (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
26 #endif /* __LINUX_BITS_H */