summaryrefslogtreecommitdiff
path: root/osdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep.c')
-rw-r--r--osdep.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/osdep.c b/osdep.c
index 8191b1f717..f824bc1ea2 100644
--- a/osdep.c
+++ b/osdep.c
@@ -61,6 +61,10 @@ void *qemu_malloc(size_t size)
}
#if defined(_WIN32)
+void *qemu_memalign(size_t alignment, size_t size)
+{
+ return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
+}
void *qemu_vmalloc(size_t size)
{
@@ -172,6 +176,22 @@ static void kqemu_vfree(void *ptr)
#endif
+void *qemu_memalign(size_t alignment, size_t size)
+{
+#if defined(_POSIX_C_SOURCE)
+ int ret;
+ void *ptr;
+ ret = posix_memalign(&ptr, alignment, size);
+ if (ret != 0)
+ return NULL;
+ return ptr;
+#elif defined(_BSD)
+ return valloc(size);
+#else
+ return memalign(alignment, size);
+#endif
+}
+
/* alloc shared memory pages */
void *qemu_vmalloc(size_t size)
{