Define OS-dependent qemu_getpagesize()
PATCH 1/1 Define OS-dependent qemu_getpagesize()
Signed-off-by Hollis Blanchard <[email protected]>
qemu/exec.c +1 -10
@@ -239,16 +239,7 @@ static void page_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 + qemu_real_host_page_size =qemu_getpagesize ();if (qemu_host_page_size =0 ) qemu_host_page_size = qemu_real_host_page_size;if (qemu_host_page_size <TARGET_PAGE_SIZE )
qemu/osdep.c +13 -0
@@ -64,6 +64,14 @@ void qemu_vfree(void *ptr)void qemu_vfree (void *ptr) {VirtualFree (ptr,0 ,MEM_RELEASE ); +} + +long qemu_getpagesize (void ) +{ +SYSTEM_INFO system_info; + +GetSystemInfo (&system_info); +return system_info.dwPageSize; }#else
@@ -190,6 +198,11 @@ void *qemu_memalign(size_t alignment, si#endif } +long qemu_getpagesize (void ) +{ +return sysconf (_SC_PAGESIZE); +} +/* alloc shared memory pages */ void *qemu_vmalloc (size_t size) {
qemu/osdep.h +1 -0
@@ -72,6 +72,7 @@ void *qemu_memalign(size_t alignment, sivoid *qemu_memalign (size_t alignment,size_t size);void *qemu_vmalloc (size_t size);void qemu_vfree (void *ptr); +long qemu_getpagesize (void );int qemu_create_pidfile (const char *filename);
Allocate guest memory on host page boundaries.
Signed-off-by Hollis Blanchard <[email protected]>
osdep.c +1 -1
@@ -213,7 +213,7 @@ void *qemu_vmalloc(size_t size)#ifdef _BSDreturn valloc (size);#else -return memalign (4096 , size); +return memalign (qemu_getpagesize (), size);#endif }
Anthony Liguori
AppliedQuoted 2 lines · Hollis Blanchard
Signed-off-by Hollis Blanchard <[email protected]>
Applied both. Thanks.
In the future, please try to give better descriptions. The change might be simple but it's usually hard to infer why a change is needed just from the code unless it's a simple bug fix.
Regards,
Anthony Liguori
Quoted 2 lines · Hollis Blanchard
Signed-off-by Hollis Blanchard <[email protected]>
This breaks the -linux-user build.
Quoted 11 lines
qemu/exec.c +0
-5@@ -239,16 +239,7 @@ static void page_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/exec.c static void page_init(void) · line 245
Quoted 10 lines
qemu/exec.c +1
-5- qemu_real_host_page_size = system_info.dwPageSize; - } -#else - qemu_real_host_page_size =getpagesize (); -#endif + qemu_real_host_page_size =qemu_getpagesize ();if (qemu_host_page_size =0 ) qemu_host_page_size = qemu_real_host_page_size;if (qemu_host_page_size <TARGET_PAGE_SIZE )
This is only used by -linux-user, which does not use osdep.c.
I've reverted this changeset and changed qemu_vmalloc() to just use getpagesize().
Regards,
Anthony Liguori