aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-11 23:06:45 +0200
committerMax Kellermann <max@duempel.org>2014-08-11 23:06:45 +0200
commitc597538b4023fd1f40bbb66f79caa508b223a8f2 (patch)
treef77433b0db2f1f57250632c60c58420b16d4803a
parent43f964e28df15d724c7ee7fd5e15b57ae6ce2ef6 (diff)
downloadmpd-c597538b4023fd1f40bbb66f79caa508b223a8f2.tar.gz
mpd-c597538b4023fd1f40bbb66f79caa508b223a8f2.tar.xz
mpd-c597538b4023fd1f40bbb66f79caa508b223a8f2.zip
util/HugeAllocator: implement on Windows
-rw-r--r--src/util/HugeAllocator.hxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util/HugeAllocator.hxx b/src/util/HugeAllocator.hxx
index 70d54daa2..e85f936dc 100644
--- a/src/util/HugeAllocator.hxx
+++ b/src/util/HugeAllocator.hxx
@@ -63,6 +63,28 @@ HugeFree(void *p, size_t size);
void
HugeDiscard(void *p, size_t size);
+#elif defined(WIN32)
+#include <windows.h>
+
+gcc_malloc
+static inline void *
+HugeAllocate(size_t size)
+{
+ return VirtualAlloc(nullptr, size, MEM_LARGE_PAGES, PAGE_READWRITE);
+}
+
+static inline void
+HugeFree(void *p, gcc_unused size_t size)
+{
+ VirtualFree(p, 0, MEM_RELEASE);
+}
+
+static inline void
+HugeDiscard(void *p, size_t size)
+{
+ VirtualAlloc(p, size, MEM_RESET, PAGE_NOACCESS);
+}
+
#else
/* not Linux: fall back to standard C calls */