1 /* Copyright (C) 2006-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <sys/select.h>
19 #include <sysdep-cancel.h>
22 pselect64_syscall (int nfds
, fd_set
*readfds
, fd_set
*writefds
,
23 fd_set
*exceptfds
, const struct __timespec64
*timeout
,
24 const sigset_t
*sigmask
)
26 #ifndef __NR_pselect6_time64
27 # define __NR_pselect6_time64 __NR_pselect6
29 /* NB: This is required by ARGIFY used in x32 internal_syscallN. */
30 __syscall_ulong_t data
[2] =
32 (uintptr_t) sigmask
, __NSIG_BYTES
34 return SYSCALL_CANCEL (pselect6_time64
, nfds
, readfds
, writefds
, exceptfds
,
39 __pselect64 (int nfds
, fd_set
*readfds
, fd_set
*writefds
, fd_set
*exceptfds
,
40 const struct __timespec64
*timeout
, const sigset_t
*sigmask
)
42 /* The Linux kernel can in some situations update the timeout value.
43 We do not want that so use a local variable. */
44 struct __timespec64 tval
;
51 /* Note: the system call expects 7 values but on most architectures
52 we can only pass in 6 directly. If there is an architecture with
53 support for more parameters a new version of this file needs to
55 #ifdef __ASSUME_TIME64_SYSCALLS
56 return pselect64_syscall (nfds
, readfds
, writefds
, exceptfds
, timeout
,
59 bool need_time64
= timeout
!= NULL
&& !in_int32_t_range (timeout
->tv_sec
);
62 int r
= pselect64_syscall (nfds
, readfds
, writefds
, exceptfds
, timeout
,
64 if (r
== 0 || errno
!= ENOSYS
)
66 __set_errno (EOVERFLOW
);
70 return __pselect32 (nfds
, readfds
, writefds
, exceptfds
, timeout
, sigmask
);
75 libc_hidden_def (__pselect64
)
78 __pselect (int nfds
, fd_set
*readfds
, fd_set
*writefds
, fd_set
*exceptfds
,
79 const struct timespec
*timeout
, const sigset_t
*sigmask
)
81 struct __timespec64 ts64
, *pts64
= NULL
;
84 ts64
= valid_timespec_to_timespec64 (*timeout
);
87 return __pselect64 (nfds
, readfds
, writefds
, exceptfds
, pts64
, sigmask
);
92 weak_alias (__pselect
, pselect
)