diff options
Diffstat (limited to 'source/base/base.h')
| -rwxr-xr-x | source/base/base.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/base/base.h b/source/base/base.h index 3fe9dca..f908962 100755 --- a/source/base/base.h +++ b/source/base/base.h | |||
| @@ -6,6 +6,11 @@ | |||
| 6 | #define global_variable static | 6 | #define global_variable static |
| 7 | #define local_persist static | 7 | #define local_persist static |
| 8 | 8 | ||
| 9 | #define ARENA_ALIGN (2 * sizeof(void *)) | ||
| 10 | |||
| 11 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) | ||
| 12 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) | ||
| 13 | |||
| 9 | #define unused(x) (void)(x) | 14 | #define unused(x) (void)(x) |
| 10 | #define NIL 0 | 15 | #define NIL 0 |
| 11 | 16 | ||
| @@ -62,3 +67,24 @@ typedef intptr_t smm; | |||
| 62 | #define Len(s) (sizeof(s) - 1) | 67 | #define Len(s) (sizeof(s) - 1) |
| 63 | 68 | ||
| 64 | #endif | 69 | #endif |
| 70 | |||
| 71 | #ifdef BASE_IMPLEMENTATION | ||
| 72 | |||
| 73 | internal inline b8 | ||
| 74 | is_pow(umm x) | ||
| 75 | { | ||
| 76 | return (x & (x - 1)) == 0; | ||
| 77 | } | ||
| 78 | |||
| 79 | internal inline u64 | ||
| 80 | align(u64 pointer, umm alignment) | ||
| 81 | { | ||
| 82 | if ((alignment & (alignment - 1)) == 0) | ||
| 83 | { | ||
| 84 | return pointer; | ||
| 85 | } | ||
| 86 | |||
| 87 | return (pointer + alignment - 1) & ~(alignment - 1); | ||
| 88 | } | ||
| 89 | |||
| 90 | #endif | ||
