From f8db0a0820b30aec21942d29bba26af47e1c7c68 Mon Sep 17 00:00:00 2001 From: Fabrice Date: Thu, 16 Apr 2026 18:31:23 +0200 Subject: fixup --- omni/log.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 omni/log.h (limited to 'omni/log.h') diff --git a/omni/log.h b/omni/log.h new file mode 100644 index 0000000..f3e865b --- /dev/null +++ b/omni/log.h @@ -0,0 +1,29 @@ +#ifndef OMNI_ASSERT_H +#define OMNI_ASSERT_H + +#include +#include + +#include "stdint.h" + +template +[[noreturn]] void panic_impl(const char* file, u32 line, const char* fmt, + Args arguments) { + fprintf(stderr, "PANIC at %s:%d: ", file, line); + fprintf(stderr, fmt, args...); + fputs("\n", stderr); + abort(); +} + +#define panic(...) panic_impl(__FILE__, __LINE__, __VA_ARGS__) + +#ifndef NDEBUG +# define assert(cond) \ + do { \ + if (!(cond)) panic("assertion failed: %s", #cond); \ + } while (0); +#else +# define assert(cond) unused(cond) +#endif + +#endif -- cgit v1.2.3