From 3d5a836379e5064d563322de095d0775607ff185 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roger=20Pau=20Monn=C3=A9?= Date: Tue, 2 Jun 2020 13:39:02 +0200 Subject: [PATCH] compilers: always use _Static_assert with clang MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit All versions of clang used by Xen support _Static_assert, so use it unconditionally when building Xen with clang. No functional change expected. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu Acked-by: Andrew Cooper Release-acked-by: Paul Durrant --- xen/include/xen/lib.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index e5b0a007b8..076bcfb67d 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -25,7 +25,9 @@ #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) #define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0) -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +/* All clang versions supported by Xen have _Static_assert. */ +#if defined(__clang__) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) /* Force a compilation error if condition is true */ #define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); }) -- 2.30.2