* [MINIOS PATCH] lib.h: remove BUILD_BUG_ON
@ 2016-08-12 14:01 Wei Liu
2016-08-12 14:02 ` Samuel Thibault
0 siblings, 1 reply; 3+ messages in thread
From: Wei Liu @ 2016-08-12 14:01 UTC (permalink / raw)
To: Minios-devel; +Cc: Xen-devel, Wei Liu, Samuel Thibault
BUILD_BUG_ON should not appear in a public-facing header, otherwise it
risks clashing with macro with the same name in other code bases. I
encountered such issue when trying to add BUILD_BUG_ON to a private
header in Xen's gnttab library.
Ideally BUILD_BUG_ON should be moved to a private header, but there is
actually no user of it in mini-os tree, just remove it.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
include/lib.h | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/include/lib.h b/include/lib.h
index 39d6a18..e7155e2 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -54,15 +54,6 @@
#include <xen/event_channel.h>
#include "gntmap.h"
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); })
-#define BUILD_BUG_ON_ZERO(cond) \
- sizeof(struct { _Static_assert(!(cond), "!(" #cond ")"); })
-#else
-#define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })
-#define BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
-#endif
-
#ifdef HAVE_LIBC
#include <sys/queue.h>
#include <stdio.h>
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [MINIOS PATCH] lib.h: remove BUILD_BUG_ON
2016-08-12 14:01 [MINIOS PATCH] lib.h: remove BUILD_BUG_ON Wei Liu
@ 2016-08-12 14:02 ` Samuel Thibault
2016-08-12 15:14 ` Wei Liu
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2016-08-12 14:02 UTC (permalink / raw)
To: Wei Liu; +Cc: Minios-devel, Xen-devel
Wei Liu, on Fri 12 Aug 2016 15:01:07 +0100, wrote:
> BUILD_BUG_ON should not appear in a public-facing header, otherwise it
> risks clashing with macro with the same name in other code bases. I
> encountered such issue when trying to add BUILD_BUG_ON to a private
> header in Xen's gnttab library.
>
> Ideally BUILD_BUG_ON should be moved to a private header, but there is
> actually no user of it in mini-os tree, just remove it.
>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> include/lib.h | 9 ---------
> 1 file changed, 9 deletions(-)
>
> diff --git a/include/lib.h b/include/lib.h
> index 39d6a18..e7155e2 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -54,15 +54,6 @@
> #include <xen/event_channel.h>
> #include "gntmap.h"
>
> -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
> -#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); })
> -#define BUILD_BUG_ON_ZERO(cond) \
> - sizeof(struct { _Static_assert(!(cond), "!(" #cond ")"); })
> -#else
> -#define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })
> -#define BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
> -#endif
> -
> #ifdef HAVE_LIBC
> #include <sys/queue.h>
> #include <stdio.h>
> --
> 2.1.4
>
--
Samuel
(03:13:14) <j> bon
(03:13:19) <j> il est tard :p
(03:13:25) <g> c'est l'heure de manger
(03:13:38) <j> hm j'ai mangé à 1h moi, j'ai des horaires raisonnables
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [MINIOS PATCH] lib.h: remove BUILD_BUG_ON
2016-08-12 14:02 ` Samuel Thibault
@ 2016-08-12 15:14 ` Wei Liu
0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2016-08-12 15:14 UTC (permalink / raw)
To: Samuel Thibault, Wei Liu, Minios-devel, Xen-devel
On Fri, Aug 12, 2016 at 04:02:11PM +0200, Samuel Thibault wrote:
> Wei Liu, on Fri 12 Aug 2016 15:01:07 +0100, wrote:
> > BUILD_BUG_ON should not appear in a public-facing header, otherwise it
> > risks clashing with macro with the same name in other code bases. I
> > encountered such issue when trying to add BUILD_BUG_ON to a private
> > header in Xen's gnttab library.
> >
> > Ideally BUILD_BUG_ON should be moved to a private header, but there is
> > actually no user of it in mini-os tree, just remove it.
> >
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>
> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>
Actually some stuff in stubdom depends on mini-os leaking BUILD_BUG_ON,
while some actively work around the leaking of some other macros.
I will hold off putting in this patch for now.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-12 15:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-12 14:01 [MINIOS PATCH] lib.h: remove BUILD_BUG_ON Wei Liu
2016-08-12 14:02 ` Samuel Thibault
2016-08-12 15:14 ` Wei Liu
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).