• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2002 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3 
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8 
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18 
19 #ifndef	_SYS_EPOLL_H
20 #define	_SYS_EPOLL_H	1
21 
22 #include <stdint.h>
23 #include <sys/types.h>
24 
25 
26 enum EPOLL_EVENTS
27   {
28     EPOLLIN = 0x001,
29 #define EPOLLIN EPOLLIN
30     EPOLLPRI = 0x002,
31 #define EPOLLPRI EPOLLPRI
32     EPOLLOUT = 0x004,
33 #define EPOLLOUT EPOLLOUT
34     EPOLLRDNORM = 0x040,
35 #define EPOLLRDNORM EPOLLRDNORM
36     EPOLLRDBAND = 0x080,
37 #define EPOLLRDBAND EPOLLRDBAND
38     EPOLLWRNORM = 0x100,
39 #define EPOLLWRNORM EPOLLWRNORM
40     EPOLLWRBAND = 0x200,
41 #define EPOLLWRBAND EPOLLWRBAND
42     EPOLLMSG = 0x400,
43 #define EPOLLMSG EPOLLMSG
44     EPOLLERR = 0x008,
45 #define EPOLLERR EPOLLERR
46     EPOLLHUP = 0x010,
47 #define EPOLLHUP EPOLLHUP
48     EPOLLONESHOT = (1 << 30),
49 #define EPOLLONESHOT EPOLLONESHOT
50     EPOLLET = (1 << 31)
51 #define EPOLLET EPOLLET
52 
53   };
54 
55 
56 /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl().  */
57 #define EPOLL_CTL_ADD 1	/* Add a file decriptor to the interface.  */
58 #define EPOLL_CTL_DEL 2	/* Remove a file decriptor from the interface.  */
59 #define EPOLL_CTL_MOD 3	/* Change file decriptor epoll_event structure.  */
60 
61 
62 /*
63  * On x86-64 make the 64bit structure have the same alignment as the
64  * 32bit structure. This makes 32bit emulation easier.
65  */
66 #ifdef __x86_64__
67 #define EPOLL_PACKED __attribute__((packed))
68 #else
69 #define EPOLL_PACKED
70 #endif
71 
72 
73 typedef union epoll_data
74 {
75   void *ptr;
76   int fd;
77   uint32_t u32;
78   uint64_t u64;
79 } epoll_data_t;
80 
81 struct epoll_event
82 {
83   uint32_t events;	/* Epoll events */
84   epoll_data_t data;	/* User data variable */
85 } EPOLL_PACKED;
86 
87 
88 __BEGIN_DECLS
89 
90 /* Creates an epoll instance.  Returns an fd for the new instance.
91    The "size" parameter is a hint specifying the number of file
92    descriptors to be associated with the new instance.  The fd
93    returned by epoll_create() should be closed with close().  */
94 extern int epoll_create (int __size) __THROW;
95 
96 
97 /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
98    -1 in case of error ( the "errno" variable will contain the
99    specific error code ) The "op" parameter is one of the EPOLL_CTL_*
100    constants defined above. The "fd" parameter is the target of the
101    operation. The "event" parameter describes which events the caller
102    is interested in and any associated user data.  */
103 extern int epoll_ctl (int __epfd, int __op, int __fd,
104 		      struct epoll_event *__event) __THROW;
105 
106 
107 /* Wait for events on an epoll instance "epfd". Returns the number of
108    triggered events returned in "events" buffer. Or -1 in case of
109    error with the "errno" variable set to the specific error code. The
110    "events" parameter is a buffer that will contain triggered
111    events. The "maxevents" is the maximum number of events to be
112    returned ( usually size of "events" ). The "timeout" parameter
113    specifies the maximum wait time in milliseconds (-1 == infinite).  */
114 extern int epoll_wait (int __epfd, struct epoll_event *__events,
115 		       int __maxevents, int __timeout) __THROW;
116 
117 __END_DECLS
118 
119 #endif /* sys/epoll.h */
120