xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.14] compilers/clang: always use _Static_assert with clang
@ 2020-06-02  9:16 Roger Pau Monne
  2020-06-02  9:23 ` Wei Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Pau Monne @ 2020-06-02  9:16 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, paul, Andrew Cooper,
	Ian Jackson, George Dunlap, Jan Beulich, Roger Pau Monne

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH for-4.14] compilers/clang: always use _Static_assert with clang
  2020-06-02  9:16 [PATCH for-4.14] compilers/clang: always use _Static_assert with clang Roger Pau Monne
@ 2020-06-02  9:23 ` Wei Liu
  2020-06-02  9:26   ` Paul Durrant
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Liu @ 2020-06-02  9:23 UTC (permalink / raw)
  To: Roger Pau Monne
  Cc: Stefano Stabellini, Julien Grall, Wei Liu, paul, Andrew Cooper,
	Ian Jackson, George Dunlap, Jan Beulich, xen-devel

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@citrix.com>

Reviewed-by: Wei Liu <wl@xen.org>

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH for-4.14] compilers/clang: always use _Static_assert with clang
  2020-06-02  9:23 ` Wei Liu
@ 2020-06-02  9:26   ` Paul Durrant
  2020-06-02  9:48     ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Durrant @ 2020-06-02  9:26 UTC (permalink / raw)
  To: 'Wei Liu', 'Roger Pau Monne'
  Cc: 'Stefano Stabellini', 'Julien Grall',
	'Andrew Cooper', 'Ian Jackson',
	'George Dunlap', 'Jan Beulich',
	xen-devel

> -----Original Message-----
> From: Wei Liu <wl@xen.org>
> Sent: 02 June 2020 10:23
> To: Roger Pau Monne <roger.pau@citrix.com>
> Cc: xen-devel@lists.xenproject.org; paul@xen.org; Andrew Cooper <andrew.cooper3@citrix.com>; George
> Dunlap <george.dunlap@citrix.com>; Ian Jackson <ian.jackson@eu.citrix.com>; Jan Beulich
> <jbeulich@suse.com>; Julien Grall <julien@xen.org>; Stefano Stabellini <sstabellini@kernel.org>; Wei
> Liu <wl@xen.org>
> Subject: 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@citrix.com>
> 
> Reviewed-by: Wei Liu <wl@xen.org>
> 
> > ---
> > 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.

Yes, seems reasonable.

Release-acked-by: Paul Durrant <paul@xen.org>

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH for-4.14] compilers/clang: always use _Static_assert with clang
  2020-06-02  9:26   ` Paul Durrant
@ 2020-06-02  9:48     ` Andrew Cooper
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2020-06-02  9:48 UTC (permalink / raw)
  To: paul, 'Wei Liu', 'Roger Pau Monne'
  Cc: 'Stefano Stabellini', 'Julien Grall',
	'Ian Jackson', 'George Dunlap',
	'Jan Beulich',
	xen-devel

On 02/06/2020 10:26, Paul Durrant wrote:
>> 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@citrix.com>
>> Reviewed-by: Wei Liu <wl@xen.org>
>>
>>> ---
>>> 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.
> Yes, seems reasonable.
>
> Release-acked-by: Paul Durrant <paul@xen.org>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-02  9:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  9:16 [PATCH for-4.14] compilers/clang: always use _Static_assert with clang Roger Pau Monne
2020-06-02  9:23 ` Wei Liu
2020-06-02  9:26   ` Paul Durrant
2020-06-02  9:48     ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).