Files
ld58/code/os/impl/linux/core.c

32 lines
583 B
C
Raw Normal View History

2025-10-04 00:56:55 +01:00
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);
}