aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2015-12-18 21:11:46 +0000
committerFreeArtMan <dos21h@gmail.com>2015-12-18 21:11:46 +0000
commit4c058db338ff00e0e97cea0e985625deb47143cd (patch)
tree5fac68f6535a58819526c8e06d2ec6d58f2abb6d
parent1e2abb48c0e3a735e666124e96090c367bc30544 (diff)
downloaddm-4c058db338ff00e0e97cea0e985625deb47143cd.tar.gz
dm-4c058db338ff00e0e97cea0e985625deb47143cd.zip
Add assert.h for asserting some conditions
-rw-r--r--assert.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/assert.h b/assert.h
new file mode 100644
index 0000000..08d84f5
--- /dev/null
+++ b/assert.h
@@ -0,0 +1,46 @@
+#ifndef __ASSERT_H
+#define __ASSERT_H
+
+/*****************************************************************************
+ * CONFIG ASSERT THINGS
+ *****************************************************************************/
+
+/* enable to enable asserts */
+#define ASSERT_ON
+
+/* exit way */
+#define __EXIT_ABBORT
+
+#ifdef __EXIT_ABBORT
+ #define __EXIT_WAY exit(1);
+#else
+ #define __EXIT_WAY ;
+#endif
+
+
+#ifdef ASSERT_ON
+#define __STR(S) #S
+#define AS_NULL(X) if ((X)==NULL)\
+{\
+ printf("\033[1;34m%s:%d GOTCHA NULL\033[0m\n",__FILE__,__LINE__);\
+ __EXIT_WAY;\
+}
+
+#define AS_RANGE(X,A,B)
+
+#define AS_EXPR(X) if ((X))\
+{\
+ printf("\033[1;34m%s:%d assert:%s\033[0m\n",__FILE__,__LINE__,__STR(X));\
+ __EXIT_WAY;\
+}
+
+#else
+
+#define AS_NULL(X)
+#define AS_RANGE(X,A,B)
+#define AS_EXPR(X)
+
+#endif
+
+#endif
+