From b6a3e690b4f396633c75e18a9c3e7b6771fb71ba Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 4 Jun 2013 11:24:49 -0700 Subject: osdep: Create qemu_getauxval and qemu_init_auxval Abstract away dependence on a system implementation of getauxval. Signed-off-by: Richard Henderson --- linux-user/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'linux-user') diff --git a/linux-user/main.c b/linux-user/main.c index 6b4ab0930e..0e453369c8 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3701,6 +3701,7 @@ int main(int argc, char **argv, char **envp) module_call_init(MODULE_INIT_QOM); + qemu_init_auxval(envp); qemu_cache_utils_init(envp); if ((envlist = envlist_create()) == NULL) { -- cgit v1.2.3 From 664d2c4458a268eb176a223c397453a72ed167f4 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 10 Jun 2013 09:05:09 -0700 Subject: 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 Signed-off-by: Richard Henderson --- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-user') diff --git a/linux-user/main.c b/linux-user/main.c index 0e453369c8..50db7553ea 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3702,7 +3702,7 @@ int main(int argc, char **argv, char **envp) module_call_init(MODULE_INIT_QOM); qemu_init_auxval(envp); - qemu_cache_utils_init(envp); + qemu_cache_utils_init(); if ((envlist = envlist_create()) == NULL) { (void) fprintf(stderr, "Unable to allocate envlist\n"); -- cgit v1.2.3 From 0b959cf5e4cce08ed96bd7832447e1543cd3622f Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 15 Oct 2013 15:00:36 -0700 Subject: linux-user: Use qemu_getauxval for AT_EXECFD Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/main.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'linux-user') diff --git a/linux-user/main.c b/linux-user/main.c index 50db7553ea..54f71fe8f6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3663,26 +3663,6 @@ static int parse_args(int argc, char **argv) return optind; } -static int get_execfd(char **envp) -{ - typedef struct { - long a_type; - long a_val; - } auxv_t; - auxv_t *auxv; - - while (*envp++ != NULL) { - ; - } - - for (auxv = (auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) { - if (auxv->a_type == AT_EXECFD) { - return auxv->a_val; - } - } - return -1; -} - int main(int argc, char **argv, char **envp) { struct target_pt_regs regs1, *regs = ®s1; @@ -3876,13 +3856,13 @@ int main(int argc, char **argv, char **envp) env->opaque = ts; task_settid(ts); - execfd = get_execfd(envp); - if (execfd < 0) { + execfd = qemu_getauxval(AT_EXECFD); + if (execfd == 0) { execfd = open(filename, O_RDONLY); - } - if (execfd < 0) { - printf("Error while loading %s: %s\n", filename, strerror(-execfd)); - _exit(1); + if (execfd < 0) { + printf("Error while loading %s: %s\n", filename, strerror(errno)); + _exit(1); + } } ret = loader_exec(execfd, filename, target_argv, target_environ, regs, -- cgit v1.2.3