aboutsummaryrefslogtreecommitdiff
path: root/osdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep.c')
-rw-r--r--osdep.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/osdep.c b/osdep.c
index ba6d5f38a1..eef1ecbecb 100644
--- a/osdep.c
+++ b/osdep.c
@@ -273,15 +273,13 @@ void *get_mmap_addr(unsigned long size)
#else
-#ifdef _BSD
+#ifdef _WIN32
+#include <windows.h>
+#elif defined(_BSD)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
-#ifdef _WIN32
-/* XXX: find a solution to have page aligned data */
-#define memalign(align, size) malloc(size)
-#endif
int qemu_write(int fd, const void *buf, size_t n)
{
@@ -308,7 +306,22 @@ void *qemu_malloc(size_t size)
return malloc(size);
}
-#if defined(USE_KQEMU)
+#if defined(_WIN32)
+
+void *qemu_vmalloc(size_t size)
+{
+ /* FIXME: this is not exactly optimal solution since VirtualAlloc
+ has 64Kb granularity, but at least it guarantees us that the
+ memory is page aligned. */
+ return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void qemu_vfree(void *ptr)
+{
+ VirtualFree(ptr, 0, MEM_RELEASE);
+}
+
+#elif defined(USE_KQEMU)
#include <sys/mman.h>
#include <fcntl.h>