summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/pselect.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/pselect.c')
-rw-r--r--sysdeps/unix/sysv/linux/pselect.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c
index 77a5179925..45a3b4ab58 100644
--- a/sysdeps/unix/sysv/linux/pselect.c
+++ b/sysdeps/unix/sysv/linux/pselect.c
@@ -23,13 +23,13 @@
#include <kernel-features.h>
#include <sysdep-cancel.h>
-int
-__pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- const struct timespec *timeout, const sigset_t *sigmask)
+int __pselect64 (int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, const struct __timespec64 *timeout,
+ const sigset_t *sigmask)
{
/* The Linux kernel can in some situations update the timeout value.
We do not want that so use a local variable. */
- struct timespec tval;
+ struct __timespec64 tval;
if (timeout != NULL)
{
tval = *timeout;
@@ -49,9 +49,50 @@ __pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
data.ss = (__syscall_ulong_t) (uintptr_t) sigmask;
data.ss_len = _NSIG / 8;
+#ifdef __ASSUME_TIME64_SYSCALLS
+# ifndef __NR_pselect6_time64
+# define __NR_pselect6_time64 __NR_pselect6
+# endif
+ return SYSCALL_CANCEL (pselect6_time64, nfds, readfds, writefds, exceptfds,
+ timeout, &data);
+#else
+# ifdef __NR_ppoll_time64
+ int ret = SYSCALL_CANCEL (pselect6_time64, nfds, readfds, writefds,
+ exceptfds, timeout, &data);
+ if (ret >= 0 || errno != ENOSYS)
+ return ret;
+# endif
+ struct timespec ts32;
+ if (timeout)
+ {
+ if (! in_time_t_range (timeout->tv_sec))
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ ts32 = valid_timespec64_to_timespec (*timeout);
+ }
+
return SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds,
- timeout, &data);
+ timeout ? &ts32 : NULL, &data);
+#endif /* __ASSUME_TIME64_SYSCALLS */
}
+
+#if __TIMESIZE != 64
+int
+__pselect (int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, const struct timespec *timeout,
+ const sigset_t *sigmask)
+{
+ struct __timespec64 ts64;
+ if (timeout)
+ ts64 = valid_timespec_to_timespec64 (*timeout);
+
+ return __pselect64 (nfds, readfds, writefds, exceptfds,
+ timeout ? &ts64 : NULL, sigmask);
+}
+#endif
#ifndef __pselect
weak_alias (__pselect, pselect)
#endif