Skip to content

Commit

Permalink
LibC: Turn CRASH() into a function and add noreturn attribute
Browse files Browse the repository at this point in the history
This way CRASH() can be used in functions that are themselves
marked as noreturn.
  • Loading branch information
gunnarbeutner authored and awesomekling committed Apr 12, 2021
1 parent d5e1250 commit 44486e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Userland/Libraries/LibC/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ void __assertion_failed(const char* msg)
}
#endif
}

void __crash()
{
asm volatile("ud2");
__builtin_unreachable();
}
7 changes: 3 additions & 4 deletions Userland/Libraries/LibC/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ __attribute__((noreturn)) void __assertion_failed(const char* msg);
# define VERIFY_NOT_REACHED() CRASH()
#endif

#define CRASH() \
do { \
asm volatile("ud2"); \
} while (0)
__attribute__((noreturn)) void __crash();

#define CRASH() __crash()
#define VERIFY assert
#define TODO VERIFY_NOT_REACHED

Expand Down

0 comments on commit 44486e8

Please sign in to comment.