From f8db0a0820b30aec21942d29bba26af47e1c7c68 Mon Sep 17 00:00:00 2001 From: Fabrice Date: Thu, 16 Apr 2026 18:31:23 +0200 Subject: fixup --- omni/BUILD.bazel | 2 +- omni/assert.h | 29 ----------------------------- omni/log.h | 29 +++++++++++++++++++++++++++++ omni/memory.h | 25 ------------------------- 4 files changed, 30 insertions(+), 55 deletions(-) delete mode 100644 omni/assert.h create mode 100644 omni/log.h delete mode 100644 omni/memory.h diff --git a/omni/BUILD.bazel b/omni/BUILD.bazel index 9278b8f..be1b50c 100644 --- a/omni/BUILD.bazel +++ b/omni/BUILD.bazel @@ -6,7 +6,7 @@ cc_library( ":stdint.h", ":platform.h", ":intrin.h", - ":memory.h" + ":log.h" ], visibility = ["//visibility:public"] ) diff --git a/omni/assert.h b/omni/assert.h deleted file mode 100644 index f3e865b..0000000 --- a/omni/assert.h +++ /dev/null @@ -1,29 +0,0 @@ -#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 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 diff --git a/omni/memory.h b/omni/memory.h deleted file mode 100644 index def1cc0..0000000 --- a/omni/memory.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef OMNI_MEMORY_H -#define OMNI_MEMORY_H - -#include "stdint.h" - -struct Layout { - usize size; - usize align; - - template - constexpr static Layout of(usize n) noexcept { - return Layout{n * sizeof(T), alignof(T)}; - } - - static bool from(usize size, usize align) noexcept { - return Layout{size, align}; - } -}; - -struct Allocator { - virtual u8* allocate(Layout layout) noexcept; - virtual void deallocate(u8* ptr); -}; - -#endif -- cgit v1.2.3