X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=utils.h;h=a86894aa57b1ec25935771dbe828c5a11837a264;hb=f1735cd94e55a3547254bd7d5f3c7c8cd79dac59;hp=065a28b343f9e29e7cb4fe53d49313ff539fb972;hpb=9c8ab5d64cb1bfc6f8a235af5913ed3537c38e2a;p=project%2Flibubox.git diff --git a/utils.h b/utils.h index 065a28b..a86894a 100644 --- a/utils.h +++ b/utils.h @@ -30,7 +30,7 @@ * the last argument needs to be a NULL pointer */ -#define calloc_a(len, ...) __calloc_a(len, ##__VA_ARGS__) +#define calloc_a(len, ...) __calloc_a(len, ##__VA_ARGS__, NULL) void *__calloc_a(size_t len, ...); @@ -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