util: Use qemu_getauxval in linux qemu_cache_utils_init

With this we no longer pass down envp, and thus all systems can have
the same void prototype.  So also eliminate a useless thunk.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Richard Henderson 2013-06-10 09:05:09 -07:00
parent c9baa30f42
commit 664d2c4458
4 changed files with 24 additions and 35 deletions

View File

@ -12,7 +12,7 @@ struct qemu_cache_conf {
extern struct qemu_cache_conf qemu_cache_conf; extern struct qemu_cache_conf qemu_cache_conf;
void qemu_cache_utils_init(char **envp); void qemu_cache_utils_init(void);
/* mildly adjusted code from tcg-dyngen.c */ /* mildly adjusted code from tcg-dyngen.c */
static inline void flush_icache_range(uintptr_t start, uintptr_t stop) static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
@ -38,7 +38,7 @@ static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
} }
#else #else
#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) #define qemu_cache_utils_init() do { } while (0)
#endif #endif
#endif /* QEMU_CACHE_UTILS_H */ #endif /* QEMU_CACHE_UTILS_H */

View File

@ -3702,7 +3702,7 @@ int main(int argc, char **argv, char **envp)
module_call_init(MODULE_INIT_QOM); module_call_init(MODULE_INIT_QOM);
qemu_init_auxval(envp); qemu_init_auxval(envp);
qemu_cache_utils_init(envp); qemu_cache_utils_init();
if ((envlist = envlist_create()) == NULL) { if ((envlist = envlist_create()) == NULL) {
(void) fprintf(stderr, "Unable to allocate envlist\n"); (void) fprintf(stderr, "Unable to allocate envlist\n");

View File

@ -1,3 +1,4 @@
#include "qemu-common.h"
#include "qemu/cache-utils.h" #include "qemu/cache-utils.h"
#if defined(_ARCH_PPC) #if defined(_ARCH_PPC)
@ -9,31 +10,33 @@ struct qemu_cache_conf qemu_cache_conf = {
#if defined _AIX #if defined _AIX
#include <sys/systemcfg.h> #include <sys/systemcfg.h>
static void ppc_init_cacheline_sizes(void) void qemu_cache_utils_init(void)
{ {
qemu_cache_conf.icache_bsize = _system_configuration.icache_line; qemu_cache_conf.icache_bsize = _system_configuration.icache_line;
qemu_cache_conf.dcache_bsize = _system_configuration.dcache_line; qemu_cache_conf.dcache_bsize = _system_configuration.dcache_line;
} }
#elif defined __linux__ #elif defined __linux__
#include "qemu/osdep.h"
#include "elf.h"
#define QEMU_AT_NULL 0 void qemu_cache_utils_init(void)
#define QEMU_AT_DCACHEBSIZE 19
#define QEMU_AT_ICACHEBSIZE 20
static void ppc_init_cacheline_sizes(char **envp)
{ {
unsigned long *auxv; unsigned long dsize = qemu_getauxval(AT_DCACHEBSIZE);
unsigned long isize = qemu_getauxval(AT_ICACHEBSIZE);
while (*envp++); if (dsize == 0 || isize == 0) {
if (dsize == 0) {
for (auxv = (unsigned long *) envp; *auxv != QEMU_AT_NULL; auxv += 2) { fprintf(stderr, "getauxval AT_DCACHEBSIZE failed\n");
switch (*auxv) {
case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break;
case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break;
default: break;
} }
if (isize == 0) {
fprintf(stderr, "getauxval AT_ICACHEBSIZE failed\n");
}
exit(1);
} }
qemu_cache_conf.dcache_bsize = dsize;
qemu_cache_conf.icache_bsize = isize;
} }
#elif defined __APPLE__ #elif defined __APPLE__
@ -41,7 +44,7 @@ static void ppc_init_cacheline_sizes(char **envp)
#include <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
static void ppc_init_cacheline_sizes(void) void qemu_cache_utils_init(void)
{ {
size_t len; size_t len;
unsigned cacheline; unsigned cacheline;
@ -55,9 +58,8 @@ static void ppc_init_cacheline_sizes(void)
qemu_cache_conf.icache_bsize = cacheline; qemu_cache_conf.icache_bsize = cacheline;
} }
} }
#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -65,7 +67,7 @@ static void ppc_init_cacheline_sizes(void)
#include <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
static void ppc_init_cacheline_sizes(void) void qemu_cache_utils_init(void)
{ {
size_t len = 4; size_t len = 4;
unsigned cacheline; unsigned cacheline;
@ -81,17 +83,4 @@ static void ppc_init_cacheline_sizes(void)
} }
#endif #endif
#ifdef __linux__
void qemu_cache_utils_init(char **envp)
{
ppc_init_cacheline_sizes(envp);
}
#else
void qemu_cache_utils_init(char **envp)
{
(void) envp;
ppc_init_cacheline_sizes();
}
#endif
#endif /* _ARCH_PPC */ #endif /* _ARCH_PPC */

2
vl.c
View File

@ -2895,7 +2895,7 @@ int main(int argc, char **argv, char **envp)
rtc_clock = QEMU_CLOCK_HOST; rtc_clock = QEMU_CLOCK_HOST;
qemu_init_auxval(envp); qemu_init_auxval(envp);
qemu_cache_utils_init(envp); qemu_cache_utils_init();
QLIST_INIT (&vm_change_state_head); QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling(); os_setup_early_signal_handling();