[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 11/11] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_S
From: |
Richard Henderson |
Subject: |
[PATCH v4 11/11] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_STRING |
Date: |
Tue, 7 Jun 2022 22:19:45 -0700 |
Inline these macros into the only two callers.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/mips/tcg/sysemu/mips-semi.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/target/mips/tcg/sysemu/mips-semi.c
b/target/mips/tcg/sysemu/mips-semi.c
index b54267681e..5fb1ad9092 100644
--- a/target/mips/tcg/sysemu/mips-semi.c
+++ b/target/mips/tcg/sysemu/mips-semi.c
@@ -198,19 +198,6 @@ static void uhi_fstat_cb(CPUState *cs, uint64_t ret, int
err)
uhi_cb(cs, ret, err);
}
-#define GET_TARGET_STRING(p, addr) \
- do { \
- p = lock_user_string(addr); \
- if (!p) { \
- report_fault(env); \
- } \
- } while (0)
-
-#define FREE_TARGET_STRING(p, gpr) \
- do { \
- unlock_user(p, gpr, 0); \
- } while (0)
-
void mips_semihosting(CPUMIPSState *env)
{
CPUState *cs = env_cpu(env);
@@ -225,9 +212,13 @@ void mips_semihosting(CPUMIPSState *env)
case UHI_open:
{
+ target_ulong fname = gpr[4];
int ret = -1;
- GET_TARGET_STRING(p, gpr[4]);
+ p = lock_user_string(fname);
+ if (!p) {
+ report_fault(env);
+ }
if (!strcmp("/dev/stdin", p)) {
ret = 0;
} else if (!strcmp("/dev/stdout", p)) {
@@ -235,7 +226,7 @@ void mips_semihosting(CPUMIPSState *env)
} else if (!strcmp("/dev/stderr", p)) {
ret = 2;
}
- FREE_TARGET_STRING(p, gpr[4]);
+ unlock_user(p, fname, 0);
/* FIXME: reusing a guest fd doesn't seem correct. */
if (ret >= 0) {
@@ -243,7 +234,7 @@ void mips_semihosting(CPUMIPSState *env)
break;
}
- semihost_sys_open(cs, uhi_cb, gpr[4], 0, gpr[5], gpr[6]);
+ semihost_sys_open(cs, uhi_cb, fname, 0, gpr[5], gpr[6]);
}
break;
@@ -314,14 +305,14 @@ void mips_semihosting(CPUMIPSState *env)
pct_d = strstr(p, "%d");
if (!pct_d) {
- FREE_TARGET_STRING(p, addr);
+ unlock_user(p, addr, 0);
semihost_sys_write(cs, uhi_cb, 2, addr, len);
break;
}
str = g_string_new_len(p, pct_d - p);
g_string_append_printf(str, "%d%s", (int)gpr[5], pct_d + 2);
- FREE_TARGET_STRING(p, addr);
+ unlock_user(p, addr, 0);
/*
* When we're using gdb, we need a guest address, so
--
2.34.1
- [PATCH v4 06/11] target/mips: Use semihosting/syscalls.h, (continued)
- [PATCH v4 06/11] target/mips: Use semihosting/syscalls.h, Richard Henderson, 2022/06/08
- [PATCH v4 04/11] target/mips: Drop link syscall from semihosting, Richard Henderson, 2022/06/08
- [PATCH v4 09/11] semihosting: Remove qemu_semihosting_log_out, Richard Henderson, 2022/06/08
- [PATCH v4 07/11] target/mips: Avoid qemu_semihosting_log_out for UHI_plog, Richard Henderson, 2022/06/08
- [PATCH v4 05/11] target/mips: Drop pread and pwrite syscalls from semihosting, Richard Henderson, 2022/06/08
- [PATCH v4 08/11] target/mips: Use error_report for UHI_assert, Richard Henderson, 2022/06/08
- [PATCH v4 10/11] target/mips: Simplify UHI_argnlen and UHI_argn, Richard Henderson, 2022/06/08
- [PATCH v4 11/11] target/mips: Remove GET_TARGET_STRING and FREE_TARGET_STRING,
Richard Henderson <=