aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple/util.h')
-rw-r--r--libmaple/util.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/libmaple/util.h b/libmaple/util.h
index 053731a..63e305d 100644
--- a/libmaple/util.h
+++ b/libmaple/util.h
@@ -32,6 +32,8 @@
#ifndef _UTIL_H_
#define _UTIL_H_
+#include "libmaple.h"
+
#define BIT(shift) (1 << (shift))
#define BIT_MASK_SHIFT(mask, shift) ((mask) << (shift))
@@ -70,9 +72,14 @@ void _fail(const char*, int, const char*);
#endif
-/* Assert for sanity checks, undefine MAPLE_DEBUG to compile
- * out these checks */
-#if MAPLE_DEBUG
+// Asserts for sanity checks, redefine DEBUG_LEVEL in libmaple.h to compile out
+// these checks
+
+#define DEBUG_NONE 0
+#define DEBUG_FAULT 1
+#define DEBUG_ALL 2
+
+#if DEBUG_LEVEL >= DEBUG_ALL
#define ASSERT(exp) \
if (exp) \
{} \
@@ -82,5 +89,15 @@ void _fail(const char*, int, const char*);
#define ASSERT(exp) (void)((0))
#endif
+#if DEBUG_LEVEL >= DEBUG_FAULT
+#define ASSERT_FAULT(exp) \
+ if (exp) \
+ {} \
+ else \
+ _fail(__FILE__, __LINE__, #exp)
+#else
+#define ASSERT_FAULT(exp) (void)((0))
+#endif
+
#endif