|
2 | 2 | #ifndef __LINUX_BITS_H
|
3 | 3 | #define __LINUX_BITS_H
|
4 | 4 |
|
5 |
| -#include <linux/const.h> |
6 | 5 | #include <vdso/bits.h>
|
7 | 6 | #include <uapi/linux/bits.h>
|
8 |
| -#include <asm/bitsperlong.h> |
9 | 7 |
|
10 | 8 | #define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG))
|
11 | 9 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
|
50 | 48 | (type_max(t) << (l) & \
|
51 | 49 | type_max(t) >> (BITS_PER_TYPE(t) - 1 - (h)))))
|
52 | 50 |
|
| 51 | +#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l) |
| 52 | +#define GENMASK_ULL(h, l) GENMASK_TYPE(unsigned long long, h, l) |
| 53 | + |
53 | 54 | #define GENMASK_U8(h, l) GENMASK_TYPE(u8, h, l)
|
54 | 55 | #define GENMASK_U16(h, l) GENMASK_TYPE(u16, h, l)
|
55 | 56 | #define GENMASK_U32(h, l) GENMASK_TYPE(u32, h, l)
|
56 | 57 | #define GENMASK_U64(h, l) GENMASK_TYPE(u64, h, l)
|
| 58 | +#define GENMASK_U128(h, l) GENMASK_TYPE(u128, h, l) |
57 | 59 |
|
58 | 60 | /*
|
59 | 61 | * Fixed-type variants of BIT(), with additional checks like GENMASK_TYPE(). The
|
|
79 | 81 | * BUILD_BUG_ON_ZERO is not available in h files included from asm files,
|
80 | 82 | * disable the input check if that is the case.
|
81 | 83 | */
|
82 |
| -#define GENMASK_INPUT_CHECK(h, l) 0 |
| 84 | +#define GENMASK(h, l) __GENMASK(h, l) |
| 85 | +#define GENMASK_ULL(h, l) __GENMASK_ULL(h, l) |
83 | 86 |
|
84 | 87 | #endif /* !defined(__ASSEMBLY__) */
|
85 | 88 |
|
86 |
| -#define GENMASK(h, l) \ |
87 |
| - (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) |
88 |
| -#define GENMASK_ULL(h, l) \ |
89 |
| - (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l)) |
90 |
| - |
91 |
| -#if !defined(__ASSEMBLY__) |
92 |
| -/* |
93 |
| - * Missing asm support |
94 |
| - * |
95 |
| - * __GENMASK_U128() depends on _BIT128() which would not work |
96 |
| - * in the asm code, as it shifts an 'unsigned __int128' data |
97 |
| - * type instead of direct representation of 128 bit constants |
98 |
| - * such as long and unsigned long. The fundamental problem is |
99 |
| - * that a 128 bit constant will get silently truncated by the |
100 |
| - * gcc compiler. |
101 |
| - */ |
102 |
| -#define GENMASK_U128(h, l) \ |
103 |
| - (GENMASK_INPUT_CHECK(h, l) + __GENMASK_U128(h, l)) |
104 |
| -#endif |
105 |
| - |
106 | 89 | #endif /* __LINUX_BITS_H */
|
0 commit comments