Merge branch 'main' of yibble.dev:bulmanator/ld58

Fixed conflicts
Added "code" directory for include to make it easier to include core
headers
Stopped warnings (probably cl specific)
This commit is contained in:
2025-10-04 21:58:14 +01:00
19 changed files with 366 additions and 20 deletions

View File

@@ -1,5 +1,7 @@
#if OS_WINDOWS
#include "impl/windows/core.c"
#elif OS_LINUX
#include "impl/linux/core.c"
#endif

31
code/os/impl/linux/core.c Normal file
View File

@@ -0,0 +1,31 @@
U64 VM_PageSize() {
U64 result = getpagesize();
return result;
}
U64 VM_AllocationGranularity() {
U64 result = getpagesize();
return result;
}
void *VM_Reserve(U64 size) {
void *addr = mmap(0, size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
void *result = (addr == MAP_FAILED) ? 0 : addr;
return result;
}
B32 VM_Commit(void *base, U64 size) {
B32 result = mprotect(base, size, PROT_READ | PROT_WRITE) == 0;
return result;
}
void VM_Decommit(void *base, U64 size) {
mprotect(base, size, PROT_NONE);
}
void VM_Release(void *base, U64 size) {
munmap(base, size);
}