... and use it in self-tests.h. This is intended to replace constructs such as __bitop_bad_size(). It produces a better diagnostic, and is MISRA-friendly.
Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com> --- CC: Jan Beulich <jbeul...@suse.com> CC: Roger Pau Monné <roger....@citrix.com> CC: Stefano Stabellini <sstabell...@kernel.org> CC: Julien Grall <jul...@xen.org> CC: Volodymyr Babchuk <volodymyr_babc...@epam.com> CC: Bertrand Marquis <bertrand.marq...@arm.com> CC: Michal Orzel <michal.or...@amd.com> CC: Oleksii Kurochko <oleksii.kuroc...@gmail.com> RFC for-4.19. This can be used to not introduce new MISRA violations when adjusting __bitop_bad_size(). It's safe to pull out of this series. --- xen/include/xen/macros.h | 2 ++ xen/include/xen/self-tests.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h index ec89f4654fcf..8441d7e7d66a 100644 --- a/xen/include/xen/macros.h +++ b/xen/include/xen/macros.h @@ -59,6 +59,8 @@ #define BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond)) #endif +#define BUILD_ERROR(msg) asm ( ".error \"" msg "\"" ) + /* Hide a value from the optimiser. */ #define HIDE(x) \ ({ \ diff --git a/xen/include/xen/self-tests.h b/xen/include/xen/self-tests.h index 42a4cc4d17fe..4bc322b7f2a6 100644 --- a/xen/include/xen/self-tests.h +++ b/xen/include/xen/self-tests.h @@ -22,9 +22,9 @@ typeof(fn(val)) real = fn(val); \ \ if ( !__builtin_constant_p(real) ) \ - asm ( ".error \"'" STR(fn(val)) "' not compile-time constant\"" ); \ + BUILD_ERROR("'" STR(fn(val)) "' not compile-time constant"); \ else if ( real != res ) \ - asm ( ".error \"Compile time check '" STR(fn(val) == res) "' failed\"" ); \ + BUILD_ERROR("Compile time check '" STR(fn(val) == res) "' failed"); \ } while ( 0 ) #else #define COMPILE_CHECK(fn, val, res) -- 2.39.2