aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-06-03 13:57:52 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-06-06 19:10:37 +0100
commitc188e238a62039f365bb480b34b2409383063058 (patch)
tree4375b1ea1271167884a8baa55480099d98e50bf1
parent3b34b77ea58eb93304a8a1c441ee85fdfb1671b2 (diff)
downloadqemu-arm-c188e238a62039f365bb480b34b2409383063058.tar.gz
linux-user: Use safe_syscall wrapper for accept and accept4 syscalls
Use the safe_syscall wrapper for the accept and accept4 syscalls. accept4 has been in the kernel since 2.6.28 so we can assume it is always present. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--linux-user/syscall.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8682ab0cff..aac2bbdfad 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -708,6 +708,8 @@ safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags)
safe_syscall2(int, flock, int, fd, int, operation)
safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo,
const struct timespec *, uts, size_t, sigsetsize)
+safe_syscall4(int, accept4, int, fd, struct sockaddr *, addr, socklen_t *, len,
+ int, flags)
safe_syscall2(int, nanosleep, const struct timespec *, req,
struct timespec *, rem)
#ifdef TARGET_NR_clock_nanosleep
@@ -2427,19 +2429,6 @@ static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec,
return ret;
}
-/* If we don't have a system accept4() then just call accept.
- * The callsites to do_accept4() will ensure that they don't
- * pass a non-zero flags argument in this config.
- */
-#ifndef CONFIG_ACCEPT4
-static inline int accept4(int sockfd, struct sockaddr *addr,
- socklen_t *addrlen, int flags)
-{
- assert(flags == 0);
- return accept(sockfd, addr, addrlen);
-}
-#endif
-
/* do_accept4() Must return target values and target errnos. */
static abi_long do_accept4(int fd, abi_ulong target_addr,
abi_ulong target_addrlen_addr, int flags)
@@ -2452,7 +2441,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl);
if (target_addr == 0) {
- return get_errno(accept4(fd, NULL, NULL, host_flags));
+ return get_errno(safe_accept4(fd, NULL, NULL, host_flags));
}
/* linux returns EINVAL if addrlen pointer is invalid */
@@ -2468,7 +2457,7 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
addr = alloca(addrlen);
- ret = get_errno(accept4(fd, addr, &addrlen, host_flags));
+ ret = get_errno(safe_accept4(fd, addr, &addrlen, host_flags));
if (!is_error(ret)) {
host_to_target_sockaddr(target_addr, addr, addrlen);
if (put_user_u32(addrlen, target_addrlen_addr))
@@ -7693,11 +7682,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_accept4
case TARGET_NR_accept4:
-#ifdef CONFIG_ACCEPT4
ret = do_accept4(arg1, arg2, arg3, arg4);
-#else
- goto unimplemented;
-#endif
break;
#endif
#ifdef TARGET_NR_bind