Back to index

glibc  2.9
epoll.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002-2006, 2007, 2008 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 #ifndef       _SYS_EPOLL_H
00020 #define       _SYS_EPOLL_H  1
00021 
00022 #include <stdint.h>
00023 #include <sys/types.h>
00024 
00025 /* Get __sigset_t.  */
00026 #include <bits/sigset.h>
00027 
00028 #ifndef __sigset_t_defined
00029 # define __sigset_t_defined
00030 typedef __sigset_t sigset_t;
00031 #endif
00032 
00033 
00034 /* Flags to be passed to epoll_create2.  */
00035 enum
00036   {
00037     EPOLL_CLOEXEC = 010000000,
00038 #define EPOLL_CLOEXEC EPOLL_CLOEXEC
00039     EPOLL_NONBLOCK = 04
00040 #define EPOLL_NONBLOCK EPOLL_NONBLOCK
00041   };
00042 
00043 
00044 enum EPOLL_EVENTS
00045   {
00046     EPOLLIN = 0x001,
00047 #define EPOLLIN EPOLLIN
00048     EPOLLPRI = 0x002,
00049 #define EPOLLPRI EPOLLPRI
00050     EPOLLOUT = 0x004,
00051 #define EPOLLOUT EPOLLOUT
00052     EPOLLRDNORM = 0x040,
00053 #define EPOLLRDNORM EPOLLRDNORM
00054     EPOLLRDBAND = 0x080,
00055 #define EPOLLRDBAND EPOLLRDBAND
00056     EPOLLWRNORM = 0x100,
00057 #define EPOLLWRNORM EPOLLWRNORM
00058     EPOLLWRBAND = 0x200,
00059 #define EPOLLWRBAND EPOLLWRBAND
00060     EPOLLMSG = 0x400,
00061 #define EPOLLMSG EPOLLMSG
00062     EPOLLERR = 0x008,
00063 #define EPOLLERR EPOLLERR
00064     EPOLLHUP = 0x010,
00065 #define EPOLLHUP EPOLLHUP
00066     EPOLLRDHUP = 0x2000,
00067 #define EPOLLRDHUP EPOLLRDHUP
00068     EPOLLONESHOT = (1 << 30),
00069 #define EPOLLONESHOT EPOLLONESHOT
00070     EPOLLET = (1 << 31)
00071 #define EPOLLET EPOLLET
00072   };
00073 
00074 
00075 /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl().  */
00076 #define EPOLL_CTL_ADD 1     /* Add a file descriptor to the interface.  */
00077 #define EPOLL_CTL_DEL 2     /* Remove a file descriptor from the interface.  */
00078 #define EPOLL_CTL_MOD 3     /* Change file descriptor epoll_event structure.  */
00079 
00080 
00081 typedef union epoll_data
00082 {
00083   void *ptr;
00084   int fd;
00085   uint32_t u32;
00086   uint64_t u64;
00087 } epoll_data_t;
00088 
00089 struct epoll_event
00090 {
00091   uint32_t events;   /* Epoll events */
00092   epoll_data_t data; /* User data variable */
00093 };
00094 
00095 
00096 __BEGIN_DECLS
00097 
00098 /* Creates an epoll instance.  Returns an fd for the new instance.
00099    The "size" parameter is a hint specifying the number of file
00100    descriptors to be associated with the new instance.  The fd
00101    returned by epoll_create() should be closed with close().  */
00102 extern int epoll_create (int __size) __THROW;
00103 
00104 /* Same as epoll_create but with an additional FLAGS parameter.  */
00105 extern int epoll_create2 (int __size, int __flags) __THROW;
00106 
00107 
00108 /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
00109    -1 in case of error ( the "errno" variable will contain the
00110    specific error code ) The "op" parameter is one of the EPOLL_CTL_*
00111    constants defined above. The "fd" parameter is the target of the
00112    operation. The "event" parameter describes which events the caller
00113    is interested in and any associated user data.  */
00114 extern int epoll_ctl (int __epfd, int __op, int __fd,
00115                     struct epoll_event *__event) __THROW;
00116 
00117 
00118 /* Wait for events on an epoll instance "epfd". Returns the number of
00119    triggered events returned in "events" buffer. Or -1 in case of
00120    error with the "errno" variable set to the specific error code. The
00121    "events" parameter is a buffer that will contain triggered
00122    events. The "maxevents" is the maximum number of events to be
00123    returned ( usually size of "events" ). The "timeout" parameter
00124    specifies the maximum wait time in milliseconds (-1 == infinite).
00125 
00126    This function is a cancellation point and therefore not marked with
00127    __THROW.  */
00128 extern int epoll_wait (int __epfd, struct epoll_event *__events,
00129                      int __maxevents, int __timeout);
00130 
00131 
00132 /* Same as epoll_wait, but the thread's signal mask is temporarily
00133    and atomically replaced with the one provided as parameter.
00134 
00135    This function is a cancellation point and therefore not marked with
00136    __THROW.  */
00137 extern int epoll_pwait (int __epfd, struct epoll_event *__events,
00138                      int __maxevents, int __timeout,
00139                      __const __sigset_t *__ss);
00140 
00141 __END_DECLS
00142 
00143 #endif /* sys/epoll.h */