summaryrefslogtreecommitdiff
path: root/kernel/libc
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/libc')
-rw-r--r--kernel/libc/exit/assert.c4
-rw-r--r--kernel/libc/include/assert.h8
2 files changed, 9 insertions, 3 deletions
diff --git a/kernel/libc/exit/assert.c b/kernel/libc/exit/assert.c
index b48773a..3351249 100644
--- a/kernel/libc/exit/assert.c
+++ b/kernel/libc/exit/assert.c
@@ -1,12 +1,12 @@
#include <assert.h>
#include <log.h>
#include <stdio.h>
-#include <log.h>
-void aFailed(char *f, int l) {
+__attribute__((__noreturn__)) void aFailed(char *f, int l) {
kprintf("Assert failed\n");
kprintf("%s : %d\n", f, l);
dump_backtrace(10);
+ asm("hlt");
for (;;)
;
}
diff --git a/kernel/libc/include/assert.h b/kernel/libc/include/assert.h
index 90a0be4..d6525f0 100644
--- a/kernel/libc/include/assert.h
+++ b/kernel/libc/include/assert.h
@@ -1,10 +1,16 @@
#include <log.h>
#include <stdio.h>
+// This infinite loop is needed for GCC to understand that
+// aFailed does not return. No clue why the attribute does
+// help solve the issue.
#define assert(expr) \
{ \
- if (!(expr)) \
+ if (!(expr)) { \
aFailed(__FILE__, __LINE__); \
+ for (;;) \
+ ; \
+ } \
}
#define ASSERT_BUT_FIXME_PROPOGATE(expr) \