aboutsummaryrefslogtreecommitdiff
path: root/util/oslib-posix.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-03-23 19:57:22 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2022-04-06 10:50:38 +0200
commit8e3b0cbb7212a1e5707ed2d4c26b4e3d2483768d (patch)
treefe73195ef7adcea2745f6f31502264157be476c2 /util/oslib-posix.c
parentb307e5052d5c09a2bb71b1670c14ca4fc44ea33f (diff)
Replace qemu_real_host_page variables with inlined functions
Replace the global variables with inlined helper functions. getpagesize() is very likely annotated with a "const" function attribute (at least with glibc), and thus optimization should apply even better. This avoids the need for a constructor initialization too. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220323155743.1585078-12-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r--util/oslib-posix.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 2ebfb75057..577c855612 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -767,7 +767,7 @@ void *qemu_alloc_stack(size_t *sz)
#ifdef CONFIG_DEBUG_STACK_USAGE
void *ptr2;
#endif
- size_t pagesz = qemu_real_host_page_size;
+ size_t pagesz = qemu_real_host_page_size();
#ifdef _SC_THREAD_STACK_MIN
/* avoid stacks smaller than _SC_THREAD_STACK_MIN */
long min_stack_sz = sysconf(_SC_THREAD_STACK_MIN);
@@ -829,7 +829,7 @@ void qemu_free_stack(void *stack, size_t sz)
unsigned int usage;
void *ptr;
- for (ptr = stack + qemu_real_host_page_size; ptr < stack + sz;
+ for (ptr = stack + qemu_real_host_page_size(); ptr < stack + sz;
ptr += sizeof(uint32_t)) {
if (*(uint32_t *)ptr != 0xdeadbeaf) {
break;
@@ -927,10 +927,10 @@ size_t qemu_get_host_physmem(void)
#ifdef _SC_PHYS_PAGES
long pages = sysconf(_SC_PHYS_PAGES);
if (pages > 0) {
- if (pages > SIZE_MAX / qemu_real_host_page_size) {
+ if (pages > SIZE_MAX / qemu_real_host_page_size()) {
return SIZE_MAX;
} else {
- return pages * qemu_real_host_page_size;
+ return pages * qemu_real_host_page_size();
}
}
#endif