diff --git a/AK/BumpAllocator.h b/AK/BumpAllocator.h index 21348a4df0c..862217f4976 100644 --- a/AK/BumpAllocator.h +++ b/AK/BumpAllocator.h @@ -10,7 +10,12 @@ #include #include #include -#include +#if defined(AK_OS_WINDOWS) +# include +# include +#else +# include +#endif namespace AK { @@ -73,7 +78,11 @@ public: } if constexpr (use_mmap) { +#if defined(AK_OS_WINDOWS) + VirtualFree((LPVOID)chunk, m_chunk_size, MEM_RELEASE); +#else munmap((void*)chunk, m_chunk_size); +#endif } else { kfree_sized((void*)chunk, m_chunk_size); } @@ -106,10 +115,19 @@ protected: #ifdef AK_OS_SERENITY new_chunk = serenity_mmap(nullptr, m_chunk_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_RANDOMIZED | MAP_PRIVATE, 0, 0, m_chunk_size, "BumpAllocator Chunk"); #else +# if defined(AK_OS_WINDOWS) + new_chunk = VirtualAlloc(NULL, m_chunk_size, MEM_COMMIT, PAGE_READWRITE); +# else new_chunk = mmap(nullptr, m_chunk_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); +# endif #endif +#if defined(AK_OS_WINDOWS) + if (new_chunk == NULL) + return false; +#else if (new_chunk == MAP_FAILED) return false; +#endif } else { new_chunk = kmalloc(m_chunk_size); if (!new_chunk)