From 89197a0b077d2f797a8215e936eca2ab0958d26d Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sat, 6 Sep 2025 00:13:24 +0200 Subject: [PATCH] assert.h: assert & assert_msg panic macros --- kern/libkern/assert.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 kern/libkern/assert.h diff --git a/kern/libkern/assert.h b/kern/libkern/assert.h new file mode 100644 index 0000000..7cb7a27 --- /dev/null +++ b/kern/libkern/assert.h @@ -0,0 +1,15 @@ +#include + +#define assert(cond) \ + do { \ + if (!(cond)) { \ + PANIC("Assertion failed: %s\n", #cond); \ + } \ + } while (0) + +#define assert_msg(cond, fmt, ...) \ + do { \ + if (!(cond)) { \ + PANIC("Assertion failed: %s: " fmt, #cond, ##__VA_ARGS__); \ + } \ + } while (0)