From 60152880142086a170ba4e169fcb8216b351b090 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Wed, 14 Nov 2012 14:39:07 -0800 Subject: [PATCH] common/config: allow enable/disable ASSERT() easily Now, assertions (ASSERT()) are only checked if the CONFIG_ASSERT macro is defined. We leave this enabled for all builds for now. --- common.h | 5 +++++ config.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/common.h b/common.h index 50410ea7..81b26728 100644 --- a/common.h +++ b/common.h @@ -20,6 +20,7 @@ void assert_hook(void); +#ifdef CONFIG_ASSERT #define ASSERT(expr) \ do { \ if (!(expr)) { \ @@ -30,6 +31,10 @@ do { \ exit(EXIT_FAILURE); \ } \ } while (0) +#else +#define ASSERT(expr) \ + do { } while (0) +#endif /* CONFIG_ASSERT */ #define error_msg(...) fprintf(stderr, "Error: " __VA_ARGS__) diff --git a/config.h b/config.h index 109e8d86..e064e39a 100644 --- a/config.h +++ b/config.h @@ -9,6 +9,10 @@ /* #ifndef CONFIG_DEBUG #define CONFIG_DEBUG #endif + + #ifndef CONFIG_ASSERT + #define CONFIG_ASSERT + #endif */ /** Turn on support for dumping cyclegraphs as dot files at each @@ -44,5 +48,7 @@ /* Size of stack to allocate for a thread. */ #define STACK_SIZE (1024 * 1024) +/** Enable debugging assertions (via ASSERT()) */ +#define CONFIG_ASSERT #endif -- 2.34.1