Back to index

glibc  2.9
epoll_pwait.c
Go to the documentation of this file.
00001 /* Copyright (C) 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <errno.h>
00020 #include <signal.h>
00021 #include <unistd.h>
00022 #include <sys/epoll.h>
00023 
00024 #include <sysdep-cancel.h>
00025 #include <sys/syscall.h>
00026 
00027 #ifdef __NR_epoll_pwait
00028 
00029 /* Wait for events on an epoll instance "epfd". Returns the number of
00030    triggered events returned in "events" buffer. Or -1 in case of
00031    error with the "errno" variable set to the specific error code. The
00032    "events" parameter is a buffer that will contain triggered
00033    events. The "maxevents" is the maximum number of events to be
00034    returned ( usually size of "events" ). The "timeout" parameter
00035    specifies the maximum wait time in milliseconds (-1 == infinite).
00036    The thread's signal mask is temporarily and atomically replaced with
00037    the one provided as parameter.  */
00038 
00039 int epoll_pwait (int epfd, struct epoll_event *events,
00040                int maxevents, int timeout,
00041                const sigset_t *set)
00042 {
00043   if (SINGLE_THREAD_P)
00044     return INLINE_SYSCALL (epoll_pwait, 6, epfd, events, maxevents, timeout,
00045                         set, _NSIG / 8);
00046 
00047   int oldtype = LIBC_CANCEL_ASYNC ();
00048 
00049   int result = INLINE_SYSCALL (epoll_pwait, 6, epfd, events, maxevents,
00050                             timeout, set, _NSIG / 8);
00051 
00052   LIBC_CANCEL_RESET (oldtype);
00053 
00054   return result;
00055 }
00056 
00057 #else
00058 
00059 int epoll_pwait (int epfd, struct epoll_event *events,
00060                int maxevents, int timeout,
00061                const sigset_t *set)
00062 {
00063   __set_errno (ENOSYS);
00064   return -1;
00065 }
00066 stub_warning (epoll_pwait)
00067 
00068 # include <stub-tag.h>
00069 #endif