]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/microblaze/pselect32.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / microblaze / pselect32.c
1 /* Synchronous I/O multiplexing. Linux/microblaze version.
2 Copyright (C) 2019-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #include <errno.h>
20 #include <signal.h>
21 #include <time.h>
22 #include <sys/poll.h>
23 #include <sysdep-cancel.h>
24
25 #ifndef __ASSUME_PSELECT
26 int
27 __pselect32 (int nfds, fd_set *readfds, fd_set *writefds,
28 fd_set *exceptfds, const struct __timespec64 *timeout,
29 const sigset_t *sigmask)
30 {
31 /* The fallback uses 'select' which shows the race condition regarding
32 signal mask set/restore, requires two additional syscalls, and has
33 a worse timeout precision (microseconds instead of nanoseconds). */
34
35 struct timeval tv32, *ptv32 = NULL;
36 if (timeout != NULL)
37 {
38 if (! in_time_t_range (timeout->tv_sec)
39 || ! valid_nanoseconds (timeout->tv_nsec))
40 {
41 __set_errno (EINVAL);
42 return -1;
43 }
44
45 tv32 = valid_timespec64_to_timeval (*timeout);
46 ptv32 = &tv32;
47 }
48
49 sigset_t savemask;
50 if (sigmask != NULL)
51 __sigprocmask (SIG_SETMASK, sigmask, &savemask);
52
53 /* select itself is a cancellation entrypoint. */
54 int ret = __select (nfds, readfds, writefds, exceptfds, ptv32);
55
56 if (sigmask != NULL)
57 __sigprocmask (SIG_SETMASK, &savemask, NULL);
58
59 return ret;
60 }
61 #endif /* __ASSUME_PSELECT */