[v2,099/108] linux-user: Split out signalfd, signalfd4

Message ID 20180610030220.3777-100-richard.henderson@linaro.org
State New
Headers show
Series
  • linux-user: Split do_syscall
Related show

Commit Message

Richard Henderson June 10, 2018, 3:02 a.m.
All targets define signalfd4; remove the ifdefs.
In do_signalfd4, unlock the target sigmask earlier and use is_error.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/syscall.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

-- 
2.17.1

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 5edcb39b73..e630a43f97 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6975,8 +6975,6 @@  static abi_long host_to_target_statfs64(abi_ulong target_addr,
 }
 #endif
 
-#if defined(TARGET_NR_signalfd) || defined(TARGET_NR_signalfd4)
-
 /* signalfd siginfo conversion */
 
 static void
@@ -7045,21 +7043,17 @@  static abi_long do_signalfd4(int fd, abi_long mask, int flags)
     if (!lock_user_struct(VERIFY_READ, target_mask, mask, 1)) {
         return -TARGET_EFAULT;
     }
-
     target_to_host_sigset(&host_mask, target_mask);
+    unlock_user_struct(target_mask, mask, 0);
 
     host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl);
 
     ret = get_errno(signalfd(fd, &host_mask, host_flags));
-    if (ret >= 0) {
+    if (!is_error(ret)) {
         fd_trans_register(ret, &target_signalfd_trans);
     }
-
-    unlock_user_struct(target_mask, mask, 0);
-
     return ret;
 }
-#endif
 
 /* Map host to target signal numbers for the wait family of syscalls.
    Assume all other status bits are the same.  */
@@ -11884,6 +11878,18 @@  IMPL(sigaltstack)
     return do_sigaltstack(arg1, arg2, get_sp_from_cpustate(cpu_env));
 }
 
+#ifdef TARGET_NR_signalfd
+IMPL(signalfd)
+{
+    return do_signalfd4(arg1, arg2, 0);
+}
+#endif
+
+IMPL(signalfd4)
+{
+    return do_signalfd4(arg1, arg2, arg4);
+}
+
 #ifdef TARGET_NR_sigpending
 IMPL(sigpending)
 {
@@ -12850,14 +12856,6 @@  static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1,
     abi_long ret;
 
     switch(num) {
-#if defined(TARGET_NR_signalfd4)
-    case TARGET_NR_signalfd4:
-        return do_signalfd4(arg1, arg2, arg4);
-#endif
-#if defined(TARGET_NR_signalfd)
-    case TARGET_NR_signalfd:
-        return do_signalfd4(arg1, arg2, 0);
-#endif
 #if defined(CONFIG_EPOLL)
 #if defined(TARGET_NR_epoll_create)
     case TARGET_NR_epoll_create:
@@ -13808,6 +13806,10 @@  static impl_fn *syscall_table(unsigned num)
         SYSCALL(sigaction);
 #endif
         SYSCALL(sigaltstack);
+#ifdef TARGET_NR_signalfd
+        SYSCALL(signalfd);
+#endif
+        SYSCALL(signalfd4);
 #ifdef TARGET_NR_sigpending
         SYSCALL(sigpending);
 #endif