summary refs log tree commit diff stats
path: root/util/oslib-win32.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-05-14 17:43:21 +0800
committerMichael S. Tsirkin <mst@redhat.com>2014-06-19 18:44:19 +0300
commit38183310be7af6af5ee60e7c9e9647133a7d11c3 (patch)
tree5b43582a4745b4c604c1366c1f3d47d5aadc0f70 /util/oslib-win32.c
parente1c57ab86f3c4ea6532b51cfecf32770b45f5e7a (diff)
downloadfocaccia-qemu-38183310be7af6af5ee60e7c9e9647133a7d11c3.tar.gz
focaccia-qemu-38183310be7af6af5ee60e7c9e9647133a7d11c3.zip
memory: move preallocation code out of exec.c
So that backends can use it.

Since we need the page size for efficiency, move code to compute it
out of translate-all.c and into util/oslib-win32.c.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'util/oslib-win32.c')
-rw-r--r--util/oslib-win32.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 69552f7ec3..ee6bcf1256 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -350,3 +350,22 @@ gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout)
 
     return num_completed;
 }
+
+size_t getpagesize(void)
+{
+    SYSTEM_INFO system_info;
+
+    GetSystemInfo(&system_info);
+    return system_info.dwPageSize;
+}
+
+void os_mem_prealloc(int fd, char *area, size_t memory)
+{
+    int i;
+    size_t pagesize = getpagesize();
+
+    memory = (memory + pagesize - 1) & -pagesize;
+    for (i = 0; i < memory / pagesize; i++) {
+        memset(area + pagesize * i, 0, 1);
+    }
+}