Signed-off-by: Zixing Liu <liush...@aosc.io>
---
linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8bfe491..6906e7b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -711,6 +711,11 @@ safe_syscall5(int, ppoll, struct pollfd *, ufds,
unsigned int, nfds,
safe_syscall6(int, epoll_pwait, int, epfd, struct epoll_event *,
events,
int, maxevents, int, timeout, const sigset_t *, sigmask,
size_t, sigsetsize)
+#if defined(__NR_epoll_pwait2)
+safe_syscall6(int, epoll_pwait2, int, epfd, struct epoll_event *,
events,
+ int, maxevents, struct timespec *, timeout, const
sigset_t *, sigmask,
+ size_t, sigsetsize)
+#endif
#if defined(__NR_futex)
safe_syscall6(int,futex,int *,uaddr,int,op,int,val, \
const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -13363,19 +13368,22 @@ static abi_long do_syscall1(CPUArchState
*cpu_env, int num, abi_long arg1,
}
#endif
-#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait)
+#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait) ||
defined(TARGET_NR_epoll_pwait2)
#if defined(TARGET_NR_epoll_wait)
case TARGET_NR_epoll_wait:
#endif
#if defined(TARGET_NR_epoll_pwait)
case TARGET_NR_epoll_pwait:
+#endif
+#if defined(TARGET_NR_epoll_pwait2)
+ case TARGET_NR_epoll_pwait2:
#endif
{
struct target_epoll_event *target_ep;
struct epoll_event *ep;
int epfd = arg1;
int maxevents = arg3;
- int timeout = arg4;
+ abi_long timeout = arg4;
if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
return -TARGET_EINVAL;
@@ -13396,6 +13404,9 @@ static abi_long do_syscall1(CPUArchState
*cpu_env, int num, abi_long arg1,
switch (num) {
#if defined(TARGET_NR_epoll_pwait)
case TARGET_NR_epoll_pwait:
+#if defined(TARGET_NR_epoll_pwait2)
+ case TARGET_NR_epoll_pwait2:
+#endif
{
sigset_t *set = NULL;
@@ -13406,8 +13417,25 @@ static abi_long do_syscall1(CPUArchState
*cpu_env, int num, abi_long arg1,
}
}
- ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents,
timeout,
- set, SIGSET_T_SIZE));
+ if (num == TARGET_NR_epoll_pwait) {
+ ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents,
(int)timeout,
+ set, SIGSET_T_SIZE));
+ } else {
+#if defined(TARGET_NR_epoll_pwait2)
+ struct timespec hspec;
+ struct timespec *ts_arg = NULL;
+ if (timeout) {
+ if (target_to_host_timespec(&hspec,
(abi_ulong)timeout)) {
+ return -TARGET_EFAULT;
+ }
+ ts_arg = &hspec;
+ }
+ ret = get_errno(safe_epoll_pwait2(epfd, ep, maxevents,
ts_arg,
+ set, SIGSET_T_SIZE));
+#else
+ return -TARGET_ENOSYS;
+#endif
+ }
if (set) {
finish_sigsuspend_mask(ret);
--
2.49.0