Message ID | 20241203-is_constexpr-refactor-v1-4-4e4cbaecc216@wanadoo.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | compiler.h: refactor __is_constexpr() into is_const{,_true,_false}() | expand |
On Thu. 5 Dec 2024 at 03:52, David Laight <David.Laight@aculab.com> wrote: > From: Vincent Mailhol > > Sent: 02 December 2024 17:33 > > > > __builtin_choose_expr(__is_constexpr((l) > (h)), (l) > (h), 0) > > > > is equivalent to: > > > > is_const_true((l) > (h)) > > Change it to BUILD_BUG_ON_MSG(statically_true((l) < (h)), "error message") > > and then fix all the fallout :-) BUILD_BUG_ON_MSG() is not suitable for GENMASK_INPUT_CHECK. We need one of the variants that returns zero here. But I agree that it is good to have a more meaningful error message here. I will use __BUILD_BUG_ON_ZERO_MSG() in v2. Yours sincerely, Vincent Mailhol
diff --git a/include/linux/bits.h b/include/linux/bits.h index 60044b6088172b3f26aa3f17cdaede9786863dae..ef0119e6179e1ca95345a3d4d3327ba19633028e 100644 --- a/include/linux/bits.h +++ b/include/linux/bits.h @@ -20,9 +20,8 @@ */ #if !defined(__ASSEMBLY__) #include <linux/build_bug.h> -#define GENMASK_INPUT_CHECK(h, l) \ - (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ - __is_constexpr((l) > (h)), (l) > (h), 0))) +#include <linux/compiler.h> +#define GENMASK_INPUT_CHECK(h, l) BUILD_BUG_ON_ZERO(is_const_true((l) > (h))) #else /* * BUILD_BUG_ON_ZERO is not available in h files included from asm files,