Trimming CC-list.

> It'd can't be done as it's used in declarations
> and included in asm files and it uses the UL()
> macro.

Can the BUILD_BUG_ON_ZERO() macro be used instead? It works in
declarations. I don't know if it works in asm-files, but the below
changes builds an x86-64 allyesconfig without problems (after the rest
of this series have been applied.

/Rikard

---
 include/linux/bits.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/linux/bits.h b/include/linux/bits.h
index 669d69441a62..52e747d27f87 100644
--- a/include/linux/bits.h
+++ b/include/linux/bits.h
@@ -2,6 +2,7 @@
 #ifndef __LINUX_BITS_H
 #define __LINUX_BITS_H
 
+#include <linux/build_bug.h>
 #include <linux/const.h>
 #include <asm/bitsperlong.h>
 
@@ -19,11 +20,15 @@
  * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
  */
 #define GENMASK(h, l) \
+       (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
+               __is_constexpr(h) && __is_constexpr(l), (l) > (h), 0)) + \
        (((~UL(0)) - (UL(1) << (l)) + 1) & \
-        (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
+        (~UL(0) >> (BITS_PER_LONG - 1 - (h)))))
 
 #define GENMASK_ULL(h, l) \
+       (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
+               __is_constexpr(h) && __is_constexpr(l), (l) > (h), 0)) + \
        (((~ULL(0)) - (ULL(1) << (l)) + 1) & \
-        (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
+        (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h)))))
 
 #endif /* __LINUX_BITS_H */
-- 
2.22.0

Reply via email to