[ltt-dev] [PATCH v3 2/2] api: reimplement BUILD_BUG_ON in compiler.h
Paolo Bonzini
pbonzini at redhat.com
Wed Aug 17 04:36:28 EDT 2011
Even though it's just two lines of code, I'm reimplementing it
cleanly out of paranoia.
Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
---
tests/api.h | 4 +---
urcu/compiler.h | 3 +++
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/api.h b/tests/api.h
index 49c96f7..c5d716f 100644
--- a/tests/api.h
+++ b/tests/api.h
@@ -27,11 +27,9 @@
* to redistribute under later versions of GPL might not be available.
*/
+#include <urcu/compiler.h>
#include <urcu/arch.h>
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
-
/*
* Machine parameters.
*/
diff --git a/urcu/compiler.h b/urcu/compiler.h
index 54904cc..489677b 100644
--- a/urcu/compiler.h
+++ b/urcu/compiler.h
@@ -61,4 +61,7 @@
(type *)((char *)__ptr - offsetof(type, member)); \
})
+#define CAA_BUILD_BUG_ON_ZERO(cond) (sizeof(struct { int:-!!(cond); }))
+#define CAA_BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
+
#endif /* _URCU_COMPILER_H */
--
1.7.6
More information about the lttng-dev
mailing list