diff --git a/include/sys/debug.h b/include/sys/debug.h index f3f3529a9..9fa2653d4 100644 --- a/include/sys/debug.h +++ b/include/sys/debug.h @@ -145,4 +145,15 @@ do { \ #define VERIFY(x) ASSERT(x) #endif /* NDEBUG */ + +/* + * Compile-time assertion. The condition 'x' must be constant. + */ +#define CTASSERT_GLOBAL(x) _CTASSERT(x, __LINE__) +#define CTASSERT(x) { _CTASSERT(x, __LINE__); } +#define _CTASSERT(x, y) __CTASSERT(x, y) +#define __CTASSERT(x, y) \ + typedef char __attribute__ ((unused)) \ + __compile_time_assertion__ ## y[(x) ? 1 : -1] + #endif /* SPL_DEBUG_H */