mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:47:34 +00:00
Put assertions behind a DEBUG flag to make it easy to build without them.
This commit is contained in:
parent
f3754b8429
commit
0c898e3c2c
18 changed files with 49 additions and 37 deletions
|
@ -3,12 +3,15 @@
|
|||
#include <Kernel/kstdio.h>
|
||||
#include <Kernel/i386.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
[[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func);
|
||||
|
||||
#define ASSERT(expr) (static_cast<bool>(expr) ? (void)0 : __assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__))
|
||||
#define ASSERT_NOT_REACHED() ASSERT(false)
|
||||
#else
|
||||
#define ASSERT(expr)
|
||||
#define ASSERT_NOT_REACHED() CRASH()
|
||||
#endif
|
||||
#define CRASH() do { asm volatile("ud2"); } while(0)
|
||||
#define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0)
|
||||
//#define ASSERT RELEASE_ASSERT
|
||||
#define ASSERT_NOT_REACHED() ASSERT(false)
|
||||
#define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpu_flags() & 0x200))
|
||||
#define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpu_flags() & 0x200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue