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 <pbonz...@redhat.com> --- include/sysemu/os-win32.h | 2 ++ translate-all.c | 7 ------- util/oslib-win32.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index bf8523a..af3fbc4 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -89,6 +89,8 @@ static inline void os_setup_post(void) {} void os_set_line_buffering(void); static inline void os_set_proc_name(const char *dummy) {} +size_t getpagesize(void); + #if !defined(EPROTONOSUPPORT) # define EPROTONOSUPPORT EINVAL #endif diff --git a/translate-all.c b/translate-all.c index 6b7b46e..5425d03 100644 --- a/translate-all.c +++ b/translate-all.c @@ -295,14 +295,7 @@ void page_size_init(void) { /* NOTE: we can always suppose that qemu_host_page_size >= TARGET_PAGE_SIZE */ -#ifdef _WIN32 - SYSTEM_INFO system_info; - - GetSystemInfo(&system_info); - qemu_real_host_page_size = system_info.dwPageSize; -#else qemu_real_host_page_size = getpagesize(); -#endif if (qemu_host_page_size == 0) { qemu_host_page_size = qemu_real_host_page_size; } diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 69552f7..ee6bcf1 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); + } +} -- 1.9.3