13#elif OS_LINUX || OS_MAC
21 return VirtualAlloc(0, size, MEM_RESERVE, PAGE_NOACCESS);
22#elif OS_LINUX || OS_MAC
23 void *ptr = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
24 return (ptr == MAP_FAILED) ? 0 : ptr;
32 return VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE) != 0;
33#elif OS_LINUX || OS_MAC
34 return mprotect(ptr, size, PROT_READ | PROT_WRITE) == 0;
42 VirtualFree(ptr, size, MEM_DECOMMIT);
43#elif OS_LINUX || OS_MAC
44 mprotect(ptr, size, PROT_NONE);
45 madvise(ptr, size, MADV_DONTNEED);
54 VirtualFree(ptr, 0, MEM_RELEASE);
55#elif OS_LINUX || OS_MAC
Context detection, compiler abstractions, utility macros, and data structures.
void mem_os_release(void *ptr, usize size)
Releases a reserved virtual address block entirely back to the OS.
b32 mem_os_commit(void *ptr, usize size)
Commits physical RAM to a previously reserved virtual address block.
void * mem_os_reserve(usize size)
Reserves a contiguous block of virtual address space.
void mem_os_decommit(void *ptr, usize size)
Decommits physical RAM, returning it to the OS.
Cross-platform wrappers for OS-level virtual memory management.