Added memory arena

Fixed frames in flight validation error in vulkan
Added some utility macros
Added function decorator macros
Added some consolidation headers/code include files
This commit is contained in:
2025-10-04 00:46:26 +01:00
parent 9f2ef576b9
commit 5f07239374
13 changed files with 429 additions and 12 deletions

View File

@@ -1,9 +1,17 @@
#if !defined(LD_CORE_MACROS_H_)
#define LD_CORE_MACROS_H_
#include <assert.h>
#define Assert(exp) assert(exp)
#define ArraySize(x) (sizeof(x) / sizeof((x)[0]))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Clamp(min, x, max) (Min(Max(min, x), max))
#define Clamp01(x) Clamp(0, x, 1)
#define cast(x) (x)
#define _Glue(a, b) a##b
#define _Stringify(x) #x
@@ -11,5 +19,30 @@
#define Glue(a, b) _Glue(a, b)
#define Stringify(x) _Stringify(x)
#if LANG_CPP
#define Alignof(x) alignof(x)
#else
#define Alignof(x) _Alignof(x)
#endif
// Singly linked lists (named members)
//
#define SLL_EnqueueN(h, t, n, next) (((h) == 0) ? ((h) = (t) = (n), (n)->next = 0) : ((t)->next = (n), (t) = (n), (n)->next = 0))
#define SLL_EnqueueFrontN(h, t, n, next) (((h) == 0) ? ((h) = (t) = (n), (n)->next = 0) : ((n)->next = (h), (h) = (n)))
#define SLL_DequeueN(h, t, next) ((h) == (t) ? ((h) = 0, (t) = 0) : ((h) = (h)->next))
#define SLL_PushN(h, n, next) ((n)->next = (h), (h) = (n))
#define SLL_PopN(h, next) (((h) != 0) ? (h) = (h)->next : 0)
#define function static
#define internal static
#define global_var static
#define local_persist static
#if COMPILER_CL
#define thread_var __declspec(thread)
#else
#define thread_var __thread
#endif
#endif // LD_CORE_MACROS_H_