Compare commits

...

277 Commits
v1.0.2 ... dist

Author SHA1 Message Date
Bert Belder
0598a791bf
version 1.5.8 2020-06-29 04:38:00 +02:00
Bert Belder
e215682be2
win: use lower case file names when importing Windows SDK headers
Although the header files included in the official Windows SDK have
mixed case file names, MinGW opted to ship headers with entirely lower
case names.

Since the MinGW headers are often used when cross compiling Windows
binaries on Linux hosts, and Linux treats paths as case sensitive by
default, following the 'official' spelling breaks many cross build
setups.

Non-cross builds do not seem to be affected by using lower case file
names, and Microsoft also does not seem particularly consistent in the
way it spells header file names in e.g. documentation and sample code.

Therefore, this patch makes wepoll use lower case file names when
including Windows headers, regardless of whether MinGW or the official
SDK is used.

See also https://github.com/libevent/libevent/pull/1039
and https://github.com/stjepang/smol/issues/138.

Closes: https://github.com/piscisaureus/wepoll/pull/19
2020-06-29 04:18:06 +02:00
Bert Belder
8ddde74704
ci: add Visual Studio 2019 x86 and x64 test jobs 2020-06-29 03:32:01 +02:00
Bert Belder
990ab03d70
ci: use msvc x64 toolset to build x64 targets 2020-06-29 03:27:04 +02:00
Bert Belder
98decd24e2
src: use '#define's instead of global variables for integer constants
By doing this, it is no longer necessary to invoke `unused_var()` to
squelch compiler warnings about unused variables that are used only in
`assert()` calls. These `assert()` calls are removed by the preprocessor
in release builds, which causes these warnings.
2020-06-20 08:51:29 +02:00
Bert Belder
1c549c3ab7
ci: upgrade node.js to v12.x LTS 2020-06-20 08:51:29 +02:00
Bert Belder
dcaa6606e0
reflock: squelch clang warning about unused const var 'REFLOCK_DESTROY_MASK'
It is used, except when assertions are disabled due to the 'NDEBUG'
preprocessor variable being defined.
2020-06-04 03:02:50 +02:00
Bert Belder
4a7e05917f
src: inline some small and single-caller functions 2020-06-03 12:29:36 +02:00
Bert Belder
f8325fba92
ci: don't dump the entire environment into the build log 2020-05-26 19:24:53 +02:00
Bert Belder
71e9ea6664
tools/bundle: don't emit empty line when stripping 'clang-format on|off' comment 2020-05-26 19:07:03 +02:00
Bert Belder
e9fa25980b
config: re-enable overriding 'WEPOLL_EXPORT' when compiling bundle
This possibility got inadvertently removed in the big config refactor
(3ad20d7), which made building a shared library from the bundled source
distribution (as is done by e.g. vcpkg) impossible.
2020-05-26 19:07:03 +02:00
Bert Belder
2ce1a56c40
config: rename macro 'WEPOLL_INTERNAL_VAR' to 'WEPOLL_INTERNAL_EXTERN'
The old name was not really appropriate; this attribute should only be
used on variable declarations, while the definition of the same variable
needs to be tagged with 'WEPOLL_INTERNAL'.
2020-05-26 19:07:03 +02:00
Bert Belder
f8a135487d
src: improve code comments 2020-05-26 19:07:02 +02:00
Bert Belder
07af653b17
src: rename 'afd_helper' to the more descriptive 'afd_device' 2020-05-26 19:07:02 +02:00
Bert Belder
78bb46e678
port,sock: minor tweaks to 'alloc()' and 'free()' functions 2020-05-26 18:57:00 +02:00
Bert Belder
fa78be3f47
version 1.5.7 2020-05-15 22:38:42 +02:00
Bert Belder
469cb335c1
dist: merge release tag v1.5.7 2020-05-15 22:38:42 +02:00
Bert Belder
8dc6115127
ws: add workaround for Komodia based LSPs that break SIO_BASE_HANDLE 2020-05-13 01:31:16 +02:00
Bert Belder
8223744d7b
port: drop '_handle' suffix from 'port_(un)register_socket()' function names 2020-05-12 03:56:30 +02:00
Bert Belder
81411367b5
queue: rename functions to make their purpose more obvious 2020-05-12 03:56:29 +02:00
Bert Belder
126c00944c
test: make the memory leak checker for tests work again
It turns out that these static constructors declared with
`__declspec(allocate(".CRT$XCU"))` don't work if you try to link them
from a static library. With this patch we go back to passing
'leak-check.c' as an extra source file when compiling a test.
2020-05-09 11:16:07 +02:00
Bert Belder
532d57ed31
style: use clang-format version 10.x 2020-05-09 11:06:23 +02:00
Bert Belder
8128da416c
version 1.5.6 2020-01-13 00:26:46 +01:00
Bert Belder
4fe5f50f22
dist: merge release tag v1.5.6 2020-01-13 00:26:46 +01:00
Bert Belder
efa35adbc5
tree: rename 'FIXUP' macros to 'REBALANCE' 2020-01-13 00:15:16 +01:00
Bert Belder
3ad20d71ff
build: refactor config infrastructure and test build setup
* Configuration is now done with files, instead of through command line
  switches specified in CMakeLists.txt.
