Compare commits
277 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0598a791bf | ||
|
|
e215682be2 | ||
|
|
8ddde74704 | ||
|
|
990ab03d70 | ||
|
|
98decd24e2 | ||
|
|
1c549c3ab7 | ||
|
|
dcaa6606e0 | ||
|
|
4a7e05917f | ||
|
|
f8325fba92 | ||
|
|
71e9ea6664 | ||
|
|
e9fa25980b | ||
|
|
2ce1a56c40 | ||
|
|
f8a135487d | ||
|
|
07af653b17 | ||
|
|
78bb46e678 | ||
|
|
fa78be3f47 | ||
|
|
469cb335c1 | ||
|
|
8dc6115127 | ||
|
|
8223744d7b | ||
|
|
81411367b5 | ||
|
|
126c00944c | ||
|
|
532d57ed31 | ||
|
|
8128da416c | ||
|
|
4fe5f50f22 | ||
|
|
efa35adbc5 | ||
|
|
3ad20d71ff | ||
|
|
4536518f8a | ||
|
|
bb6c522d8f | ||
|
|
d272c5188d | ||
|
|
dd7dd6fcd9 | ||
|
|
c57eb84863 | ||
|
|
8cd6e896cd | ||
|
|
d87deefada | ||
|
|
a11398b1c5 | ||
|
|
8c98df30da | ||
|
|
d5f8f5f1b1 | ||
|
|
a627f365fd | ||
|
|
027fb4a419 | ||
|
|
7080d540e2 | ||
|
|
017fa62aac | ||
|
|
06dd355e33 | ||
|
|
20af8d02c7 | ||
|
|
cf4530307f | ||
|
|
0088a1f263 | ||
|
|
4727adafb7 | ||
|
|
65b4e44abd | ||
|
|
e9bf27c395 | ||
|
|
adf44ab203 | ||
|
|
f196d9fc31 | ||
|
|
870273c60d | ||
|
|
ec78f05d70 | ||
|
|
2cd1a594d4 | ||
|
|
b7289278e1 | ||
|
|
b55b10a934 | ||
|
|
210f4f8fba | ||
|
|
fca062c60d | ||
|
|
11633bf403 | ||
|
|
1bc78625f0 | ||
|
|
97276ce4dd | ||
|
|
a82802933a | ||
|
|
653545fd35 | ||
|
|
7274ddd9fb | ||
|
|
6cf7a01f4a | ||
|
|
bf5e17e5c5 | ||
|
|
5c32cea921 | ||
|
|
8b7b340610 | ||
|
|
a9e78ad9b5 | ||
|
|
d6144b2e83 | ||
|
|
43f8095c14 | ||
|
|
f5ad7a4657 | ||
|
|
040ba6e466 | ||
|
|
0857889a0f | ||
|
|
61a794d0fb | ||
|
|
9a2efd9db7 | ||
|
|
21deebe236 | ||
|
|
006dc04624 | ||
|
|
dc895c6dec | ||
|
|
4a741f3271 | ||
|
|
ec63f7f473 | ||
|
|
d78d67632d | ||
|
|
f704614aa2 | ||
|
|
02bddcd1a9 | ||
|
|
5dacd46a94 | ||
|
|
e61acfab97 | ||
|
|
f813598587 | ||
|
|
9fa0461e33 | ||
|
|
95c6d8b7a1 | ||
|
|
6e50accebe | ||
|
|
44f357ab2e | ||
|
|
dd65a0c06b | ||
|
|
74e6f02ee4 | ||
|
|
49146ab381 | ||
|
|
513410278d | ||
|
|
e7e2cd478a | ||
|
|
4e685dcf29 | ||
|
|
6146716d4a | ||
|
|
64b714ab36 | ||
|
|
613a821a30 | ||
|
|
8f4d4e9602 | ||
|
|
042bfd32f3 | ||
|
|
bcc72f8ec5 | ||
|
|
4e21e8411e | ||
|
|
cb50462b77 | ||
|
|
52e3f7d596 | ||
|
|
3e2cc6379f | ||
|
|
73af86d1f5 | ||
|
|
a919a57ad2 | ||
|
|
2e882a5dfe | ||
|
|
0a817e84ec | ||
|
|
3098a3cda5 | ||
|
|
a60d90a26a | ||
|
|
fa16c36d95 | ||
|
|
354e56be7e | ||
|
|
3e3251e0d9 | ||
|
|
e3c63df748 | ||
|
|
24dda1ef62 | ||
|
|
8e4f574d37 | ||
|
|
f00c18e323 | ||
|
|
1e5def7413 | ||
|
|
52c9a3722a | ||
|
|
3512e8324a | ||
|
|
33a6ee6889 | ||
|
|
2e4627ba4a | ||
|
|
6f6c32628a | ||
|
|
b9b4cc7686 | ||
|
|
7c57e19298 | ||
|
|
74d7624afd | ||
|
|
fb9820b06c | ||
|
|
55d08bee97 | ||
|
|
5b7b5b0ed4 | ||
|
|
0fbf0e2b0e | ||
|
|
7c52fee8be | ||
|
|
279315afcd | ||
|
|
c3506ab046 | ||
|
|
3315e2fb1b | ||
|
|
5323fa751b | ||
|
|
b895c1866e | ||
|
|
065fee7b29 | ||
|
|
6353061ecf | ||
|
|
578f056670 | ||
|
|
1714c32f13 | ||
|
|
ed63069469 | ||
|
|
45159cb572 | ||
|
|
7d5eff6737 | ||
|
|
1bcd5d35e3 | ||
|
|
564db33b82 | ||
|
|
d6845acd26 | ||
|
|
56f2d70ce3 | ||
|
|
8ac9b204da | ||
|
|
f4cfe68f5b | ||
|
|
5313db4399 | ||
|
|
df7abafe96 | ||
|
|
cab89ae16a | ||
|
|
1a8573c4c1 | ||
|
|
5bcde85f8b | ||
|
|
c07cc8f7cc | ||
|
|
dfeefa8780 | ||
|
|
6a932e0daf | ||
|
|
607ed77216 | ||
|
|
a54e813d2f | ||
|
|
2789bad793 | ||
|
|
c69f361564 | ||
|
|
ba343a0898 | ||
|
|
de68d70f9c | ||
|
|
9d61ddfddb | ||
|
|
06342920d6 | ||
|
|
e7e8385354 | ||
|
|
075e1cef0b | ||
|
|
7fc24cef64 | ||
|
|
47497ee19d | ||
|
|
002c7f0899 | ||
|
|
cb43cb5c06 | ||
|
|
2b59b3295c | ||
|
|
01714be0d2 | ||
|
|
727786c6ee | ||
|
|
7dc6890500 | ||
|
|
9799eec661 | ||
|
|
3db46f068f | ||
|
|
3fd1466c56 | ||
|
|
b5356bac0f | ||
|
|
18931462bd | ||
|
|
437fb2f24c | ||
|
|
cdd70c9e3d | ||
|
|
fabbb839c1 | ||
|
|
bde80b0938 | ||
|
|
38ac088e7a | ||
|
|
3f24ebfa21 | ||
|
|
0b4788e2af | ||
|
|
2af6b901ba | ||
|
|
0ab1823431 | ||
|
|
b0fb981bc3 | ||
|
|
d8cf151f30 | ||
|
|
ac432c2cce | ||
|
|
b7ab093531 | ||
|
|
70c5a36e56 | ||
|
|
206dff3f6a | ||
|
|
d907d3f768 | ||
|
|
ed51c0a335 | ||
|
|
e358fdc430 | ||
|
|
d25f2bf8c4 | ||
|
|
ac0f54621b | ||
|
|
e10424bf58 | ||
|
|
1a2743cf5e | ||
|
|
1ef60cb893 | ||
|
|
a2eeaa5f82 | ||
|
|
2b57c726c8 | ||
|
|
1ad34ec3f3 | ||
|
|
05c384b181 | ||
|
|
d84e928508 | ||
|
|
d26c10f852 | ||
|
|
42d714eded | ||
|
|
3bfdff4c8e | ||
|
|
d85c46f114 | ||
|
|
658775faee | ||
|
|
937b9a27fa | ||
|
|
7dcc3d5eab | ||
|
|
0f68b70114 | ||
|
|
093e6f5240 | ||
|
|
157cadf4e4 | ||
|
|
d448bdf8d8 | ||
|
|
04f956501a | ||
|
|
af5b83ac9d | ||
|
|
24ae64e042 | ||
|
|
097e4fef9a | ||
|
|
b5864f3a0f | ||
|
|
5b7ebc3b93 | ||
|
|
7cf7ecfef6 | ||
|
|
d8093dc167 | ||
|
|
30ca0a1319 | ||
|
|
42ccc11634 | ||
|
|
99ce867424 | ||
|
|
450292aebc | ||
|
|
86fbe53e70 | ||
|
|
6182e1ec73 | ||
|
|
4d6cb0ff5b | ||
|
|
ada9cb5910 | ||
|
|
9114b4232a | ||
|
|
f260365c45 | ||
|
|
05bad1e58b | ||
|
|
eecfb0e5e3 | ||
|
|
50f84cdc6b | ||
|
|
a11f4de81c | ||
|
|
e5a8d83c8b | ||
|
|
4159a14364 | ||
|
|
283aa5fe76 | ||
|
|
af9a6eb40f | ||
|
|
a2f6609d57 | ||
|
|
227ee0e63d | ||
|
|
c053eb280d | ||
|
|
bbeed7566c | ||
|
|
11d7a0395f | ||
|
|
d5b5b605c0 | ||
|
|
d83871797c | ||
|
|
dc1369886d | ||
|
|
69a297fd22 | ||
|
|
981b3caf4e | ||
|
|
98fc483e76 | ||
|
|
d76556797d | ||
|
|
2b07037dbb | ||
|
|
c751fb935f | ||
|
|
778082c38a | ||
|
|
614e5c493e | ||
|
|
11e6439c38 | ||
|
|
523bb0f8c0 | ||
|
|
f223463f12 | ||
|
|
712eaab58b | ||
|
|
3e3d414637 | ||
|
|
d64a5f282d | ||
|
|
7d3dd32b3d | ||
|
|
ceb44f6501 | ||
|
|
49f73f6723 | ||
|
|
c22de2ecab | ||
|
|
6209fd4850 | ||
|
|
f7e15f1ba8 | ||
|
|
b3335d9c19 | ||
|
|
63d3e3b2bc | ||
|
|
6c5ad68f48 |
28
LICENSE
Normal file
28
LICENSE
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
wepoll - epoll for Windows
|
||||||
|
https://github.com/piscisaureus/wepoll
|
||||||
|
|
||||||
|
Copyright 2012-2020, Bert Belder <bertbelder@gmail.com>
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
167
README.md
167
README.md
@ -1,18 +1,18 @@
|
|||||||
# wepoll - epoll for windows
|
# wepoll - epoll for windows
|
||||||
|
|
||||||
This library implements the
|
[![][ci status badge]][ci status link]
|
||||||
[epoll](http://man7.org/linux/man-pages/man7/epoll.7.html) API for
|
|
||||||
Windows applications. It attempts to be efficient, and to match the
|
This library implements the [epoll][man epoll] API for Windows
|
||||||
Linux API and as closely as possible.
|
applications. It is fast and scalable, and it closely resembles the API
|
||||||
|
and behavior of Linux' epoll.
|
||||||
|
|
||||||
## Rationale
|
## Rationale
|
||||||
|
|
||||||
Unlike Linux, OS X, and many other operating systems, Windows doesn't
|
Unlike Linux, OS X, and many other operating systems, Windows doesn't
|
||||||
have a good API for receiving socket state notifications. It only
|
have a good API for receiving socket state notifications. It only
|
||||||
supports the `select` and `WSAPoll` APIs, but they
|
supports the `select` and `WSAPoll` APIs, but they
|
||||||
[don't scale](https://daniel.haxx.se/docs/poll-vs-select.html)
|
[don't scale][select scale] and suffer from
|
||||||
and suffer from
|
[other issues][wsapoll broken].
|
||||||
[other issues](https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/).
|
|
||||||
|
|
||||||
Using I/O completion ports isn't always practical when software is
|
Using I/O completion ports isn't always practical when software is
|
||||||
designed to be cross-platform. Wepoll offers an alternative that is
|
designed to be cross-platform. Wepoll offers an alternative that is
|
||||||
@ -21,37 +21,40 @@ to run on Linux.
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* can poll 100000s of sockets efficiently
|
* Can poll 100000s of sockets efficiently.
|
||||||
* fully thread safe
|
* Fully thread-safe.
|
||||||
* multiple threads can poll the same epoll port
|
* Multiple threads can poll the same epoll port.
|
||||||
* sockets can be added to multiple epoll sets
|
* Sockets can be added to multiple epoll sets.
|
||||||
* polling for `EPOLLIN`, `EPOLLOUT`, `EPOLLPRI`, `EPOLLRDHUP`,
|
* All epoll events (`EPOLLIN`, `EPOLLOUT`, `EPOLLPRI`, `EPOLLRDHUP`)
|
||||||
`EPOLLHUP`, and `EPOLLERR` events
|
are supported.
|
||||||
* `EPOLLONESTHOT` flag
|
* Level-triggered and one-shot (`EPOLLONESTHOT`) modes are supported
|
||||||
|
* Trivial to embed: you need [only two files][dist].
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
* only works with sockets
|
* Only works with sockets.
|
||||||
* some modes not suported: `EPOLLET`, `EPOLLEXCLUSIVE`
|
* Edge-triggered (`EPOLLET`) mode isn't supported.
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
The library is distributed as a single source file (wepoll.c) and a
|
The library is [distributed][dist] as a single source file
|
||||||
single header file (wepoll.h). Compile the .c file as part of your
|
([wepoll.c][wepoll.c]) and a single header file ([wepoll.h][wepoll.h]).<br>
|
||||||
project, and include the header wherever needed.
|
Compile the .c file as part of your project, and include the header wherever
|
||||||
|
needed.
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
* Requires Windows 7 or higher.
|
* Requires Windows Vista or higher.
|
||||||
* Can be compiled with recent versions of MSVC and Clang.
|
* Can be compiled with recent versions of MSVC, Clang, and GCC.
|
||||||
* GCC (mingw) should work (but is untested).
|
|
||||||
|
|
||||||
## API notes
|
## API
|
||||||
|
|
||||||
### General
|
### General remarks
|
||||||
|
|
||||||
* The epoll port is a `HANDLE`, not a file descriptor.
|
* The epoll port is a `HANDLE`, not a file descriptor.
|
||||||
* All functions set both `errno` and `GetLastError()` on failure.
|
* All functions set both `errno` and `GetLastError()` on failure.
|
||||||
|
* For more extensive documentation, see the [epoll(7) man page][man epoll],
|
||||||
|
and the per-function man pages that are linked below.
|
||||||
|
|
||||||
### epoll_create/epoll_create1
|
### epoll_create/epoll_create1
|
||||||
|
|
||||||
@ -61,10 +64,10 @@ HANDLE epoll_create1(int flags);
|
|||||||
```
|
```
|
||||||
|
|
||||||
* Create a new epoll instance (port).
|
* Create a new epoll instance (port).
|
||||||
* `size` is ignored but most be nonzero.
|
* `size` is ignored but most be greater than zero.
|
||||||
* `flags` must be zero as there are no supported flags.
|
* `flags` must be zero as there are no supported flags.
|
||||||
* Returns `INVALID_HANDLE_VALUE` on failure.
|
* Returns `NULL` on failure.
|
||||||
* [man page](http://man7.org/linux/man-pages/man2/epoll_create.2.html)
|
* [Linux man page][man epoll_create]
|
||||||
|
|
||||||
### epoll_close
|
### epoll_close
|
||||||
|
|
||||||
@ -86,15 +89,22 @@ int epoll_ctl(HANDLE ephnd,
|
|||||||
```
|
```
|
||||||
|
|
||||||
* Control which socket events are monitored by an epoll port.
|
* Control which socket events are monitored by an epoll port.
|
||||||
* `ephnd` must be a HANDLE created by `epoll_create` or `epoll_create1`.
|
* `ephnd` must be a HANDLE created by
|
||||||
|
[`epoll_create()`](#epoll_createepoll_create1) or
|
||||||
|
[`epoll_create1()`](#epoll_createepoll_create1).
|
||||||
* `op` must be one of `EPOLL_CTL_ADD`, `EPOLL_CTL_MOD`, `EPOLL_CTL_DEL`.
|
* `op` must be one of `EPOLL_CTL_ADD`, `EPOLL_CTL_MOD`, `EPOLL_CTL_DEL`.
|
||||||
|
* `sock` must be a valid socket created by [`socket()`][msdn socket],
|
||||||
|
[`WSASocket()`][msdn wsasocket], or [`accept()`][msdn accept].
|
||||||
|
* `event` should be a pointer to a [`struct epoll_event`](#struct-epoll_event).<br>
|
||||||
|
If `op` is `EPOLL_CTL_DEL` then the `event` parameter is ignored, and it
|
||||||
|
may be `NULL`.
|
||||||
|
* Returns 0 on success, -1 on failure.
|
||||||
* It is recommended to always explicitly remove a socket from its epoll
|
* It is recommended to always explicitly remove a socket from its epoll
|
||||||
set using `EPOLL_CTL_MOD` *before* closing it. As on Linux, sockets
|
set using `EPOLL_CTL_DEL` *before* closing it.<br>
|
||||||
are automatically removed from the epoll set when they are closed, but
|
As on Linux, closed sockets are automatically removed from the epoll set, but
|
||||||
wepoll may not be able to detect this until the next call to
|
wepoll may not be able to detect that a socket was closed until the next call
|
||||||
`epoll_wait()`.
|
to [`epoll_wait()`](#epoll_wait).
|
||||||
* TODO: expand
|
* [Linux man page][man epoll_ctl]
|
||||||
* [man page](http://man7.org/linux/man-pages/man2/epoll_ctl.2.html)
|
|
||||||
|
|
||||||
### epoll_wait
|
### epoll_wait
|
||||||
|
|
||||||
@ -106,10 +116,87 @@ int epoll_wait(HANDLE ephnd,
|
|||||||
```
|
```
|
||||||
|
|
||||||
* Receive socket events from an epoll port.
|
* Receive socket events from an epoll port.
|
||||||
* Returns
|
* `events` should point to a caller-allocated array of
|
||||||
- -1 on failure
|
[`epoll_event`](#struct-epoll_event) structs, which will receive the
|
||||||
- 0 when a timeout occurs
|
reported events.
|
||||||
- \>0 the number of evens received
|
* `maxevents` is the maximum number of events that will be written to the
|
||||||
* TODO: expand
|
`events` array, and must be greater than zero.
|
||||||
* [man page](http://man7.org/linux/man-pages/man2/epoll_wait.2.html)
|
* `timeout` specifies whether to block when no events are immediately available.
|
||||||
|
- `<0` block indefinitely
|
||||||
|
- `0` report any events that are already waiting, but don't block
|
||||||
|
- `≥1` block for at most N milliseconds
|
||||||
|
* Return value:
|
||||||
|
- `-1` an error occurred
|
||||||
|
- `0` timed out without any events to report
|
||||||
|
- `≥1` the number of events stored in the `events` buffer
|
||||||
|
* [Linux man page][man epoll_wait]
|
||||||
|
|
||||||
|
### struct epoll_event
|
||||||
|
|
||||||
|
```c
|
||||||
|
typedef union epoll_data {
|
||||||
|
void* ptr;
|
||||||
|
int fd;
|
||||||
|
uint32_t u32;
|
||||||
|
uint64_t u64;
|
||||||
|
SOCKET sock; /* Windows specific */
|
||||||
|
HANDLE hnd; /* Windows specific */
|
||||||
|
} epoll_data_t;
|
||||||
|
```
|
||||||
|
|
||||||
|
```c
|
||||||
|
struct epoll_event {
|
||||||
|
uint32_t events; /* Epoll events and flags */
|
||||||
|
epoll_data_t data; /* User data variable */
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
* The `events` field is a bit mask containing the events being
|
||||||
|
monitored/reported, and optional flags.<br>
|
||||||
|
Flags are accepted by [`epoll_ctl()`](#epoll_ctl), but they are not reported
|
||||||
|
back by [`epoll_wait()`](#epoll_wait).
|
||||||
|
* The `data` field can be used to associate application-specific information
|
||||||
|
with a socket; its value will be returned unmodified by
|
||||||
|
[`epoll_wait()`](#epoll_wait).
|
||||||
|
* [Linux man page][man epoll_ctl]
|
||||||
|
|
||||||
|
| Event | Description |
|
||||||
|
|---------------|----------------------------------------------------------------------|
|
||||||
|
| `EPOLLIN` | incoming data available, or incoming connection ready to be accepted |
|
||||||
|
| `EPOLLOUT` | ready to send data, or outgoing connection successfully established |
|
||||||
|
| `EPOLLRDHUP` | remote peer initiated graceful socket shutdown |
|
||||||
|
| `EPOLLPRI` | out-of-band data available for reading |
|
||||||
|
| `EPOLLERR` | socket error<sup>1</sup> |
|
||||||
|
| `EPOLLHUP` | socket hang-up<sup>1</sup> |
|
||||||
|
| `EPOLLRDNORM` | same as `EPOLLIN` |
|
||||||
|
| `EPOLLRDBAND` | same as `EPOLLPRI` |
|
||||||
|
| `EPOLLWRNORM` | same as `EPOLLOUT` |
|
||||||
|
| `EPOLLWRBAND` | same as `EPOLLOUT` |
|
||||||
|
| `EPOLLMSG` | never reported |
|
||||||
|
|
||||||
|
| Flag | Description |
|
||||||
|
|------------------|---------------------------|
|
||||||
|
| `EPOLLONESHOT` | report event(s) only once |
|
||||||
|
| `EPOLLET` | not supported by wepoll |
|
||||||
|
| `EPOLLEXCLUSIVE` | not supported by wepoll |
|
||||||
|
| `EPOLLWAKEUP` | not supported by wepoll |
|
||||||
|
|
||||||
|
<sup>1</sup>: the `EPOLLERR` and `EPOLLHUP` events may always be reported by
|
||||||
|
[`epoll_wait()`](#epoll_wait), regardless of the event mask that was passed to
|
||||||
|
[`epoll_ctl()`](#epoll_ctl).
|
||||||
|
|
||||||
|
|
||||||
|
[ci status badge]: https://ci.appveyor.com/api/projects/status/github/piscisaureus/wepoll?branch=master&svg=true
|
||||||
|
[ci status link]: https://ci.appveyor.com/project/piscisaureus/wepoll/branch/master
|
||||||
|
[dist]: https://github.com/piscisaureus/wepoll/tree/dist
|
||||||
|
[man epoll]: http://man7.org/linux/man-pages/man7/epoll.7.html
|
||||||
|
[man epoll_create]: http://man7.org/linux/man-pages/man2/epoll_create.2.html
|
||||||
|
[man epoll_ctl]: http://man7.org/linux/man-pages/man2/epoll_ctl.2.html
|
||||||
|
[man epoll_wait]: http://man7.org/linux/man-pages/man2/epoll_wait.2.html
|
||||||
|
[msdn accept]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737526(v=vs.85).aspx
|
||||||
|
[msdn socket]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740506(v=vs.85).aspx
|
||||||
|
[msdn wsasocket]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms742212(v=vs.85).aspx
|
||||||
|
[select scale]: https://daniel.haxx.se/docs/poll-vs-select.html
|
||||||
|
[wsapoll broken]: https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
|
||||||
|
[wepoll.c]: https://github.com/piscisaureus/wepoll/blob/dist/wepoll.c
|
||||||
|
[wepoll.h]: https://github.com/piscisaureus/wepoll/blob/dist/wepoll.h
|
||||||
|
|||||||
60
wepoll.h
60
wepoll.h
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* wepoll - epoll for Windows
|
* wepoll - epoll for Windows
|
||||||
* Copyright 2012-2017, Bert Belder. All rights reserved.
|
* https://github.com/piscisaureus/wepoll
|
||||||
*
|
*
|
||||||
* The red-black tree implementation:
|
* Copyright 2012-2020, Bert Belder <bertbelder@gmail.com>
|
||||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu> All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
@ -39,32 +39,32 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum EPOLL_EVENTS {
|
enum EPOLL_EVENTS {
|
||||||
EPOLLIN = 1 << 0,
|
EPOLLIN = (int) (1U << 0),
|
||||||
EPOLLPRI = 1 << 1,
|
EPOLLPRI = (int) (1U << 1),
|
||||||
EPOLLOUT = 1 << 2,
|
EPOLLOUT = (int) (1U << 2),
|
||||||
EPOLLERR = 1 << 3,
|
EPOLLERR = (int) (1U << 3),
|
||||||
EPOLLHUP = 1 << 4,
|
EPOLLHUP = (int) (1U << 4),
|
||||||
EPOLLRDNORM = 1 << 6,
|
EPOLLRDNORM = (int) (1U << 6),
|
||||||
EPOLLRDBAND = 1 << 7,
|
EPOLLRDBAND = (int) (1U << 7),
|
||||||
EPOLLWRNORM = 1 << 8,
|
EPOLLWRNORM = (int) (1U << 8),
|
||||||
EPOLLWRBAND = 1 << 9,
|
EPOLLWRBAND = (int) (1U << 9),
|
||||||
EPOLLMSG = 1 << 10,
|
EPOLLMSG = (int) (1U << 10), /* Never reported. */
|
||||||
EPOLLRDHUP = 1 << 13,
|
EPOLLRDHUP = (int) (1U << 13),
|
||||||
EPOLLONESHOT = 1 << 31
|
EPOLLONESHOT = (int) (1U << 31)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EPOLLIN EPOLLIN
|
#define EPOLLIN (1U << 0)
|
||||||
#define EPOLLPRI EPOLLPRI
|
#define EPOLLPRI (1U << 1)
|
||||||
#define EPOLLOUT EPOLLOUT
|
#define EPOLLOUT (1U << 2)
|
||||||
#define EPOLLERR EPOLLERR
|
#define EPOLLERR (1U << 3)
|
||||||
#define EPOLLHUP EPOLLHUP
|
#define EPOLLHUP (1U << 4)
|
||||||
#define EPOLLRDNORM EPOLLRDNORM
|
#define EPOLLRDNORM (1U << 6)
|
||||||
#define EPOLLRDBAND EPOLLRDBAND
|
#define EPOLLRDBAND (1U << 7)
|
||||||
#define EPOLLWRNORM EPOLLWRNORM
|
#define EPOLLWRNORM (1U << 8)
|
||||||
#define EPOLLWRBAND EPOLLWRBAND
|
#define EPOLLWRBAND (1U << 9)
|
||||||
#define EPOLLMSG EPOLLMSG
|
#define EPOLLMSG (1U << 10)
|
||||||
#define EPOLLRDHUP EPOLLRDHUP
|
#define EPOLLRDHUP (1U << 13)
|
||||||
#define EPOLLONESHOT EPOLLONESHOT
|
#define EPOLLONESHOT (1U << 31)
|
||||||
|
|
||||||
#define EPOLL_CTL_ADD 1
|
#define EPOLL_CTL_ADD 1
|
||||||
#define EPOLL_CTL_MOD 2
|
#define EPOLL_CTL_MOD 2
|
||||||
@ -78,12 +78,12 @@ typedef union epoll_data {
|
|||||||
int fd;
|
int fd;
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
SOCKET sock;
|
SOCKET sock; /* Windows specific */
|
||||||
HANDLE hnd;
|
HANDLE hnd; /* Windows specific */
|
||||||
} epoll_data_t;
|
} epoll_data_t;
|
||||||
|
|
||||||
struct epoll_event {
|
struct epoll_event {
|
||||||
uint32_t events; /* Epoll events */
|
uint32_t events; /* Epoll events and flags */
|
||||||
epoll_data_t data; /* User data variable */
|
epoll_data_t data; /* User data variable */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user