semihosting: Split out semihost_sys_rename
Split out the non-ARM specific portions of SYS_RENAME to a
reusable function.
Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index f4ce385..14d37ac 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -492,26 +492,7 @@
GET_ARG(1);
GET_ARG(2);
GET_ARG(3);
- if (use_gdb_syscalls()) {
- gdb_do_syscall(common_semi_cb, "rename,%s,%s",
- arg0, (int)arg1 + 1, arg2, (int)arg3 + 1);
- } else {
- char *s2;
-
- s = lock_user_string(arg0);
- if (!s) {
- goto do_fault;
- }
- s2 = lock_user_string(arg2);
- if (!s2) {
- unlock_user(s, arg0, 0);
- goto do_fault;
- }
- ret = rename(s, s2);
- unlock_user(s2, arg2, 0);
- unlock_user(s, arg0, 0);
- common_semi_cb(cs, ret, ret ? errno : 0);
- }
+ semihost_sys_rename(cs, common_semi_cb, arg0, arg1 + 1, arg2, arg3 + 1);
break;
case TARGET_SYS_CLOCK: