From: Paolo Bonzini Date: Wed, 17 Aug 2011 09:33:58 +0000 (-0400) Subject: api: reimplement BUILD_BUG_ON in compiler.h X-Git-Tag: v0.6.5~51^2~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=78bec10ca517bf457cba0cddfdb3516ee153e36f;p=userspace-rcu.git api: reimplement BUILD_BUG_ON in compiler.h Even though it's just two lines of code, I'm reimplementing it cleanly out of paranoia. Signed-off-by: Paolo Bonzini Signed-off-by: Mathieu Desnoyers --- 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 #include -#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 */