All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] libs/gnttab: introduce XENGNTTAB_BUILD_BUG_ON
@ 2016-08-04  9:42 Wei Liu
  2016-09-19 11:41 ` Ian Jackson
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2016-08-04  9:42 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ian Jackson, Wei Liu, Paulina Szubarczyk

The implementation is taken from libxc.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>

I could have put it in a header file accessible to all libraries under
libs but this construct is only relevant to xengnttab library at the
moment so it's put under gnttab/private.h. It can be easily moved to
a common place when other libraries under libs require it.

This patch is necessary to unblock Paulina on her gnttab copy work.
---
 tools/libs/gnttab/private.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/libs/gnttab/private.h b/tools/libs/gnttab/private.h
index d286c86..2bdc0f2 100644
--- a/tools/libs/gnttab/private.h
+++ b/tools/libs/gnttab/private.h
@@ -4,6 +4,13 @@
 #include <xentoollog.h>
 #include <xengnttab.h>
 
+/* Force a compilation error if condition is true */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#define XENGNTTAB_BUILD_BUG_ON(p) ({ _Static_assert(!(p), "!(" #p ")"); })
+#else
+#define XENGNTTAB_BUILD_BUG_ON(p) ((void)sizeof(struct { int:-!!(p); }))
+#endif
+
 struct xengntdev_handle {
     xentoollog_logger *logger, *logger_tofree;
     int fd;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2016-09-19 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-04  9:42 [PATCH v2] libs/gnttab: introduce XENGNTTAB_BUILD_BUG_ON Wei Liu
2016-09-19 11:41 ` Ian Jackson
2016-09-19 12:52   ` Wei Liu
2016-09-19 13:49     ` Ian Jackson
2016-09-19 13:55       ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.