compilers: always use _Static_assert with clang
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 2 Jun 2020 11:39:02 +0000 (13:39 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 2 Jun 2020 11:39:02 +0000 (13:39 +0200)
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é <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wl@xen.org>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Paul Durrant <paul@xen.org>
xen/include/xen/lib.h

index e5b0a007b82e1de4538b3e98593ad7f363b48e77..076bcfb67dbb22112608eaf0db0d9bd702140b81 100644 (file)
@@ -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 ")"); })