|
8 | 8 | // this is needed separately from lwipopts.h
|
9 | 9 | // because it is shared by both sides of glue
|
10 | 10 |
|
| 11 | +#define UNDEBUG 1 // 0 or 1 (1: uassert removed) |
11 | 12 | #define UDEBUG 0 // 0 or 1 (glue debug)
|
12 | 13 | #define UDUMP 0 // 0 or 1 (glue / dump packet)
|
13 | 14 | #define UDEBUGINDEX 0 // 0 or 1 (show debug line number)
|
@@ -81,8 +82,22 @@ int doprint_minus (const char* format, ...) __attribute__ ((format (printf, 1, 2
|
81 | 82 | #define uprint(x...) do { (void)0; } while (0)
|
82 | 83 | #endif
|
83 | 84 |
|
| 85 | +#if UNDEBUG |
| 86 | +#define uassert(assertion...) do { (void)0; } while (0) |
| 87 | +#else // !defined(UNDEBUG) |
| 88 | +#define uassert(assertion...) \ |
| 89 | +do { if ((assertion) == 0) { \ |
| 90 | + static const char assrt[] ICACHE_RODATA_ATTR STORE_ATTR = #assertion " wrong@"; \ |
| 91 | + os_printf_plus(assrt); \ |
| 92 | + static const char assrt_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \ |
| 93 | + os_printf_plus(assrt_file); \ |
| 94 | + static const char assrt_line[] ICACHE_RODATA_ATTR STORE_ATTR = ":%d\n"; \ |
| 95 | + os_printf_plus(assrt_line, __LINE__); \ |
| 96 | + uhalt(); \ |
| 97 | +} } while (0) |
| 98 | +#endif // !defined(UNDEBUG) |
| 99 | + |
84 | 100 | #define uerror(x...) do { doprint(x); } while (0)
|
85 |
| -#define uassert(assertion...) do { if ((assertion) == 0) { os_printf_plus("assert fail: " #assertion " @%s:%d\n", __FILE__, __LINE__); uhalt(); } } while (0) |
86 | 101 | #define uhalt() do { *((int*)0) = 0; /* this triggers gdb */ } while (0)
|
87 | 102 | #define nl() do { uprint("\n"); } while (0)
|
88 | 103 |
|
|
0 commit comments