diff options
Diffstat (limited to 'libc/inc/assert.h')
-rw-r--r-- | libc/inc/assert.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libc/inc/assert.h b/libc/inc/assert.h index a553444..758c91b 100644 --- a/libc/inc/assert.h +++ b/libc/inc/assert.h @@ -6,17 +6,22 @@ #include <print.h> #ifdef kernel +#include <proc.h> #define assert(exp) \ if (!(exp)) { \ printf("%s:%d: %s: Assertion '%s' failed\n", __FILE__, __LINE__, __func__, #exp); \ - __asm__ volatile("cli\nhlt"); \ + struct proc *proc = proc_current(); \ + if (proc) \ + proc_exit(proc, 1); \ + else \ + __asm__ volatile("cli\nhlt"); \ } #elif defined(userspace) #include <sys.h> #define assert(exp) \ if (!(exp)) { \ printf("%s:%d: %s: Assertion '%s' failed\n", __FILE__, __LINE__, __func__, #exp); \ - sys0(SYS_LOOP); \ + sys1(SYS_EXIT, 1); \ } #else #error "No lib target specified. Please use -Dkernel or -Duserspace" |