aboutsummaryrefslogtreecommitdiff
path: root/include/apos/assert.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-05-21 21:02:17 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-05-21 21:02:17 +0300
commit8da0171e5ca3492cdb34422184a1c96acd0b5165 (patch)
treec125b7286f929c8ff7f8a2b938cec84328e99de4 /include/apos/assert.h
parent836026dbba64793afc0d2591ffdb6fb39b696977 (diff)
downloadkmi-8da0171e5ca3492cdb34422184a1c96acd0b5165.tar.gz
kmi-8da0171e5ca3492cdb34422184a1c96acd0b5165.zip
add status info to memory mappings
+ next up would probably be to start working on process/thread relationships, largely as documented. Still not entirely sure about how I want to handle fork, but I suppose I might figure it out at some point.
Diffstat (limited to 'include/apos/assert.h')
-rw-r--r--include/apos/assert.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/apos/assert.h b/include/apos/assert.h
new file mode 100644
index 0000000..7200fd2
--- /dev/null
+++ b/include/apos/assert.h
@@ -0,0 +1,42 @@
+#ifndef APOS_ASSERT_H
+#define APOS_ASSERT_H
+
+#include <apos/debug.h>
+#include <apos/utils.h>
+
+/* TODO: should this exit or do something explosive like that? */
+#if !defined(DNDEBUG)
+#define catastrophic_assert(x) \
+ do { \
+ if (x) { \
+ err("catastrophic assertion failed: %s\n", QUOTE(x)); \
+ while (1) \
+ ; \
+ } \
+ } while (0);
+
+#define hard_assert(x, r) \
+ do { \
+ if (x) { \
+ warn("hard assertion failed: %s\n", QUOTE(x)); \
+ return r; \
+ } \
+ } while (0);
+
+#define soft_assert(x) \
+ do { \
+ if (x) { \
+ info("soft assertion failed: %s\n", QUOTE(x)); \
+ } \
+ } while (0);
+#else
+#define catastrophic_assert(x)
+#define hard_assert(x, r)
+#define soft_assert(x)
+#endif
+
+/* use when return value doesn't exist, like hard_assert(x,
+ * RETURN_VOID); */
+#define RETURN_VOID
+
+#endif /* APOS_ASSERT_H */