Added: Win32 platform layer
This commit is contained in:
parent
55632d07eb
commit
792ddeb80d
|
@ -0,0 +1,34 @@
|
|||
|
||||
internal void *
|
||||
platform_memory_reserve(u64 size)
|
||||
{
|
||||
void *result = VirtualAlloc(0, size, MEM_RESERVE, PAGE_READWRITE);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal b8
|
||||
platform_memory_commit(void *ptr, u64 size)
|
||||
{
|
||||
b32 result = (VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE) != 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void
|
||||
platform_memory_decommit(void *ptr, u64 size)
|
||||
{
|
||||
VirtualFree(ptr, size, MEM_DECOMMIT);
|
||||
};
|
||||
|
||||
internal void
|
||||
platform_memory_release(void *ptr, u64 size)
|
||||
{
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
internal u64
|
||||
platform_get_page_size(void)
|
||||
{
|
||||
SYSTEM_INFO sysinfo = {0};
|
||||
GetSystemInfo(&sysinfo);
|
||||
return sysinfo.dwPageSize;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef WIN32_PLATFORM_H
|
||||
#define WIN32_PLATFORM_H
|
||||
|
||||
#undef internal
|
||||
#include <Windows.h>
|
||||
#define internal static
|
||||
|
||||
//= rhjr: platform memory management
|
||||
|
||||
internal void * platform_memory_reserve(u64 size);
|
||||
internal b8 platform_memory_commit(void *ptr, u64 size);
|
||||
internal void platform_memory_decommit(void *ptr, u64 size);
|
||||
internal void platform_memory_release(void *ptr, u64 size);
|
||||
|
||||
internal u64 platform_get_page_size(void);
|
||||
|
||||
#endif // WIN32_PLATFORM_H
|
Loading…
Reference in New Issue
Block a user