]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 2006-2021 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> |
60a2e28b | 25 | #include <time64-support.h> |
7c65e900 UD |
26 | |
27 | ||
7c65e900 | 28 | int |
258c2421 LM |
29 | __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout, |
30 | const sigset_t *sigmask) | |
7c65e900 UD |
31 | { |
32 | /* The Linux kernel can in some situations update the timeout value. | |
33 | We do not want that so use a local variable. */ | |
258c2421 | 34 | struct __timespec64 tval; |
7c65e900 UD |
35 | if (timeout != NULL) |
36 | { | |
37 | tval = *timeout; | |
38 | timeout = &tval; | |
39 | } | |
40 | ||
60a2e28b AZ |
41 | int ret; |
42 | ||
43 | if (supports_time64 ()) | |
44 | { | |
3feb53ba AZ |
45 | #ifndef __NR_ppoll_time64 |
46 | # define __NR_ppoll_time64 __NR_ppoll | |
47 | #endif | |
60a2e28b AZ |
48 | ret = SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, |
49 | __NSIG_BYTES); | |
3feb53ba | 50 | |
60a2e28b AZ |
51 | if (ret == 0 || errno != ENOSYS) |
52 | return ret; | |
3feb53ba | 53 | |
60a2e28b AZ |
54 | mark_time64_unsupported (); |
55 | } | |
56 | ||
57 | #ifndef __ASSUME_TIME64_SYSCALLS | |
258c2421 LM |
58 | struct timespec ts32; |
59 | if (timeout) | |
60 | { | |
61 | if (! in_time_t_range (timeout->tv_sec)) | |
62 | { | |
63 | __set_errno (EOVERFLOW); | |
64 | return -1; | |
65 | } | |
66 | ||
67 | ts32 = valid_timespec64_to_timespec (*timeout); | |
68 | } | |
69 | ||
3feb53ba AZ |
70 | ret = SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL, sigmask, |
71 | __NSIG_BYTES); | |
258c2421 | 72 | #endif |
3feb53ba AZ |
73 | |
74 | return ret; | |
258c2421 LM |
75 | } |
76 | ||
77 | #if __TIMESIZE != 64 | |
03343699 LM |
78 | libc_hidden_def (__ppoll64) |
79 | ||
258c2421 LM |
80 | int |
81 | __ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, | |
82 | const sigset_t *sigmask) | |
83 | { | |
84 | struct __timespec64 ts64; | |
85 | if (timeout) | |
86 | ts64 = valid_timespec_to_timespec64 (*timeout); | |
87 | ||
88 | return __ppoll64 (fds, nfds, timeout ? &ts64 : NULL, sigmask); | |
7c65e900 | 89 | } |
258c2421 LM |
90 | #endif |
91 | strong_alias (__ppoll, ppoll) | |
d9a216c0 | 92 | libc_hidden_def (ppoll) |