From 3c8852ab8a22c0d949423ab59a55bd4746e20326 Mon Sep 17 00:00:00 2001 From: neal Date: Wed, 12 Dec 2007 17:46:35 +0000 Subject: 2007-12-12 Neal H. Walfield * assert.h (assertx): New macro. --- libc-parts/assert.h | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'libc-parts/assert.h') 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 +# define assertx(__ax_expr, __ax_fmt, ...) \ + do \ + { \ + if (! (__ax_expr)) \ + printf (__ax_fmt, ##__VA_ARGS__); \ + assert (__ax_expr); \ + } \ + while (0) + #else # ifndef NDEBUG #include -# 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) -- cgit v1.2.3