diff options
author | Maria Matejka <mq@ucw.cz> | 2020-05-01 15:34:17 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2020-05-01 15:34:17 +0200 |
commit | 048eb2ddf1ee9587d9fa30cbb3f87d6f650a2133 (patch) | |
tree | fdec4c5679a02c901cf2bc92fd81618c6f12d48e /lib/birdlib.h | |
parent | 17de3a023f7bde293892b41bfafe5740c8553fc8 (diff) | |
parent | 59238768b3b05fa134348d2232b42537d0403994 (diff) |
Merge remote-tracking branch 'origin/mq-static-analysis'
Diffstat (limited to 'lib/birdlib.h')
-rw-r--r-- | lib/birdlib.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/birdlib.h b/lib/birdlib.h index 5202b0c8..23036c1b 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -72,6 +72,7 @@ static inline int u64_cmp(u64 i1, u64 i2) #define NORET __attribute__((noreturn)) #define UNUSED __attribute__((unused)) #define PACKED __attribute__((packed)) +#define NONNULL(...) __attribute__((nonnull((__VA_ARGS__)))) #ifndef HAVE_THREAD_LOCAL #define _Thread_local @@ -162,12 +163,23 @@ void debug(const char *msg, ...); /* Printf to debug output */ #define DBG(x, y...) do { } while(0) #endif +#define ASSERT_DIE(x) do { if (!(x)) bug("Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0) + +#define EXPENSIVE_CHECK(x) /* intentionally left blank */ + #ifdef DEBUGGING -#define ASSERT(x) do { if (!(x)) bug("Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0) +#define ASSERT(x) ASSERT_DIE(x) +#define ASSUME(x) ASSERT_DIE(x) +#ifdef ENABLE_EXPENSIVE_CHECKS +#undef EXPENSIVE_CHECK +#define EXPENSIVE_CHECK(x) ASSERT_DIE(x) +#endif #else #define ASSERT(x) do { if (!(x)) log(L_BUG "Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0) +#define ASSUME(x) /* intentionally left blank */ #endif + #ifdef DEBUGGING asm( ".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n" |