]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/microblaze/pselect.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / microblaze / pselect.c
CommitLineData
8781c130 1/* Synchronous I/O multiplexing. Linux/microblaze version.
d614a753 2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
8781c130
AZ
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# define __pselect __pselect_syscall
27#endif
28
29/* If pselect is supported, just use the Linux generic implementation. */
30#include <sysdeps/unix/sysv/linux/pselect.c>
31
32#ifndef __ASSUME_PSELECT
33# undef __pselect
34int
35__pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
36 const struct timespec *timeout, const sigset_t *sigmask)
37{
38 int ret = __pselect_syscall (nfds, readfds, writefds, exceptfds, timeout,
39 sigmask);
40 if (ret >= 0 || errno != ENOSYS)
41 return ret;
42
43 /* The fallback uses 'select' which shows the race condition regarding
44 signal mask set/restore, requires two additional syscalls, and has
45 a worse timeout precision (microseconds instead of nanoseconds). */
46
47 struct timeval tval, *ptval = NULL;
48 if (timeout != NULL)
49 {
50 if (! valid_nanoseconds (timeout->tv_nsec))
51 {
52 __set_errno (EINVAL);
53 return -1;
54 }
55
56 TIMESPEC_TO_TIMEVAL (&tval, timeout);
57 ptval = &tval;
58 }
59
60 sigset_t savemask;
61 if (sigmask != NULL)
62 __sigprocmask (SIG_SETMASK, sigmask, &savemask);
63
64 /* select itself is a cancellation entrypoint. */
65 ret = __select (nfds, readfds, writefds, exceptfds, ptval);
66
67 if (sigmask != NULL)
68 __sigprocmask (SIG_SETMASK, &savemask, NULL);
69
70 return ret;
71}
72weak_alias (__pselect, pselect)
73#endif