mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
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>
This commit is contained in:
parent
e1c57ab86f
commit
38183310be
6 changed files with 97 additions and 50 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue