-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.h
More file actions
39 lines (32 loc) · 869 Bytes
/
Copy pathbase.h
File metadata and controls
39 lines (32 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef BASE_H
#define BASE_H
#include<stdio.h>
#include<stdint.h>
#include<string.h>
#include<stdbool.h>
#include <math.h>
// short form for commonly used types
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef float f32;
typedef i8 b8;
typedef i32 b32;
// the actual arena structure
typedef struct{
u64 reserve_size, commit_size, pos, commit_pos;
} mem_arena;
// type agnostic minimum and maximum
#define MIN(a, b) (((a)<(b)) ? (a) : (b))
#define MAX(a, b) (((a)>(b)) ? (a) : (b))
// get how many Bytes in the bigger units like KiB, MiB, GiB
#define KiB(n) ((u64)(n) << 10)
#define MiB(n) ((u64)(n) << 20)
#define GiB(n) ((u64)(n) << 30)
#define ALIGN_UP_POWER_2(n, p) (((u64)(n) + (u64)(p) - 1)&(~((u64)(p)-1)))
#endif // BASE_H