summaryrefslogtreecommitdiff
path: root/libc-parts/assert.h
diff options
context:
space:
mode:
authorneal <neal>2007-12-12 17:46:35 +0000
committerneal <neal>2007-12-12 17:46:35 +0000
commit3c8852ab8a22c0d949423ab59a55bd4746e20326 (patch)
treec444785a0a618a09ad048d249540127ad7b5b43b /libc-parts/assert.h
parent3e507f74c3c12389a24a24345f93d5fbeb7a63f4 (diff)
2007-12-12 Neal H. Walfield <neal@gnu.org>
* assert.h (assertx): New macro.
Diffstat (limited to 'libc-parts/assert.h')
-rw-r--r--libc-parts/assert.h43
1 files changed, 31 insertions, 12 deletions
diff --git a/libc-parts/assert.h b/libc-parts/assert.h
index 3cd8c3c..8ce8e53 100644
--- a/libc-parts/assert.h
+++ b/libc-parts/assert.h
@@ -26,25 +26,44 @@ int printf (const char *fmt, ...);
#ifdef _L4_TEST_ENVIRONMENT
# include_next <assert.h>
+# define assertx(__ax_expr, __ax_fmt, ...) \
+ do \
+ { \
+ if (! (__ax_expr)) \
+ printf (__ax_fmt, ##__VA_ARGS__); \
+ assert (__ax_expr); \
+ } \
+ while (0)
+
#else
# ifndef NDEBUG
#include <l4/thread.h>
-# define assert(expr) \
- do { \
- extern const char program_name[]; \
- if (! (expr)) \
- { \
- printf ("%s (%x):%s:%s:%d: %s failed\n", \
- program_name, l4_myself (), \
- __FILE__, __func__, __LINE__, \
- #expr); \
- for (;;); \
- } \
- } while (0)
+# define assertx(__ax_expr, __ax_fmt, ...) \
+ do { \
+ extern const char program_name[]; \
+ if (! (__ax_expr)) \
+ { \
+ printf ("%s (%x):%s:%s:%d: %s failed", \
+ program_name, l4_myself (), \
+ __FILE__, __func__, __LINE__, \
+ #__ax_expr); \
+ if ((__ax_fmt) && *(__ax_fmt)) \
+ { \
+ printf (": " __ax_fmt, ##__VA_ARGS__); \
+ } \
+ printf ("\n"); \
+ for (;;); \
+ } \
+ } while (0)
+
+# define assert(__a_expr) \
+ assertx (__a_expr, "")
+
# else
# define assert(expr) do { } while (0)
+# define assertx(expr, fmt, ...) do { } while (0)
# endif
# define assert_perror(err) assert(err == 0)