[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH for-4.14] compilers/clang: always use _Static_assert with clang
On Tue, Jun 02, 2020 at 11:16:02AM +0200, Roger Pau Monne wrote: > 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@xxxxxxxxxx> Reviewed-by: Wei Liu <wl@xxxxxxx> > --- > Not sure whether this fully qualifies as a bugfix, as the current > behavior should also work fine under clang. Note that all versions of > clang from 3.5 to trunk (11) seem to return __GNUC__ == 4 and > __GNUC_MINOR__ == 2. IMHO it wouldn't hurt to apply this patch since any breakage is easy to catch. > --- > 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.26.2 >
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |