Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-01 19:10:27 +0400
committerFelix Fietkau <nbd@openwrt.org>2013-01-01 19:10:44 +0400
commit7157c3a4df70965c5652f957ebdbbe116260d480 (patch)
tree970eaff01656a94e59786a1a68af279e035f21f6 /utils.h
parent7a117988d9f75c7ccf7eeca7b59e61a4b5b5c3e4 (diff)
utils: add BUILD_BUG_ON (similar to the one in the linux kernel)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/utils.h b/utils.h
index d1a6cd3..a86894a 100644
--- a/utils.h
+++ b/utils.h
@@ -38,4 +38,18 @@ void *__calloc_a(size_t len, ...);
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
+#define __BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+
+#ifdef __OPTIMIZE__
+extern int __BUILD_BUG_ON_CONDITION_FAILED;
+#define BUILD_BUG_ON(condition) \
+ do { \
+ __BUILD_BUG_ON(condition); \
+ if (condition) \
+ __BUILD_BUG_ON_CONDITION_FAILED = 1; \
+ } while(0)
+#else
+#define BUILD_BUG_ON __BUILD_BUG_ON
+#endif
+
#endif