uloop: improve edge trigger reliability on mac os x
[project/libubox.git] / utils.h
diff --git a/utils.h b/utils.h
index 065a28b..a86894a 100644 (file)
--- 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