diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-04 13:12:58 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-04 13:12:58 +0100 |
commit | 8b4b684d6da2f2a3a885fc34ace202330e6806c5 (patch) | |
tree | eedb0febd1f49ae07d0080d0876b8b1e568d604c /Kernel | |
parent | 7fe40633235d864c63e144295226426e456aed64 (diff) | |
download | serenity-8b4b684d6da2f2a3a885fc34ace202330e6806c5.zip |
Move assertion failures out-of-line to reduce binary bloat.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/i386.cpp | 7 | ||||
-rw-r--r-- | Kernel/kassert.h | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp index 2554b1b352..22caeb0c43 100644 --- a/Kernel/i386.cpp +++ b/Kernel/i386.cpp @@ -447,3 +447,10 @@ void handleIRQ() s_irqHandler[irq]->handleIRQ(); PIC::eoi(irq); } + +void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func) +{ + asm volatile("cli"); + kprintf("ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func); + asm volatile("hlt"); +} diff --git a/Kernel/kassert.h b/Kernel/kassert.h index cd858bca70..8a13ac1dd5 100644 --- a/Kernel/kassert.h +++ b/Kernel/kassert.h @@ -3,8 +3,10 @@ #include "kprintf.h" #include "i386.h" +void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func) NORETURN; + +#define ASSERT(expr) (static_cast<bool>(expr) ? (void)0 : __assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__)) #define CRASH() do { asm volatile("ud2"); } while(0) -#define ASSERT(x) do { if (!(x)) { asm volatile("cli"); kprintf("ASSERTION FAILED: " #x "\n%s:%u in %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); CRASH(); } } while(0) #define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0) #define ASSERT_NOT_REACHED() ASSERT(false) #define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpuFlags() & 0x200)) |