* Link tests with a static library instead of compiling individual
  wepoll source files as part of the test executable. This should make
  the CI run significantly faster.
2020-01-12 23:56:59 +01:00
Bert Belder
4536518f8a
tools/bundle: log files in which no include guards were found 2020-01-12 23:42:37 +01:00
Bert Belder
bb6c522d8f
tools/bundle: require include guards to end with '_H_' 2020-01-12 23:42:37 +01:00
Bert Belder
d272c5188d
tools/bundle: rename 'combine.js' to 'bundle.js' 2020-01-12 23:42:37 +01:00
Bert Belder
dd7dd6fcd9
build: rename configuration 'combined' to 'bundle' 2020-01-12 23:42:36 +01:00
Bert Belder
c57eb84863
build: work around bug in in Windows SDK 10.0.17763.0 and maybe other versions 2020-01-12 23:42:34 +01:00
Bert Belder
8cd6e896cd
test: fix clang warning caused by 'static_assert' polyfill 2020-01-12 23:42:07 +01:00
Bert Belder
d87deefada
doc: update copyright years 2020-01-12 23:42:06 +01:00
Bert Belder
a11398b1c5
api: fix typo in comment 2019-06-24 18:14:47 +02:00
Bert Belder
8c98df30da
gitignore: sort patterns 2019-06-24 18:14:47 +02:00
Bert Belder
d5f8f5f1b1
afd: use IO_STATUS_BLOCK instead of OVERLAPPED to track async poll ops
This reduces per-socket memory usage, as the OVERLAPPED structure
contains some fields that are never used.
2019-06-12 21:49:12 +02:00
Bert Belder
a627f365fd
src,test: clean up #include directives 2019-06-12 21:49:11 +02:00
Bert Belder
027fb4a419
util,test: remove definition and usage of type 'ssize_t' 2019-06-12 21:49:11 +02:00
Bert Belder
7080d540e2
build: do not force-include wepoll.h using a command line switch 2019-06-12 21:49:10 +02:00
Bert Belder
017fa62aac
tools/combine: fold identical 'typedef struct' declarations 2019-06-12 21:49:10 +02:00
Bert Belder
06dd355e33
tools: use prettier to format javascript files 2019-06-12 21:21:31 +02:00
Bert Belder
20af8d02c7
port: rename 'iocp' to 'iocp_handle' where appropriate 2019-05-17 13:56:37 -07:00
Bert Belder
cf4530307f
port: make the definition of 'struct port_state' private 2019-05-17 13:42:08 -07:00
Bert Belder
0088a1f263
sock: put functions in a more logical order 2019-05-17 13:42:08 -07:00
Bert Belder
4727adafb7
src: reformat with clang-format 8.0 2019-05-17 13:42:08 -07:00
Bert Belder
65b4e44abd
dist: merge release tag v1.5.5 2019-05-05 05:14:53 +02:00
Bert Belder
e9bf27c395
version 1.5.5 2019-05-05 05:14:52 +02:00
Bert Belder
adf44ab203
test: remove unnecessary semicolon from test-tree 2019-05-05 04:52:33 +02:00
Bert Belder
f196d9fc31
doc: update copyright years 2019-05-05 04:45:29 +02:00
Bert Belder
870273c60d
reflock: use proper access mask when creating keyed event 2018-12-06 08:54:12 +01:00
Bert Belder
ec78f05d70
nt: use documented parameter names for keyed event functions 2018-12-06 08:54:05 +01:00
Bert Belder
2cd1a594d4
nt: sort NT_NTDLL_IMPORT_LIST 2018-12-06 07:15:49 +01:00
Bert Belder
b7289278e1
reflock: make assert in reflock_unref() more strict, improve comments 2018-12-04 13:19:40 -08:00
Bert Belder
b55b10a934
reflock: use lowercase for hex digits consistently 2018-12-04 12:28:46 -08:00
Bert Belder
210f4f8fba
init: fix grammar and clarify comment 2018-11-26 16:43:01 -07:00
Bert Belder
fca062c60d
tools: remove optional parentheses around arrow function parameters 2018-11-26 15:52:40 -07:00
Bert Belder
11633bf403
tools/combine: use arrow functions for Array.map closures 2018-11-26 15:52:07 -07:00
Bert Belder
1bc78625f0
tools/release: simplify regex 2018-11-26 15:50:47 -07:00
Bert Belder
97276ce4dd
nt: remove unused LSA_UNICODE_STRING type 2018-11-25 23:31:23 -07:00
Bert Belder
a82802933a
build: strip clang-format on/off directives from combined source 2018-11-18 03:06:13 -08:00
Bert Belder
653545fd35
test: make test-connect-success-events more robust 2018-11-17 02:02:49 -08:00
Bert Belder
7274ddd9fb
version 1.5.4 2018-11-17 00:47:49 -08:00
Bert Belder
6cf7a01f4a
dist: merge release tag v1.5.4 2018-11-17 00:47:49 -08:00
Bert Belder
bf5e17e5c5
sock: avoid a syscall when cancelling already-completed poll operation 2018-11-17 00:43:49 -08:00
Bert Belder
5c32cea921
test: add test for 'connected socket always writable' bug 2018-11-17 00:43:48 -08:00
Bert Belder
8b7b340610
sock: fix EPOLLOUT always reported for outgoing connections
This fixes a bug that caused a socket to be always reported writable
after an outgoing connection was successfully established.
2018-11-17 00:43:48 -08:00
Bert Belder
a9e78ad9b5
test: add test for events reported after connect() fails 2018-11-17 00:43:48 -08:00
Bert Belder
d6144b2e83
sock: report the same events as linux when connect() fails 2018-11-17 00:43:48 -08:00
Bert Belder
43f8095c14
dist: include LICENSE file 2018-11-17 00:43:48 -08:00
Bert Belder
f5ad7a4657
build: clean up CMakeLists.txt 2018-11-16 21:10:10 -08:00
Bert Belder
040ba6e466
build: disable spectre diagnostic for Visual Studio 2015 2018-11-16 14:05:00 -08:00
Bert Belder
0857889a0f
dist: merge release tag v1.5.3 2018-09-06 23:21:01 +02:00
Bert Belder
61a794d0fb
version 1.5.3 2018-09-06 23:20:51 +02:00
Bert Belder
9a2efd9db7
nt: squelch novelty GCC 8 cast-function-type warnings 2018-09-06 22:26:59 +02:00
Bert Belder
21deebe236
dist: merge release tag v1.5.2 2018-07-26 03:47:03 +02:00
Bert Belder
006dc04624
version 1.5.2 2018-07-26 03:46:57 +02:00
Bert Belder
dc895c6dec
afd: use a simpler method to create AFD helper handles 2018-07-23 05:39:34 +02:00
Bert Belder
4a741f3271
ci: add test jobs that run with a non-IFS LSP installed 2018-07-14 06:27:44 +02:00
Bert Belder
ec63f7f473
ci: pin node.js version to v10.x 2018-07-14 06:02:59 +02:00
Bert Belder
d78d67632d
nt: simplify definition for IO_STATUS_BLOCK 2018-06-11 14:44:08 +02:00
Bert Belder
f704614aa2
nt: consistent nameing for NT_NTDLL_IMPORT_LIST 2018-06-11 14:39:28 +02:00
Bert Belder
02bddcd1a9
win: use #ifdef instead of #if defined() 2018-06-11 14:38:16 +02:00
Bert Belder
5dacd46a94
dist: merge release tag v1.5.1 2018-06-06 12:30:24 -07:00
Bert Belder
e61acfab97
version 1.5.1 2018-06-06 12:30:19 -07:00
Bert Belder
f813598587
src,test: use consistent naming style for private names 2018-06-06 11:37:43 -07:00
Bert Belder
9fa0461e33
win: always set _WIN32_WINNT to 0x0600 2018-06-05 17:32:31 -07:00
Bert Belder
95c6d8b7a1
afd: remove afd_poll() support for blocking operations
It's an internal API and this functionality is unused.
2018-06-04 23:55:31 -07:00
Bert Belder
6e50accebe
afd: use SetFileCompletionNotificationModes on driver sockets
This should slightly improve performance.
2018-06-04 23:55:31 -07:00
Bert Belder
44f357ab2e
afd: simplify afd_create_driver_socket() error-return logic 2018-06-04 23:55:30 -07:00
Bert Belder
dd65a0c06b
util: move static_assert polyfill to test-util.h
It's no longer used in the main source code.
2018-06-04 23:55:30 -07:00
Bert Belder
74e6f02ee4
reflock: use Interlocked functions directly, use long instead of uint32_t 2018-06-04 23:55:25 -07:00
Bert Belder
49146ab381
ws: make retry logic in ws_get_protocol_catalog() more readable 2018-06-04 23:12:28 -07:00
Bert Belder
513410278d
build: use GLOB instead of GLOB_RECURSE in cmake config 2018-06-01 13:54:38 -07:00
Bert Belder
e7e2cd478a
build: put tests in solution folder 2018-06-01 13:40:42 -07:00
Bert Belder
4e685dcf29
dist: merge release tag v1.5.0 2018-05-17 02:23:22 -07:00
Bert Belder
6146716d4a
version 1.5.0 2018-05-17 02:23:17 -07:00
Bert Belder
64b714ab36
port,sock: drop 'ep_' prefix, rename types to sock_state_t/port_state_t 2018-05-17 01:31:29 -07:00
Bert Belder
613a821a30
src: rename/remove macros that clang says have reserved names 2018-05-17 01:31:28 -07:00
Bert Belder
8f4d4e9602
src,test: squelch clang signed/unsigned conversion warnings 2018-05-17 01:31:28 -07:00
Bert Belder
042bfd32f3
test: add static qualifier to local functions in test-oneshot-and-hangup 2018-05-17 01:31:27 -07:00
Bert Belder
bcc72f8ec5
test: make clang use __attribute__((constructor)) to register leak checker 2018-05-17 01:31:27 -07:00
Bert Belder
4e21e8411e
test: surpress some overly pedantic clang warnings 2018-05-17 01:31:26 -07:00
Bert Belder
cb50462b77
afd: simplify definition of IOCTL_AFD_POLL 2018-05-17 01:31:26 -07:00
Bert Belder
52e3f7d596
nt: remove unused STATUS_* definitions 2018-05-17 01:31:25 -07:00
Bert Belder
3e2cc6379f
sock: squelch clang non-matching cast warning 2018-05-17 01:31:25 -07:00
Bert Belder
73af86d1f5
reflock: don't cast away constness from void pointers 2018-05-17 01:31:25 -07:00
Bert Belder
a919a57ad2
util: remove extra semicolon from static_assert() polyfill 2018-05-17 01:31:24 -07:00
Bert Belder
2e882a5dfe
util: remove 'unused_fn' macro which itself isn't used 2018-05-17 01:31:23 -07:00
Bert Belder
0a817e84ec
util: squelch clang cast alignment warning caused by container_of() 2018-05-17 01:31:23 -07:00
Bert Belder
3098a3cda5
util: don't define _SSIZE_T_DEFINED
Clang complains about it, and it's unnecessary anyway.
2018-05-17 01:31:23 -07:00
Bert Belder
a60d90a26a
ws: add out param for catalog entry count to ws_get_protocol_catalog()
This avoids a sign-conversion warning on clang 6.x.
2018-05-17 01:31:22 -07:00
Bert Belder
fa16c36d95
win: suppress clang reserved-id-macro warning when setting _WIN32_WINNT 2018-05-17 01:31:22 -07:00
Bert Belder
354e56be7e
win: use exact case when including Windows SDK header files
This prevents clang 6.x from emitting nonportable-system-include-path
warnings.
2018-05-17 01:31:21 -07:00
Bert Belder
3e3251e0d9
error: break up return_error() macro into two non-variadic macros
This prevents clang 6.x from emitting a
gnu-zero-variadic-macro-arguments warning.
2018-05-17 01:31:21 -07:00
Bert Belder
e3c63df748
error: make err_map_win_error_to_errno() a static function 2018-05-17 01:31:20 -07:00
Bert Belder
24dda1ef62
header: squelch clang warnings about recursive macro invocation 2018-05-17 01:31:20 -07:00
Bert Belder
8e4f574d37
header: squelch clang 6.x shift-sign-overflow warning 2018-05-17 01:31:20 -07:00
Bert Belder
f00c18e323
poll-group: rename _POLL_GROUP_MAX_SIZE to _POLL_GROUP_MAX_GROUP_SIZE 2018-05-17 01:31:19 -07:00
Bert Belder
1e5def7413
build: disable msvs 2017 spectre mitigation warning 2018-05-17 01:31:13 -07:00
Bert Belder
52c9a3722a
dist: merge release tag v1.4.2 2018-05-16 19:45:54 -07:00
Bert Belder
3512e8324a
version 1.4.2 2018-05-16 19:45:50 -07:00
Bert Belder
33a6ee6889
util: fix missing <assert.h> include 2018-05-04 02:45:40 +02:00
Bert Belder
2e4627ba4a
util: remove safe_container_of() macro 2018-05-04 02:45:40 +02:00
Bert Belder
6f6c32628a
thread-safe-tree: don't use safe_container_of() 2018-05-04 02:42:02 +02:00
Bert Belder
b9b4cc7686
sock: integrate _poll_req_t fields into ep_sock_t, and merge functions 2018-05-04 02:13:52 +02:00
Bert Belder
7c57e19298
sock: make all ep_sock_t fields private, remove _ep_sock_private_t 2018-05-03 23:27:41 +02:00
Bert Belder
74d7624afd
port: access ep_sock_t.tree_node and ep_sock_t.queue_node through getters 2018-05-03 23:27:40 +02:00
Bert Belder
fb9820b06c
src: improve phrasing of some comments, fix spelling error 2018-05-03 23:27:04 +02:00
Bert Belder
55d08bee97
port: assert that the update queue is empty before freeing 2018-05-03 23:25:55 +02:00
Bert Belder
5b7b5b0ed4
afd: remove unused event type and flag definitions 2018-05-03 14:40:52 +02:00
Bert Belder
0fbf0e2b0e
src: use more condensed style for short comments 2018-05-03 14:40:52 +02:00
Bert Belder
7c52fee8be
util: fix comments about polyfills 2018-05-03 14:40:52 +02:00
Bert Belder
279315afcd
src: add missing <string.h> includes 2018-05-03 14:40:51 +02:00
Bert Belder
c3506ab046
error: remove unnecessary include from error.h 2018-05-03 14:40:51 +02:00
Bert Belder
3315e2fb1b
sock: remove unnecessary forward declaration of poll_req_t 2018-05-03 14:40:51 +02:00
Bert Belder
5323fa751b
misc: remove javascript formatting rules from .clang-format 2018-05-03 14:40:51 +02:00
Bert Belder
b895c1866e
test: write newline before check() failure message 2018-05-03 14:40:50 +02:00
Bert Belder
065fee7b29
dist: merge release tag v1.4.1 2018-05-03 12:43:09 +02:00
Bert Belder
6353061ecf
version 1.4.1 2018-05-03 12:42:59 +02:00
Bert Belder
578f056670
src: rename 'reflock-tree' to 'thread-safe-tree' 2018-05-02 19:21:20 +02:00
Bert Belder
1714c32f13
afd: small fixes 2018-05-02 19:04:29 +02:00
Bert Belder
ed63069469
tree: make macros not look like functions 2018-05-02 19:04:04 +02:00
Bert Belder
45159cb572
dist: merge release tag v1.4.0 2018-05-02 07:12:56 +02:00
Bert Belder
7d5eff6737
version 1.4.0 2018-05-02 07:12:55 +02:00
Bert Belder
1bcd5d35e3
doc: readme tweaks 2018-05-02 07:07:48 +02:00
Bert Belder
564db33b82
doc: expand epoll_wait() documentation 2018-05-02 07:07:43 +02:00
Bert Belder
d6845acd26
doc: expand epoll_ctl() documentation 2018-05-02 07:07:42 +02:00
Bert Belder
56f2d70ce3
doc: document struct epoll_event, events and flags 2018-05-02 07:07:36 +02:00
Bert Belder
8ac9b204da
doc: make it more explicit that man pages are for Linux 2018-05-02 04:53:46 +02:00
Bert Belder
f4cfe68f5b
build: treat warnings as errors 2018-05-02 04:20:43 +02:00
Bert Belder
5313db4399
build: enable -Wextra for gcc and clang builds 2018-05-02 04:19:11 +02:00
Bert Belder
df7abafe96
ci: no longer allow LSP builds to fail 2018-05-02 04:19:11 +02:00
Bert Belder
cab89ae16a
ci: separate node.js and LSP installation steps 2018-05-02 03:50:43 +02:00
Bert Belder
1a8573c4c1
ci: write less verbose log output when installing the LSP 2018-05-02 03:50:43 +02:00
Bert Belder
5bcde85f8b
sock: call poll_group_acquire() and poll_group_release() directly 2018-05-02 03:50:42 +02:00
Bert Belder
c07cc8f7cc
poll-group: do away with the poll_group_allocator class 2018-05-02 03:50:42 +02:00
Bert Belder
dfeefa8780
error: remove error mapping for ERROR_DEVICE_FEATURE_NOT_SUPPORTED 2018-05-02 03:36:23 +02:00
Bert Belder
6a932e0daf
sock: rename 'afd_socket' to 'base_socket' 2018-05-02 03:06:35 +02:00
Bert Belder
607ed77216
sock: do not retrieve winsock protocol info for every socket 2018-05-02 03:06:35 +02:00
Bert Belder
a54e813d2f
sock: remove unnecessary header include 2018-05-02 03:06:35 +02:00
Bert Belder
2789bad793
afd: retrieve protocol info for afd driver socket on startup 2018-05-02 03:06:30 +02:00
Bert Belder
c69f361564
ws: move ws_get_base_socket() from afd.c to ws.c 2018-05-02 02:12:57 +02:00
Bert Belder
ba343a0898
afd: move afd provider guid list from header to c file 2018-05-01 23:57:54 +02:00
Bert Belder
de68d70f9c
port: fix unlikely bug in _ep_port_wait() time-out behavior 2018-05-01 22:44:32 +02:00
Bert Belder
9d61ddfddb
reflock: remove _sync_sub_and_fetch() 2018-05-01 22:11:13 +02:00
Bert Belder
06342920d6
tree: reduce code duplication 2018-05-01 22:02:45 +02:00
Bert Belder
e7e8385354
port: do not use separate poll groups for different socket types
It appears that this was never necessary after all.
2018-03-09 01:12:24 +01:00
Bert Belder
075e1cef0b
port: remove useless and ineffective locking from ep_port_delete() 2018-03-09 00:42:35 +01:00
Bert Belder
7fc24cef64
test: verify that IP and IPv6 sockets can coexist in the same epoll set 2018-03-09 00:42:31 +01:00
Bert Belder
47497ee19d
ws: report the correct error when WSAStartup() fails 2018-03-09 00:42:30 +01:00
Bert Belder
002c7f0899
src: add ws.c and ws.h for winsock-related stuff 2018-03-09 00:42:26 +01:00
Bert Belder
cb43cb5c06
ci: add experimental test environment with LSPs installed 2018-03-07 04:36:37 +01:00
Bert Belder
2b59b3295c
version 1.3.0 2018-02-12 02:19:35 +01:00
Bert Belder
01714be0d2
dist: merge release tag v1.3.0 2018-02-12 02:19:35 +01:00
Bert Belder
727786c6ee
tools: make release.js sign commits 2018-02-12 02:18:48 +01:00
Bert Belder
7dc6890500
tree: remove header-based red-black tree implementation 2018-02-12 01:40:07 +01:00
Bert Belder
9799eec661
tree: implement simpler version without macros 2018-02-12 01:40:07 +01:00
Bert Belder
3db46f068f
doc: update license 2018-02-12 01:40:06 +01:00
Bert Belder
3fd1466c56 tools: fix eslint errors 2018-01-05 18:03:39 +01:00
Bert Belder
b5356bac0f tools: clean up release.js 2018-01-05 18:03:33 +01:00
Bert Belder
18931462bd misc: add more eslint rules 2018-01-05 18:01:22 +01:00
Bert Belder
437fb2f24c tools: add release script 2017-12-11 23:57:41 +01:00
Bert Belder
cdd70c9e3d misc: switch from tsfmt to eslint 2017-12-11 23:55:04 +01:00
Bert Belder
fabbb839c1 gitignore: don't track .manifest files 2017-12-11 21:19:59 +01:00
Bert Belder
bde80b0938 version 1.2.4
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJaLqx0AAoJEHp3iHsuLtRhIGsH/19uFtGikwO+FKUhs+7+wyJL
 cu+SyL4VUYbR9qdTb3hwiwlJjkU0KaIGhEHvpjKykdEADhhMaHFMeSO5QYeVNnr+
 FI38O+JnmKbb17CtY9xmuRLhmurOj1TvNFF+pCbXoFTyI9uCc76Osdx9/9B1fPmV
 F1JBTHZSsEKivyWKeyfdbG+O1cAcXs1/NzPEvDlOeXO628GLTKD/G4Qa8l71+IKP
 Cj08vsSH5yZYXfTkR8CQNR1xAh9B5pGjH5nXX/++RxeZXBscGKzIK4JL2fbWTG24
 YS4FTbwaQAV+eTh/hbkk9bu7fdpAqYKLaQZ0cw4IAjigeozF8HqH2IJNp4KOitM=
 =Z2QT
 -----END PGP SIGNATURE-----

