common/config: allow enable/disable ASSERT() easily
authorBrian Norris <banorris@uci.edu>
Wed, 14 Nov 2012 22:39:07 +0000 (14:39 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 14 Nov 2012 22:39:07 +0000 (14:39 -0800)
Now, assertions (ASSERT()) are only checked if the CONFIG_ASSERT macro
is defined. We leave this enabled for all builds for now.

common.h
config.h

index 50410ea7e0a1bce920a2bb3ce3b968d602f929de..81b26728d917c0af8c1b26e9d0fa2d28cccb8a5a 100644 (file)
--- a/common.h
+++ b/common.h
@@ -20,6 +20,7 @@
 
 void assert_hook(void);
 
 
 void assert_hook(void);
 
+#ifdef CONFIG_ASSERT
 #define ASSERT(expr) \
 do { \
        if (!(expr)) { \
 #define ASSERT(expr) \
 do { \
        if (!(expr)) { \
@@ -30,6 +31,10 @@ do { \
                exit(EXIT_FAILURE); \
        } \
 } while (0)
                exit(EXIT_FAILURE); \
        } \
 } while (0)
+#else
+#define ASSERT(expr) \
+       do { } while (0)
+#endif /* CONFIG_ASSERT */
 
 #define error_msg(...) fprintf(stderr, "Error: " __VA_ARGS__)
 
 
 #define error_msg(...) fprintf(stderr, "Error: " __VA_ARGS__)
 
index 109e8d86097ab55c545705f0059c544bb01b9738..e064e39a4a2f3a742f7b02d1b1229fa98da2b684 100644 (file)
--- a/config.h
+++ b/config.h
@@ -9,6 +9,10 @@
 /*             #ifndef CONFIG_DEBUG
                #define CONFIG_DEBUG
                #endif
 /*             #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
 */
 
 /** 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)
 
 /* Size of stack to allocate for a thread. */
 #define STACK_SIZE (1024 * 1024)
 
+/** Enable debugging assertions (via ASSERT()) */
+#define CONFIG_ASSERT
 
 #endif
 
 #endif