summaryrefslogtreecommitdiffstats
path: root/target/arm/arm-semi.c
diff options
context:
space:
mode:
authorPeter Maydell2019-09-16 16:15:35 +0200
committerPeter Maydell2019-10-15 19:09:03 +0200
commit939f5b4331b159b51c85cae1b8f0c9d82aa0dffd (patch)
tree57e2af6db5205a3233884749e865ef9f41f6127e /target/arm/arm-semi.c
parenttarget/arm/arm-semi: Restrict use of TaskState* (diff)
downloadqemu-939f5b4331b159b51c85cae1b8f0c9d82aa0dffd.tar.gz
qemu-939f5b4331b159b51c85cae1b8f0c9d82aa0dffd.tar.xz
qemu-939f5b4331b159b51c85cae1b8f0c9d82aa0dffd.zip
target/arm/arm-semi: Use set_swi_errno() in gdbstub callback functions
When we are routing semihosting operations through the gdbstub, the work of sorting out the return value and setting errno if necessary is done by callback functions which are invoked by the gdbstub code. Clean up some ifdeffery in those functions by having them call set_swi_errno() to set the semihosting errno. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20190916141544.17540-7-peter.maydell@linaro.org
Diffstat (limited to 'target/arm/arm-semi.c')
-rw-r--r--target/arm/arm-semi.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
index 2618588076..02cd673d47 100644
--- a/target/arm/arm-semi.c
+++ b/target/arm/arm-semi.c
@@ -259,17 +259,11 @@ static void arm_semi_cb(CPUState *cs, target_ulong ret, target_ulong err)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
-#ifdef CONFIG_USER_ONLY
- TaskState *ts = cs->opaque;
-#endif
target_ulong reg0 = is_a64(env) ? env->xregs[0] : env->regs[0];
if (ret == (target_ulong)-1) {
-#ifdef CONFIG_USER_ONLY
- ts->swi_errno = err;
-#else
- syscall_err = err;
-#endif
+ errno = err;
+ set_swi_errno(env, -1);
reg0 = ret;
} else {
/* Fixup syscalls that use nonstardard return conventions. */
@@ -326,11 +320,8 @@ static void arm_semi_flen_cb(CPUState *cs, target_ulong ret, target_ulong err)
} else {
env->regs[0] = size;
}
-#ifdef CONFIG_USER_ONLY
- ((TaskState *)cs->opaque)->swi_errno = err;
-#else
- syscall_err = err;
-#endif
+ errno = err;
+ set_swi_errno(env, -1);
}
static int arm_semi_open_guestfd;
@@ -339,15 +330,9 @@ static void arm_semi_open_cb(CPUState *cs, target_ulong ret, target_ulong err)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
-#ifdef CONFIG_USER_ONLY
- TaskState *ts = cs->opaque;
-#endif
if (ret == (target_ulong)-1) {
-#ifdef CONFIG_USER_ONLY
- ts->swi_errno = err;
-#else
- syscall_err = err;
-#endif
+ errno = err;
+ set_swi_errno(env, -1);
dealloc_guestfd(arm_semi_open_guestfd);
} else {
associate_guestfd(arm_semi_open_guestfd, ret);