diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl index 7d4b6f2948..c087032293 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -19,6 +19,7 @@ Constant expressions and unreachable branches of if and switch statements are ex -doc_begin="Unreachability inside an ASSERT_UNREACHABLE() and analogous macro calls is deliberate and safe." -config=MC3A2.R2.1,reports+={deliberate, "any_area(any_loc(any_exp(macro(name(ASSERT_UNREACHABLE||PARSE_ERR_RET||PARSE_ERR||FAIL_MSR||FAIL_CPUID)))))"} +-config=MC3A2.R2.1,reports+={deliberate, "any_area(any_loc(any_exp(macro(^BUILD_ERROR(|_IF(|_NOT))$))))"} -doc_end -doc_begin="The asm-offset files are not linked deliberately, since they are used to generate definitions for asm modules." @@ -667,6 +668,7 @@ deliberate." to the # or ## operators within the following macros are deliberate, to provide useful diagnostic messages to the user." -config=MC3A2.R20.12,macros+={deliberate, "name(ASSERT||BUILD_BUG_ON||BUILD_BUG_ON_ZERO||RUNTIME_CHECK)"} +-config=MC3A2.R20.12,macros+={deliberate, "^BUILD_ERROR(|_IF(|_NOT))$"} -doc_end -doc_begin="The helper macro GENERATE_CASE may use a macro parameter for ordinary diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h index e29cff791e..b07bd5f530 100644 --- a/xen/include/xen/macros.h +++ b/xen/include/xen/macros.h @@ -64,6 +64,21 @@ */ #define BUILD_ERROR(msg) asm ( ".error \"" msg "\"" ) +/* + * Like above, but conditional upon @cfg (not) being enabled. @cfg must be + * suitable to pass to IS_ENABLED(). + */ +#define BUILD_ERROR_IF(cfg) \ + (IS_ENABLED(cfg) \ + ? ({ BUILD_ERROR( #cfg " unexpectedly enabled"); }) \ + : (void)0) + +#define BUILD_ERROR_IF_NOT(cfg) \ + (!IS_ENABLED(cfg) \ + ? ({ BUILD_ERROR( #cfg " unexpectedly disabled"); }) \ + : (void)0) + + /* Hide a value from the optimiser. */ #define HIDE(x) \ ({ \