diff options
| author | Fabrice <fabrice@schaub-dev.xyz> | 2026-04-16 17:01:13 +0200 |
|---|---|---|
| committer | Fabrice <fabrice@schaub-dev.xyz> | 2026-04-16 17:01:13 +0200 |
| commit | 4748386b4e22a5bfe0c4d3f0d65c43f37e09536e (patch) | |
| tree | 5fc64c585470ea15f93b4168ef846a447e2e0538 /omni/assert.h | |
| parent | 70dfff41ce5d50264ca419724c038e8acc8df753 (diff) | |
progress on the allocator
Diffstat (limited to 'omni/assert.h')
| -rw-r--r-- | omni/assert.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/omni/assert.h b/omni/assert.h new file mode 100644 index 0000000..f3e865b --- /dev/null +++ b/omni/assert.h @@ -0,0 +1,29 @@ +#ifndef OMNI_ASSERT_H +#define OMNI_ASSERT_H + +#include <cstdio> +#include <cstdlib> + +#include "stdint.h" + +template <typename... Args> +[[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 |
