diff --git a/src/core/System.cc b/src/core/System.cc index a999694..70117e7 100644 --- a/src/core/System.cc +++ b/src/core/System.cc @@ -1,9 +1,13 @@ #include "System.h" #include #include -#include #include #include +#ifdef PLATFORM_WINDOWS +#include "windows.h" +#else +#include +#endif unsigned long System::page_size; unsigned int System::page_size_log; @@ -63,18 +67,30 @@ bool System::init(char * argv[]) void * System::alloc_pages(int num) { +#ifdef PLATFORM_WINDOWS + return VirtualAlloc( + NULL, + num << System::page_size_log, + MEM_COMMIT | MEM_RESERVE, + PAGE_READWRITE); +#else return mmap( NULL, - num * System::page_size, + num << System::page_size_log, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +#endif } void System::free_pages(void * addr, int num) { +#ifdef PLATFORM_WINDOWS + (void)VirtualFree(addr, 0, MEM_RELEASE); +#else (void)munmap(addr, num << System::page_size_log); +#endif } std::string System::executable_path()