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