X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=utils.h;h=41f39ec690f25f408bcb92c8098b55628c22291e;hp=065a28b343f9e29e7cb4fe53d49313ff539fb972;hb=f15ceb8ced4a88f3a4c30f6b45cf52691f4c1a5f;hpb=9c8ab5d64cb1bfc6f8a235af5913ed3537c38e2a diff --git a/utils.h b/utils.h index 065a28b..41f39ec 100644 --- a/utils.h +++ b/utils.h @@ -20,6 +20,8 @@ #define __LIBUBOX_UTILS_H #include +#include +#include /* * calloc_a(size_t len, [void **addr, size_t len,...], NULL) @@ -30,7 +32,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 +40,27 @@ 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 + +#ifdef __APPLE__ + +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 + +void clock_gettime(int type, struct timespec *tv); + +#endif + #endif