linux/bug.h: make BUILD_BUG_ON generate compile-time error

From: Daniel Santos
Date: Mon Jun 04 2012 - 07:13:41 EST


---
include/linux/bug.h | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/linux/bug.h b/include/linux/bug.h
index 72961c3..d35d6e9 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -48,11 +48,12 @@ struct pt_regs;
#ifndef __OPTIMIZE__
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
#else
-extern int __build_bug_on_failed;
-#define BUILD_BUG_ON(condition) \
- do { \
- ((void)sizeof(char[1 - 2*!!(condition)])); \
- if (condition) __build_bug_on_failed = 1; \
+#define BUILD_BUG_ON(condition) \
+ do { \
+ extern void __build_bug_on_failed(void) \
+ __compiletime_error("BUILD_BUG_ON failed: " #condition);\
+ ((void)sizeof(char[1 - 2*!!(condition)])); \
+ if (condition) __build_bug_on_failed(); \
} while(0)
#endif

--
1.7.3.4


--------------070906080407090309060403--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/