diff options
| author | nasr <nsrddyn@gmail.com> | 2026-03-26 22:35:30 +0100 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2026-04-13 17:24:42 +0200 |
| commit | dd5586abec207dd4acd16d51ce0d392c03e5e957 (patch) | |
| tree | e56573f49ebb2a3236a39148842dc80bde5a286d /source/base/base_mem.h | |
feature(main): initmain
feature(main): init
Diffstat (limited to 'source/base/base_mem.h')
| -rw-r--r-- | source/base/base_mem.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/base/base_mem.h b/source/base/base_mem.h new file mode 100644 index 0000000..2778fce --- /dev/null +++ b/source/base/base_mem.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | #ifndef BASE_MEM_H | ||
| 2 | #define BASE_MEM_H | ||
| 3 | |||
| 4 | #define ARENA_ALIGN (2 * sizeof(void *)) | ||
| 5 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) | ||
| 6 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) | ||
| 7 | |||
| 8 | internal inline b8 | ||
| 9 | is_pow(umm x) | ||
| 10 | { | ||
| 11 | return (x & (x - 1)) == 0; | ||
| 12 | } | ||
| 13 | |||
| 14 | internal inline u64 | ||
| 15 | align(u64 pointer, umm alignment) | ||
| 16 | { | ||
| 17 | if ((alignment & (alignment - 1)) == 0) | ||
| 18 | { | ||
| 19 | return pointer; | ||
| 20 | } | ||
| 21 | |||
| 22 | return (pointer + alignment - 1) & ~(alignment - 1); | ||
| 23 | } | ||
| 24 | |||
| 25 | |||
| 26 | #endif | ||
