-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_lib_api.h
42 lines (31 loc) · 949 Bytes
/
core_lib_api.h
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
40
41
42
#pragma once
#include "core_types.h"
// TODO: rename file
////////////////////////////////////////////
/// MEM LAYOUT =============================
// SCRATCH PAD -> || ASSETS || we'll see
// LNR + TEMP == || LNR ? ||
////////////////////////////////////////////
constexpr u64 DEFAULT_ALIGNMNET = 2 * sizeof( void* );
struct mem_arena
{
u8* mem;
u64 size;
u64 currOffset;
};
// TODO: should not expose detail, too low level
struct temp_arena
{
mem_arena* arena;
u64 currOffset;
};
extern u64 FwdAlign( u64 addr, u64 alignment );
bool MemSysInit( u8* baseAddr, u64 size );
void ArenaInit( mem_arena* a, u8* backBuffer, u64 backBuffLen );
u8* LinearAlignAlloc( mem_arena* a, u64 size, u64 alignment = DEFAULT_ALIGNMNET );
void LinearReset( mem_arena* a );
temp_arena TempArenaBegin( mem_arena* a );
void TempArenaEnd( temp_arena temp );
extern mem_arena scratchPad;
extern mem_arena primaryMem;
extern mem_arena debugMem;