summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC
diff options
context:
space:
mode:
authorGunnar Beutner <gunnar@beutner.name>2021-04-11 18:22:48 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-12 22:30:06 +0200
commit44486e881892d2d59591cf9943c20e4265c6442a (patch)
treed5f2f9ec71a9749d994b7feb5dc7fd80a19d2313 /Userland/Libraries/LibC
parentd5e125006101e5a8d7c795e4fa893866f0544c2a (diff)
downloadserenity-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.cpp6
-rw-r--r--Userland/Libraries/LibC/assert.h7
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