dist: merge release tag v1.2.4
2017-12-11 17:05:44 +01:00
Bert Belder
38ac088e7a version 1.2.4 2017-12-11 17:03:53 +01:00
Bert Belder
3f24ebfa21 doc: update readme prose 2017-12-09 23:30:06 +01:00
Bert Belder
0b4788e2af ci: add gcc and clang builds 2017-12-10 05:51:49 +01:00
Bert Belder
2af6b901ba util: define static_assert even if clang pretends to be msvc 2017-12-10 05:51:48 +01:00
Bert Belder
0ab1823431 dist: merge release tag v1.2.3 2017-12-09 23:30:50 +01:00
Bert Belder
b0fb981bc3 version 1.2.3 2017-12-09 23:30:06 +01:00
Bert Belder
d8cf151f30 port: change some internal method names 2017-12-09 23:28:23 +01:00
Bert Belder
ac432c2cce gitignore: ignore some compiler outputs 2017-12-09 23:28:23 +01:00
Bert Belder
b7ab093531 util: fix typo in _SSIZE_T_DEFINED 2017-12-09 23:28:23 +01:00
Bert Belder
70c5a36e56 build: create the dist/ directory in configure step 2017-12-09 23:28:23 +01:00
Bert Belder
206dff3f6a util: don't redefine static_assert if it's already defined 2017-12-09 23:28:19 +01:00
Bert Belder
d907d3f768 doc: update compatibility section in readme 2017-12-08 19:43:56 +01:00
Bert Belder
ed51c0a335 test: squelch gcc -Wparentheses warning 2017-12-08 19:41:41 +01:00
Bert Belder
e358fdc430 test: use portable printf format specifier for 64-bit integer 2017-12-08 19:41:41 +01:00
Bert Belder
d25f2bf8c4 test: move variable declarations to top of block 2017-12-08 19:41:41 +01:00
Bert Belder
ac0f54621b util: enable polyfills for gcc 2017-12-08 19:41:40 +01:00
Bert Belder
e10424bf58 win: polyfill ERROR_DEVICE_FEATURE_NOT_SUPPORTED definition for MinGW 2017-12-08 19:41:40 +01:00
Bert Belder
1a2743cf5e win: gcc doesn't grok #pragma warning 2017-12-08 19:41:40 +01:00
Bert Belder
1ef60cb893 win: ensure definitions for Vista or later are included 2017-12-08 19:41:40 +01:00
Bert Belder
a2eeaa5f82 src: move variable declarations to top of block 2017-12-08 19:34:52 +01:00
Bert Belder
2b57c726c8 util: move 'unused_fn' macro to from rb.h to util.h 2017-12-08 19:34:52 +01:00
Bert Belder
1ad34ec3f3 util: rename 'unused' macro to 'unused_var' 2017-12-08 19:34:52 +01:00
Bert Belder
05c384b181 src: rename WEPOLL_INTERNAL_EXTERN to WEPOLL_INTERNAL_VAR 2017-12-08 19:34:52 +01:00
Bert Belder
d84e928508 win: add missing comment after final #endif 2017-12-08 19:34:51 +01:00
Bert Belder
d26c10f852 nt: remove unnecessary '#ifdef _NTDEF_' condition 2017-12-08 19:34:51 +01:00
Bert Belder
42d714eded gitignore: ignore executable and library outputs 2017-12-08 19:34:51 +01:00
Bert Belder
3bfdff4c8e dist: merge release tag v1.2.2 2017-12-07 22:32:49 +01:00
Bert Belder
d85c46f114 version 1.2.2 2017-12-07 22:32:09 +01:00
Bert Belder
658775faee test: add epoll_ctl_mod() EEXIST and ENOENT tests to test-error 2017-12-07 22:30:54 +01:00
Bert Belder
937b9a27fa test: improve test-error readability 2017-12-07 22:26:08 +01:00
Bert Belder
7dcc3d5eab error: remove return_handle_error() and helpers 2017-12-07 22:06:11 +01:00
Bert Belder
0f68b70114 api: explicitly check handle validity in epoll_wait() 2017-12-07 22:04:17 +01:00
Bert Belder
093e6f5240 api: explicitly check handle validity in epoll_close() 2017-12-07 22:03:45 +01:00
Bert Belder
157cadf4e4 api: always check handle validity when epoll_ctl_mod() fails 2017-12-07 22:00:11 +01:00
Bert Belder
d448bdf8d8 error: make err_check_handle() an internal api 2017-12-07 21:37:58 +01:00
Bert Belder
04f956501a dist: merge release tag v1.2.1 2017-12-11 15:21:15 +01:00
Bert Belder
af5b83ac9d version 1.2.1 2017-12-07 19:12:52 +01:00
Bert Belder
24ae64e042 test: add more test cases to test-error 2017-12-07 19:09:35 +01:00
Bert Belder
097e4fef9a port: epoll_ctl() to report EBADF when both op and sock are invalid 2017-12-07 19:07:01 +01:00
Bert Belder
b5864f3a0f afd: report EPERM+ERROR_DEVICE_FEATURE_NOT_SUPPORTED for non-afd sockets 2017-12-07 18:01:49 +01:00
Bert Belder
5b7ebc3b93 ci: remove unnecessary branch filter from appveyor configuration 2017-12-07 05:23:39 +01:00
Bert Belder
7cf7ecfef6 build: remove run-cmake.bat 2017-12-07 04:50:40 +01:00
Bert Belder
d8093dc167 doc: add build status badge to readme 2017-12-07 04:44:41 +01:00
Bert Belder
30ca0a1319 ci: add appveyor configuration file 2017-12-07 04:42:57 +01:00
Bert Belder
42ccc11634 src: suppress warnings caused by Windows SDK headers 2017-12-07 04:42:37 +01:00
Bert Belder
99ce867424 src: polyfill the 'include' keyword for Visual Studio 2013 2017-12-07 04:41:51 +01:00
Bert Belder
450292aebc test: add missing errno.h include to test-oneshot-and-hangup 2017-12-07 04:40:57 +01:00
Bert Belder
86fbe53e70 build: disable 'conditional expression is constant' warning
Visual Studio 2013 often generates this warning when it encounters a
`do { ... } while (0)` construct, which is commonly used in preprocessor
macros.
2017-12-07 04:40:30 +01:00
Bert Belder
6182e1ec73 test: add leak checker to all tests 2017-12-05 20:30:04 +01:00
Bert Belder
4d6cb0ff5b test: remove unnecessary include from test-error 2017-12-05 20:09:59 +01:00
Bert Belder
ada9cb5910 test: close epoll handle after running test-ctl-fuzz 2017-12-05 20:09:48 +01:00
Bert Belder
9114b4232a test: add test to detect memory leak
The leak itself was fixed in the previous commit.
2017-12-05 20:08:55 +01:00
Bert Belder
f260365c45 port: plug memory leak where deleted socket would never be freed 2017-12-05 20:04:41 +01:00
Bert Belder
05bad1e58b sock: move poll cancellation to _ep_sock_cancel_poll() 2017-12-05 20:04:41 +01:00
Bert Belder
eecfb0e5e3 port: make ep_port_release_poll_group() signature consistent 2017-12-05 20:04:41 +01:00
Bert Belder
50f84cdc6b port: refactor socket update queue 2017-12-05 20:04:35 +01:00
Bert Belder
a11f4de81c test: add some epoll_ctl() test cases to test-error 2017-12-05 05:14:02 +01:00
Bert Belder
e5a8d83c8b api: epoll_ctl() to return ENOTSOCK when sock argument is not a socket 2017-12-05 05:02:57 +01:00
Bert Belder
4159a14364 afd: make afd_get_protocol() error reporting more accurate 2017-12-05 04:47:59 +01:00
Bert Belder
283aa5fe76 error: map ERROR_NOT_SUPPORTED to EPERM 2017-12-05 04:46:30 +01:00
Bert Belder
af9a6eb40f test: add tests for epoll_wait() failure modes 2017-12-04 23:22:03 +01:00
Bert Belder
a2f6609d57 api: report EINVAL if epoll_wait() is called with invalid maxevents 2017-12-04 23:21:39 +01:00
Bert Belder
227ee0e63d dist: merge release tag v1.2.0 2017-12-04 21:10:19 +01:00
Bert Belder
c053eb280d version 1.2.0 2017-12-04 21:09:07 +01:00
Bert Belder
bbeed7566c test: add (incomplete) error code test 2017-12-04 21:07:43 +01:00
Bert Belder
11d7a0395f api: report EINVAL when ephnd is a valid handle but not an epoll instance 2017-12-04 21:04:58 +01:00
Bert Belder
d5b5b605c0 api: epoll_ctl_mod() report EBADF when modifying/deleting invalid socket 2017-12-04 21:03:59 +01:00
Bert Belder
d83871797c error: add return_handle_error(value, handle, [error]) macro
This macro validates that `handle` is valid. If `handle` is valid, it
behaves just like `return_error(value, [error])`. If `handle` is
invalid, it sets errno to EBADF and GetLastError() returns
ERROR_INVALID_HANDLE.
2017-12-04 21:00:44 +01:00
Bert Belder
dc1369886d error: map ERROR_*_SYSTEM_RESOURCES to ENOMEM 2017-12-04 20:06:39 +01:00
Bert Belder
69a297fd22 port: properly propagate CreateIoCompletionPort() error 2017-12-04 20:06:16 +01:00
Bert Belder
981b3caf4e api: epoll_create() and epoll_create1() should return NULL on failure 2017-12-04 20:04:30 +01:00
Bert Belder
98fc483e76 test: remove unnecessary WS2tcpip.h includes 2017-12-04 17:20:58 +01:00
Bert Belder
d76556797d doc: fix EPOLL_CTL_MOD -> EPOLL_CTL_DEL 2017-12-04 00:11:24 +01:00
Bert Belder
2b07037dbb dist: merge release tag v1.1.0 2017-12-04 00:08:09 +01:00
Bert Belder
c751fb935f version 1.1.0 2017-12-04 00:06:28 +01:00
Bert Belder
778082c38a build: combined dll depends on dist/wepoll.h 2017-12-04 00:05:00 +01:00
Bert Belder
614e5c493e build: rename 'combined' target to 'dist' 2017-12-04 00:03:51 +01:00
Bert Belder
11e6439c38 doc: move readme to root 2017-12-03 23:57:55 +01:00
Bert Belder
523bb0f8c0 doc: externalize links 2017-12-03 23:55:49 +01:00
Bert Belder
f223463f12 doc: externalize links 2017-12-03 23:50:32 +01:00
Bert Belder
712eaab58b doc: epoll_create() size argument must be greater than zero 2017-12-03 23:40:29 +01:00
Bert Belder
3e3d414637 doc: improve readability of epoll_wait() return value list 2017-12-03 23:40:13 +01:00
Bert Belder
d64a5f282d test: remove unnecessary event mask casts to uint32_t 2017-12-03 23:16:10 +01:00
Bert Belder
7d3dd32b3d header: cast event types to uint32_t 2017-12-03 23:15:31 +01:00
Bert Belder
ceb44f6501 header: align values in enum EPOLL_EVENTS definition 2017-12-03 23:14:22 +01:00
Bert Belder
49f73f6723 sock: list out known epoll event types 2017-12-03 23:13:01 +01:00
Bert Belder
c22de2ecab header: note that EPOLLMSG is never reported 2017-12-03 22:56:09 +01:00
Bert Belder
6209fd4850 header: mark windows-specific fields in union epoll_data 2017-12-03 22:55:55 +01:00
Bert Belder
f7e15f1ba8 reflock-tree: remove unnecessary casts 2017-12-03 19:09:32 +01:00
Bert Belder
b3335d9c19 src: remove unnecessary #ifndef from regular/internal.h 2017-12-03 19:01:03 +01:00
Bert Belder
63d3e3b2bc src: merge ntstatus.h into nt.h 2017-12-03 18:58:43 +01:00
Bert Belder
6c5ad68f48 dist: merge release tag v1.0.2 2017-12-03 18:21:26 +01:00
4 changed files with 1601 additions and 1845 deletions

28
LICENSE Normal file
View 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
View File

@ -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

3125
wepoll.c

File diff suppressed because it is too large Load Diff

View File

@ -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 */
}; };