[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.19? 3/6] xen/macros: Introduce BUILD_ERROR()



On Tue, 2024-06-25 at 20:07 +0100, Andrew Cooper wrote:
> ... 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.cooper3@xxxxxxxxxx>
> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> CC: Julien Grall <julien@xxxxxxx>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
> CC: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> CC: Michal Orzel <michal.orzel@xxxxxxx>
> CC: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
> 
> 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.
We can consider this patch to be in 4.19 release if necessary Acked
will be recieved:
 Release-Acked-By: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>

~ Oleksii

> 
> ---
>  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)


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.