On 1/8/26 20:43, Michael Tokarev wrote:
epoll_pwait2 is the same as epoll_pwait but with timeout being
(a pointer to) struct timespec instead of an integer.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3210
I failed to realize there was a previous attempt to implement
the same syscall by Zixing Liu - it was even submitted through my tree,
but it was badly reviewed - I failed to notice a memory leak in there.
@@ -13654,8 +13666,13 @@ 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 = safe_epoll_pwait(epfd, ep, maxevents, arg4,
+ set, SIGSET_T_SIZE);
+ } else {
+ ret = safe_epoll_pwait2(epfd, ep, maxevents, timeout_ts,
+ set, SIGSET_T_SIZE);
+ }
And this is wrong - I forgot get_errno() in the new version.
Fixed now:
@@ -13654,8 +13666,13 @@ 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, arg4,
+ set, SIGSET_T_SIZE));
+ } else {
+ ret = get_errno(safe_epoll_pwait2(epfd, ep, maxevents,
timeout_ts,
+ set, SIGSET_T_SIZE));
+ }
if (set) {
finish_sigsuspend_mask(ret);
The previous attempt were not successful, because it failed build on
armhf. I checked why it failed -- it is rather fun, the failure to
build was because qemu carried old/incomplete linux-headers for 32bit
arm. These headers weren't needed since v5.0.0, and were removed in
v10.0.0-2612-g99c6e970a4 "linux-headers: Remove the 32-bit arm headers" -
after what commit, the patch by Zixing Liu would've worked (modulo the
memory leak).
But I think my version is better, in the end (after fixing get_errno()).
Thanks,
/mjt