is already used to control compilation of debugging utilities. Introduced
DEBUG_ASSERTS as a separate switch and as a bonus, you can use assertions
selectively (previously, if you have built the library without assertions,
ASSERT couldn't work anywhere, because assert_failed() was incompatible).
void log_fork(void);
void log_switch(void);
-#ifdef CONFIG_DEBUG
void assert_failed(char *assertion, char *file, int line) NONRET;
+void assert_failed_noinfo(void) NONRET;
+
+#ifdef DEBUG_ASSERTS
#define ASSERT(x) do { if (unlikely(!(x))) assert_failed(#x, __FILE__, __LINE__); } while(0)
#else
-void assert_failed(void) NONRET;
-#define ASSERT(x) do { if (__builtin_constant_p(x) && !(x)) assert_failed(); } while(0)
+#define ASSERT(x) do { if (__builtin_constant_p(x) && !(x)) assert_failed_noinfo(); } while(0)
#endif
#define COMPILE_ASSERT(name,x) typedef char _COMPILE_ASSERT_##name[!!(x)-1]
#endif
}
-#ifdef CONFIG_DEBUG
void
assert_failed(char *assertion, char *file, int line)
{
log(L_FATAL, "Assertion `%s' failed at %s:%d", assertion, file, line);
abort();
}
-#else
+
void
-assert_failed(void)
+assert_failed_noinfo(void)
{
die("Internal error: Assertion failed.");
}
-#endif
static byte *
log_basename(byte *n)