about summary refs log tree commit diff
path: root/boot
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2025-07-09 19:06:58 +0200
committerMel <mel@rnrd.eu>2025-07-09 19:10:46 +0200
commitb92890104b5697014e8c9f8767ddb88b4cd21227 (patch)
treed8c56e0556f25146d0a58818a35da5ed770b5c34 /boot
parent7f2d00ae1889e10eea37153002cbf7296fba1993 (diff)
downloadcatskill-b92890104b5697014e8c9f8767ddb88b4cd21227.tar.zst
catskill-b92890104b5697014e8c9f8767ddb88b4cd21227.zip
Add NORETURN to failure functions, add `unreachable`
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot')
-rw-r--r--boot/common.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/boot/common.c b/boot/common.c
index d92684e..ccae087 100644
--- a/boot/common.c
+++ b/boot/common.c
@@ -10,6 +10,7 @@
 
 #pragma once
 
+#include <math.h>
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -17,7 +18,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <math.h>
 
 #define uint8 uint8_t
 #define uint16 uint16_t
@@ -46,6 +46,8 @@
 #define nil NULL
 #define unknown void
 
+#define NORETURN _Noreturn
+
 // ansi escape codes for terminal color and style
 #define ANSI(code) "\33[" code "m"
 
@@ -77,6 +79,7 @@
 // call on irrecoverable failure.
 // prints a very sad, apologetic message for
 // the user and aborts program with failure status.
+NORETURN
 void
 failure(const ascii* message)
 {
@@ -98,6 +101,13 @@ check(bool condition, const ascii* message)
     if (!condition) failure(message);
 }
 
+NORETURN
+void
+unreachable()
+{
+    failure("unreachable code reached");
+}
+
 // for each entry in a linked list.
 #define FOR_EACH(type, cursor, head) for (type cursor = head; cursor != nil; cursor = cursor->next)