windows support for kqemu (Filip Navara)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1366 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/osdep.c b/osdep.c
index ba6d5f3..eef1ecb 100644
--- a/osdep.c
+++ b/osdep.c
@@ -273,15 +273,13 @@
 
 #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 @@
     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>