]>
Commit | Line | Data |
---|---|---|
d614a753 | 1 | /* Copyright (C) 2006-2020 Free Software Foundation, Inc. |
7c65e900 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Ulrich Drepper <drepper@redhat.com>, 2006. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
7c65e900 UD |
18 | |
19 | #include <errno.h> | |
20 | #include <signal.h> | |
21 | #include <time.h> | |
22 | #include <sys/poll.h> | |
7c65e900 | 23 | #include <sysdep-cancel.h> |
258c2421 | 24 | #include <kernel-features.h> |
7c65e900 UD |
25 | |
26 | ||
7c65e900 | 27 | int |
258c2421 LM |
28 | __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout, |
29 | const sigset_t *sigmask) | |
7c65e900 UD |
30 | { |
31 | /* The Linux kernel can in some situations update the timeout value. | |
32 | We do not want that so use a local variable. */ | |
258c2421 | 33 | struct __timespec64 tval; |
7c65e900 UD |
34 | if (timeout != NULL) |
35 | { | |
36 | tval = *timeout; | |
37 | timeout = &tval; | |
38 | } | |
39 | ||
258c2421 LM |
40 | #ifdef __ASSUME_TIME64_SYSCALLS |
41 | # ifndef __NR_ppoll_time64 | |
42 | # define __NR_ppoll_time64 __NR_ppoll | |
43 | # endif | |
44 | return SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, _NSIG / 8); | |
45 | #else | |
46 | # ifdef __NR_ppoll_time64 | |
47 | int ret = SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, | |
48 | _NSIG / 8); | |
49 | if (ret >= 0 || errno != ENOSYS) | |
50 | return ret; | |
51 | # endif | |
52 | struct timespec ts32; | |
53 | if (timeout) | |
54 | { | |
55 | if (! in_time_t_range (timeout->tv_sec)) | |
56 | { | |
57 | __set_errno (EOVERFLOW); | |
58 | return -1; | |
59 | } | |
60 | ||
61 | ts32 = valid_timespec64_to_timespec (*timeout); | |
62 | } | |
63 | ||
64 | return SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL, sigmask, | |
65 | _NSIG / 8); | |
66 | #endif | |
67 | } | |
68 | ||
69 | #if __TIMESIZE != 64 | |
70 | int | |
71 | __ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, | |
72 | const sigset_t *sigmask) | |
73 | { | |
74 | struct __timespec64 ts64; | |
75 | if (timeout) | |
76 | ts64 = valid_timespec_to_timespec64 (*timeout); | |
77 | ||
78 | return __ppoll64 (fds, nfds, timeout ? &ts64 : NULL, sigmask); | |
7c65e900 | 79 | } |
258c2421 LM |
80 | #endif |
81 | strong_alias (__ppoll, ppoll) | |
d9a216c0 | 82 | libc_hidden_def (ppoll) |