]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/sys/epoll.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / sys / epoll.h
CommitLineData
f7a9f785 1/* Copyright (C) 2002-2016 Free Software Foundation, Inc.
ad3bf20c
UD
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
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
ad3bf20c
UD
17
18#ifndef _SYS_EPOLL_H
19#define _SYS_EPOLL_H 1
20
30969512 21#include <stdint.h>
ad3bf20c
UD
22#include <sys/types.h>
23
11bf311e
UD
24/* Get __sigset_t. */
25#include <bits/sigset.h>
26
27#ifndef __sigset_t_defined
28# define __sigset_t_defined
29typedef __sigset_t sigset_t;
30#endif
31
599af3ca
JM
32/* Get the platform-dependent flags. */
33#include <bits/epoll.h>
ad3bf20c 34
599af3ca
JM
35#ifndef __EPOLL_PACKED
36# define __EPOLL_PACKED
37#endif
bdcebfc4
UD
38
39
ad3bf20c
UD
40enum EPOLL_EVENTS
41 {
42 EPOLLIN = 0x001,
43#define EPOLLIN EPOLLIN
44 EPOLLPRI = 0x002,
45#define EPOLLPRI EPOLLPRI
46 EPOLLOUT = 0x004,
47#define EPOLLOUT EPOLLOUT
48 EPOLLRDNORM = 0x040,
49#define EPOLLRDNORM EPOLLRDNORM
50 EPOLLRDBAND = 0x080,
51#define EPOLLRDBAND EPOLLRDBAND
52 EPOLLWRNORM = 0x100,
53#define EPOLLWRNORM EPOLLWRNORM
54 EPOLLWRBAND = 0x200,
55#define EPOLLWRBAND EPOLLWRBAND
56 EPOLLMSG = 0x400,
57#define EPOLLMSG EPOLLMSG
58 EPOLLERR = 0x008,
59#define EPOLLERR EPOLLERR
5e826ab5 60 EPOLLHUP = 0x010,
ad3bf20c 61#define EPOLLHUP EPOLLHUP
94833f11
UD
62 EPOLLRDHUP = 0x2000,
63#define EPOLLRDHUP EPOLLRDHUP
f8d44fdc
AJ
64 EPOLLWAKEUP = 1u << 29,
65#define EPOLLWAKEUP EPOLLWAKEUP
4920765e 66 EPOLLONESHOT = 1u << 30,
e11676dd 67#define EPOLLONESHOT EPOLLONESHOT
4920765e 68 EPOLLET = 1u << 31
5e826ab5 69#define EPOLLET EPOLLET
ad3bf20c
UD
70 };
71
72
73/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
bdcebfc4
UD
74#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */
75#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
76#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
ad3bf20c
UD
77
78
79typedef union epoll_data
80{
81 void *ptr;
82 int fd;
83 uint32_t u32;
84 uint64_t u64;
85} epoll_data_t;
86
87struct epoll_event
88{
89 uint32_t events; /* Epoll events */
90 epoll_data_t data; /* User data variable */
599af3ca 91} __EPOLL_PACKED;
ad3bf20c
UD
92
93
94__BEGIN_DECLS
95
96/* Creates an epoll instance. Returns an fd for the new instance.
97 The "size" parameter is a hint specifying the number of file
98 descriptors to be associated with the new instance. The fd
99 returned by epoll_create() should be closed with close(). */
100extern int epoll_create (int __size) __THROW;
101
ebcc1f4d
UD
102/* Same as epoll_create but with an FLAGS parameter. The unused SIZE
103 parameter has been dropped. */
104extern int epoll_create1 (int __flags) __THROW;
bdcebfc4 105
ad3bf20c
UD
106
107/* Manipulate an epoll instance "epfd". Returns 0 in case of success,
108 -1 in case of error ( the "errno" variable will contain the
109 specific error code ) The "op" parameter is one of the EPOLL_CTL_*
110 constants defined above. The "fd" parameter is the target of the
111 operation. The "event" parameter describes which events the caller
112 is interested in and any associated user data. */
113extern int epoll_ctl (int __epfd, int __op, int __fd,
114 struct epoll_event *__event) __THROW;
115
116
117/* Wait for events on an epoll instance "epfd". Returns the number of
118 triggered events returned in "events" buffer. Or -1 in case of
119 error with the "errno" variable set to the specific error code. The
120 "events" parameter is a buffer that will contain triggered
121 events. The "maxevents" is the maximum number of events to be
122 returned ( usually size of "events" ). The "timeout" parameter
7761a3ac
UD
123 specifies the maximum wait time in milliseconds (-1 == infinite).
124
125 This function is a cancellation point and therefore not marked with
126 __THROW. */
ad3bf20c 127extern int epoll_wait (int __epfd, struct epoll_event *__events,
7761a3ac 128 int __maxevents, int __timeout);
ad3bf20c 129
11bf311e
UD
130
131/* Same as epoll_wait, but the thread's signal mask is temporarily
132 and atomically replaced with the one provided as parameter.
133
134 This function is a cancellation point and therefore not marked with
135 __THROW. */
136extern int epoll_pwait (int __epfd, struct epoll_event *__events,
137 int __maxevents, int __timeout,
a784e502 138 const __sigset_t *__ss);
11bf311e 139
ad3bf20c
UD
140__END_DECLS
141
142#endif /* sys/epoll.h */