1 /* Copyright (C) 2006, 2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2006.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #include <stddef.h> /* For NULL. */
25 #include <sysdep-cancel.h>
29 ppoll (struct pollfd
*fds
, nfds_t nfds
, const struct timespec
*timeout
,
30 const sigset_t
*sigmask
)
34 /* poll uses a simple millisecond value. Convert it. */
37 if (timeout
->tv_sec
< 0
38 || timeout
->tv_nsec
< 0 || timeout
->tv_nsec
>= 1000000000)
44 if (timeout
->tv_sec
> INT_MAX
/ 1000
45 || (timeout
->tv_sec
== INT_MAX
/ 1000
46 && ((timeout
->tv_nsec
+ 999999) / 1000000 > INT_MAX
% 1000)))
47 /* We cannot represent the timeout in an int value. Wait
51 tval
= (timeout
->tv_sec
* 1000
52 + (timeout
->tv_nsec
+ 999999) / 1000000);
55 /* The setting and restoring of the signal mask and the select call
56 should be an atomic operation. This can't be done without kernel
60 __sigprocmask (SIG_SETMASK
, sigmask
, &savemask
);
62 /* Note the ppoll() is a cancellation point. But since we call
63 poll() which itself is a cancellation point we do not have
64 to do anything here. */
65 int retval
= __poll (fds
, nfds
, tval
);
68 __sigprocmask (SIG_SETMASK
, &savemask
, NULL
);
74 /* __poll handles cancellation. */
75 LIBC_CANCEL_HANDLED ();
76 libc_hidden_def (ppoll
);