From b33f369ddea73a7e52109b3dfc3712d226ad8232 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 2 Sep 2024 14:16:40 -0400 Subject: [PATCH] kernel/debug: Add ASSERT_UNREACHABLE. Under KDEBUG it panics, under non-KDEBUG it's __builtin_unreachable, allowing the compiler to optimize things a little more. --- headers/private/kernel/debug.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/headers/private/kernel/debug.h b/headers/private/kernel/debug.h index af9a38156d..927c9b33cc 100644 --- a/headers/private/kernel/debug.h +++ b/headers/private/kernel/debug.h @@ -64,9 +64,11 @@ #if KDEBUG # define ASSERT(x) ASSERT_ALWAYS(x) # define ASSERT_PRINT(x, format, args...) ASSERT_ALWAYS_PRINT(x, format, args) +# define ASSERT_UNREACHABLE() panic("ASSERT UNREACHABLE (%s:%d)", __FILE__, __LINE__) #else # define ASSERT(x) do { } while(0) # define ASSERT_PRINT(x, format, args...) do { } while(0) +# define ASSERT_UNREACHABLE() __builtin_unreachable() #endif #if __GNUC__ >= 5 && !defined(__cplusplus)