2 * wepoll - epoll for Windows
3 * https://github.com/piscisaureus/wepoll
5 * Copyright 2012-2020, Bert Belder <bertbelder@gmail.com>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 EPOLLIN = (int) (1U << 0),
41 EPOLLPRI = (int) (1U << 1),
42 EPOLLOUT = (int) (1U << 2),
43 EPOLLERR = (int) (1U << 3),
44 EPOLLHUP = (int) (1U << 4),
45 EPOLLRDNORM = (int) (1U << 6),
46 EPOLLRDBAND = (int) (1U << 7),
47 EPOLLWRNORM = (int) (1U << 8),
48 EPOLLWRBAND = (int) (1U << 9),
49 EPOLLMSG = (int) (1U << 10), /* Never reported. */
50 EPOLLRDHUP = (int) (1U << 13),
51 EPOLLONESHOT = (int) (1U << 31)
54 #define EPOLLIN (1U << 0)
55 #define EPOLLPRI (1U << 1)
56 #define EPOLLOUT (1U << 2)
57 #define EPOLLERR (1U << 3)
58 #define EPOLLHUP (1U << 4)
59 #define EPOLLRDNORM (1U << 6)
60 #define EPOLLRDBAND (1U << 7)
61 #define EPOLLWRNORM (1U << 8)
62 #define EPOLLWRBAND (1U << 9)
63 #define EPOLLMSG (1U << 10)
64 #define EPOLLRDHUP (1U << 13)
65 #define EPOLLONESHOT (1U << 31)
67 #define EPOLL_CTL_ADD 1
68 #define EPOLL_CTL_MOD 2
69 #define EPOLL_CTL_DEL 3
72 typedef uintptr_t SOCKET;
74 typedef union epoll_data {
79 SOCKET sock; /* Windows specific */
80 HANDLE hnd; /* Windows specific */
84 uint32_t events; /* Epoll events and flags */
85 epoll_data_t data; /* User data variable */
92 WEPOLL_EXPORT HANDLE epoll_create(int size);
93 WEPOLL_EXPORT HANDLE epoll_create1(int flags);
95 WEPOLL_EXPORT int epoll_close(HANDLE ephnd);
97 WEPOLL_EXPORT int epoll_ctl(HANDLE ephnd,
100 struct epoll_event* event);
102 WEPOLL_EXPORT int epoll_wait(HANDLE ephnd,
103 struct epoll_event* events,
111 #endif /* WEPOLL_H_ */