[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] mini-os: add BUILD_BUG_ON()



commit 4f1f414ab5e93e73bc42435ae10e2ecae6cc5e5a
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Jul 3 16:37:22 2014 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jul 3 16:37:22 2014 +0200

    mini-os: add BUILD_BUG_ON()
    
    Just copy over what the hypervisor currently uses (comments dropped due
    to being of unknown origin; the implementation was done by me anyway).
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
    Acked-by: Tim Deegan <tim@xxxxxxx>
---
 extras/mini-os/include/lib.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/extras/mini-os/include/lib.h b/extras/mini-os/include/lib.h
index 670c14f..62836c7 100644
--- a/extras/mini-os/include/lib.h
+++ b/extras/mini-os/include/lib.h
@@ -54,6 +54,15 @@
 #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>
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.