diff options
author | Gunnar Beutner <gunnar@beutner.name> | 2021-04-11 18:22:48 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-12 22:30:06 +0200 |
commit | 44486e881892d2d59591cf9943c20e4265c6442a (patch) | |
tree | d5f2f9ec71a9749d994b7feb5dc7fd80a19d2313 /Userland/Libraries/LibC | |
parent | d5e125006101e5a8d7c795e4fa893866f0544c2a (diff) | |
download | serenity-44486e881892d2d59591cf9943c20e4265c6442a.zip |
LibC: Turn CRASH() into a function and add noreturn attribute
This way CRASH() can be used in functions that are themselves
marked as noreturn.
Diffstat (limited to 'Userland/Libraries/LibC')
-rw-r--r-- | Userland/Libraries/LibC/assert.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibC/assert.h | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Userland/Libraries/LibC/assert.cpp b/Userland/Libraries/LibC/assert.cpp index d4f99a1a87..2915d43962 100644 --- a/Userland/Libraries/LibC/assert.cpp +++ b/Userland/Libraries/LibC/assert.cpp @@ -53,3 +53,9 @@ void __assertion_failed(const char* msg) } #endif } + +void __crash() +{ + asm volatile("ud2"); + __builtin_unreachable(); +} diff --git a/Userland/Libraries/LibC/assert.h b/Userland/Libraries/LibC/assert.h index 572a35632a..3749e66c43 100644 --- a/Userland/Libraries/LibC/assert.h +++ b/Userland/Libraries/LibC/assert.h @@ -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 |