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