diff options
Diffstat (limited to 'deimos/core/base.h')
-rw-r--r-- | deimos/core/base.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/deimos/core/base.h b/deimos/core/base.h index 1e9b4a9..f24991d 100644 --- a/deimos/core/base.h +++ b/deimos/core/base.h @@ -5,6 +5,8 @@ #define deimos_StaticAssert(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
+#define deimos_Panic(MSG) do { __builtin_trap(); } while (0)
+
#define deimos_NO_COPY(TYPE) \
TYPE(const TYPE&) = delete; \
TYPE& operator=(const TYPE&) = delete;
@@ -56,6 +58,21 @@ struct SourceLocation template<typename T> T Min(T a, T b) { return (a < b) ? a : b; }
template<typename T> T Max(T a, T b) { return (a > b) ? a : b; }
+[[maybe_unused]] static constexpr int64_t Kilobytes = 1024;
+[[maybe_unused]] static constexpr int64_t Megabytes = 1024 * 1024;
+[[maybe_unused]] static constexpr int64_t Gigabytes = 1024 * 1024 * 1024;
+
+constexpr int64_t AlignUp(int64_t value, int64_t align)
+{
+ return __builtin_align_up(value, align);
+}
+
+template<typename T>
+constexpr T* OffsetBytes(T* p, int64_t offset)
+{
+ return std::bit_cast<T*>(std::bit_cast<uintptr_t>(p) + std::bit_cast<uintptr_t>(offset));
+}
+
constexpr void MemoryCopy(void* dst, const void* src, int64_t size)
{
__builtin_memcpy(dst, src, (size_t)size);
|