From 78bec10ca517bf457cba0cddfdb3516ee153e36f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 17 Aug 2011 05:33:58 -0400 Subject: [PATCH] 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 --- 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 #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 */ -- 2.34.1