diff options
-rw-r--r-- | extra/lightbar/simulation.h | 2 | ||||
-rw-r--r-- | include/compile_time_macros.h | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/extra/lightbar/simulation.h b/extra/lightbar/simulation.h index e851f718c5..6028c15dd3 100644 --- a/extra/lightbar/simulation.h +++ b/extra/lightbar/simulation.h @@ -48,6 +48,8 @@ int fake_consolecmd_lightbar(int argc, char *argv[]); #define _BA0_(c, x) _BA1_(c, x) #define BUILD_ASSERT(cond) _BA0_(cond, __LINE__) +#define BUILD_CHECK_INLINE(value, cond_true) ((value) / (!!(cond_true))) + /* Number of elements in an array */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/include/compile_time_macros.h b/include/compile_time_macros.h index 1cc41f4d0e..bf133d60f4 100644 --- a/include/compile_time_macros.h +++ b/include/compile_time_macros.h @@ -15,6 +15,12 @@ #define _BA0_(c, x) _BA1_(c, x) #define BUILD_ASSERT(cond) _BA0_(cond, __LINE__) +/* + * Test an important condition inside code path at run time, taking advantage of + * -Werror=div-by-zero. + */ +#define BUILD_CHECK_INLINE(value, cond_true) ((value) / (!!(cond_true))) + /* Number of elements in an array */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |