summaryrefslogtreecommitdiff
path: root/kernel/include/lib/klib.h
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-10 23:21:40 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-10 23:23:00 -0400
commitc5cbf5d747c0d8249c162e075863ee55a804b6db (patch)
treeace128dfee9221e2e6efdb0a05914684278d6dfd /kernel/include/lib/klib.h
parentfix random ampersand? how did i do that (diff)
downloadcomus-c5cbf5d747c0d8249c162e075863ee55a804b6db.tar.gz
comus-c5cbf5d747c0d8249c162e075863ee55a804b6db.tar.bz2
comus-c5cbf5d747c0d8249c162e075863ee55a804b6db.zip
make lib betterer
Diffstat (limited to 'kernel/include/lib/klib.h')
-rw-r--r--kernel/include/lib/klib.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/kernel/include/lib/klib.h b/kernel/include/lib/klib.h
index 3afe925..cb1de01 100644
--- a/kernel/include/lib/klib.h
+++ b/kernel/include/lib/klib.h
@@ -185,13 +185,20 @@ char *btoa(size_t bytes, char *buf);
*/
unsigned int bound(unsigned int min, unsigned int value, unsigned int max);
+#define __PANIC_STR(x) __PANIC_STR2(x)
+#define __PANIC_STR2(x) #x
+
+#define panic(...) __panic(__PANIC_STR(__LINE__), __FILE__, __VA_ARGS__)
+#define assert(val, ...) do { if (!(val)) { panic(__VA_ARGS__); } } while (0)
+
/**
* Abort the kernel with a given message.
*
* @param format - the format string
* @param ... - variable args for the format
*/
-__attribute__((noreturn)) void panic(const char *format, ...);
+__attribute__((noreturn, format(printf, 3, 4)))
+void __panic(const char *line, const char *file, const char *format, ...);
/**
* Fill dst with a stack trace consisting of return addresses in order