Back to index

glibc  2.9
ppoll.c
Go to the documentation of this file.
00001 /* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2006.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <errno.h>
00021 #include <signal.h>
00022 #include <time.h>
00023 #include <sys/poll.h>
00024 #include <kernel-features.h>
00025 #include <sysdep-cancel.h>
00026 
00027 
00028 #ifdef __NR_ppoll
00029 # ifndef __ASSUME_PPOLL
00030 static int __generic_ppoll (struct pollfd *fds, nfds_t nfds,
00031                          const struct timespec *timeout,
00032                          const sigset_t *sigmask);
00033 # endif
00034 
00035 
00036 int
00037 ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
00038        const sigset_t *sigmask)
00039 {
00040   /* The Linux kernel can in some situations update the timeout value.
00041      We do not want that so use a local variable.  */
00042   struct timespec tval;
00043   if (timeout != NULL)
00044     {
00045       tval = *timeout;
00046       timeout = &tval;
00047     }
00048 
00049   int result;
00050 
00051   if (SINGLE_THREAD_P)
00052     result = INLINE_SYSCALL (ppoll, 5, fds, nfds, timeout, sigmask, _NSIG / 8);
00053   else
00054     {
00055       int oldtype = LIBC_CANCEL_ASYNC ();
00056 
00057       result = INLINE_SYSCALL (ppoll, 5, fds, nfds, timeout, sigmask,
00058                             _NSIG / 8);
00059 
00060       LIBC_CANCEL_RESET (oldtype);
00061     }
00062 
00063 # ifndef __ASSUME_PPOLL
00064   if (result == -1 && errno == ENOSYS)
00065     result = __generic_ppoll (fds, nfds, timeout, sigmask);
00066 # endif
00067 
00068   return result;
00069 }
00070 
00071 # ifndef __ASSUME_PPOLL
00072 #  define ppoll static __generic_ppoll
00073 # endif
00074 #endif
00075 
00076 #ifndef __ASSUME_PPOLL
00077 # include <io/ppoll.c>
00078 #endif