summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/assert.c9
-rw-r--r--src/kernel/panic.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/src/kernel/assert.c b/src/kernel/assert.c
new file mode 100644
index 0000000..9bd1107
--- /dev/null
+++ b/src/kernel/assert.c
@@ -0,0 +1,9 @@
+#include <assert.h>
+#include <kernel/arch/generic.h>
+
+_Noreturn void __badassert(const char *func, const char *file, int line) {
+ /* same format as panics */
+ kprintf("\nan assert PANIC! at the %s (%s:%u)\n", func, file, line);
+ debug_stacktrace();
+ cpu_halt();
+}
diff --git a/src/kernel/panic.h b/src/kernel/panic.h
index 4e591f1..12c0d64 100644
--- a/src/kernel/panic.h
+++ b/src/kernel/panic.h
@@ -1,4 +1,5 @@
#pragma once
+#include <assert.h>
#include <kernel/arch/generic.h>
#include <kernel/util.h>
@@ -12,6 +13,3 @@
#define panic_invalid_state() _panic("invalid state")
#define panic_unimplemented() _panic("unimplemented")
-#define assert(stmt) do { if (!(stmt)) _panic("assert"); } while (0)
-
-#undef panic