]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Introduce ASSERT() and BUILD_BUG_ON()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Jun 2016 12:05:01 +0000 (12:05 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Jun 2016 12:05:01 +0000 (13:05 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/xtf/lib.h

index 183db0f80f532fd01a60e000c0d01813a9db1a2b..ddb9f982cb195c3b6542cf6c66de2d4bfd55f494 100644 (file)
 
 void __noreturn panic(const char *fmt, ...) __printf(1, 2);
 
+#define ASSERT(cond)                                    \
+    do { if ( !(cond) )                                 \
+            panic("ASSERT(%s) failed at %s:%u\n",       \
+                  #cond, __FILE__, __LINE__);           \
+    } while ( 0 )
+
+#define BUILD_BUG_ON(cond)                              \
+    _Static_assert(!cond, "!(" #cond ")")
+
 void heapsort(void *base, size_t nmemb, size_t size,
               int (*compar)(const void *, const void *),
               void (*swap)(void *, void *));