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:
3
code/os/core.c
Normal file
3
code/os/core.c
Normal file
@@ -0,0 +1,3 @@
|
||||
#if OS_WINDOWS
|
||||
#include "impl/windows/core.c"
|
||||
#endif
|
||||
14
code/os/core.h
Normal file
14
code/os/core.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#if !defined(LD_OS_CORE_H_)
|
||||
#define LD_OS_CORE_H_
|
||||
|
||||
// Virtual memory
|
||||
|
||||
function U64 VM_PageSize();
|
||||
function U64 VM_AllocationGranularity();
|
||||
|
||||
function void *VM_Reserve(U64 size);
|
||||
function B32 VM_Commit(void *base, U64 size);
|
||||
function void VM_Decommit(void *base, U64 size);
|
||||
function void VM_Release(void *base, U64 size);
|
||||
|
||||
#endif // LD_OS_CORE_H_
|
||||
38
code/os/impl/windows/core.c
Normal file
38
code/os/impl/windows/core.c
Normal file
@@ -0,0 +1,38 @@
|
||||
// Virtual memory
|
||||
|
||||
U64 VM_PageSize() {
|
||||
SYSTEM_INFO info;
|
||||
GetSystemInfo(&info);
|
||||
|
||||
U64 result = info.dwPageSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
U64 VM_AllocationGranularity() {
|
||||
SYSTEM_INFO info;
|
||||
GetSystemInfo(&info);
|
||||
|
||||
U64 result = info.dwAllocationGranularity;
|
||||
return result;
|
||||
}
|
||||
|
||||
void *VM_Reserve(U64 size) {
|
||||
void *result = VirtualAlloc(0, size, MEM_RESERVE, PAGE_NOACCESS);
|
||||
return result;
|
||||
}
|
||||
|
||||
B32 VM_Commit(void *base, U64 size) {
|
||||
B32 result = VirtualAlloc(base, size, MEM_COMMIT, PAGE_READWRITE) != 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
void VM_Decommit(void *base, U64 size) {
|
||||
VirtualFree(base, size, MEM_DECOMMIT);
|
||||
}
|
||||
|
||||
void VM_Release(void *base, U64 size) {
|
||||
(void) size;
|
||||
|
||||
VirtualFree(base, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user