Compare commits

...

185 Commits
v1.2.4 ... 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
4 changed files with 1565 additions and 1968 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.

112
README.md
View File

@ -38,21 +38,23 @@ to run on Linux.
## How to use ## How to use
The library is [distributed][dist] as a single source file The library is [distributed][dist] as a single source file
([wepoll.c][wepoll.c]) and a single header file ([wepoll.h][wepoll.h]). ([wepoll.c][wepoll.c]) and a single header file ([wepoll.h][wepoll.h]).<br>
Compile the .c file as part of your project, and include the header Compile the .c file as part of your project, and include the header wherever
wherever needed. needed.
## Compatibility ## Compatibility
* Requires Windows Vista or higher. * Requires Windows Vista or higher.
* Can be compiled with recent versions of MSVC, Clang, and GCC. * Can be compiled with recent versions of MSVC, Clang, and GCC.
## 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
@ -65,7 +67,7 @@ HANDLE epoll_create1(int flags);
* `size` is ignored but most be greater than zero. * `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 `NULL` on failure. * Returns `NULL` on failure.
* [man page][man epoll_create] * [Linux man page][man epoll_create]
### epoll_close ### epoll_close
@ -87,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_DEL` *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][man epoll_ctl]
### epoll_wait ### epoll_wait
@ -107,12 +116,74 @@ 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.
- ≥1 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][man epoll_wait] * `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 badge]: https://ci.appveyor.com/api/projects/status/github/piscisaureus/wepoll?branch=master&svg=true
@ -122,6 +193,9 @@ int epoll_wait(HANDLE ephnd,
[man epoll_create]: http://man7.org/linux/man-pages/man2/epoll_create.2.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_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 [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 [select scale]: https://daniel.haxx.se/docs/poll-vs-select.html
[wsapoll broken]: https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ [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.c]: https://github.com/piscisaureus/wepoll/blob/dist/wepoll.c

3333
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
@ -38,42 +38,38 @@
#include <stdint.h> #include <stdint.h>
/* clang-format off */
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, /* Never reported. */ EPOLLMSG = (int) (1U << 10), /* Never reported. */
EPOLLRDHUP = 1 << 13, EPOLLRDHUP = (int) (1U << 13),
EPOLLONESHOT = 1 << 31 EPOLLONESHOT = (int) (1U << 31)
}; };
#define EPOLLIN ((uint32_t) EPOLLIN) #define EPOLLIN (1U << 0)
#define EPOLLPRI ((uint32_t) EPOLLPRI) #define EPOLLPRI (1U << 1)
#define EPOLLOUT ((uint32_t) EPOLLOUT) #define EPOLLOUT (1U << 2)
#define EPOLLERR ((uint32_t) EPOLLERR) #define EPOLLERR (1U << 3)
#define EPOLLHUP ((uint32_t) EPOLLHUP) #define EPOLLHUP (1U << 4)
#define EPOLLRDNORM ((uint32_t) EPOLLRDNORM) #define EPOLLRDNORM (1U << 6)
#define EPOLLRDBAND ((uint32_t) EPOLLRDBAND) #define EPOLLRDBAND (1U << 7)
#define EPOLLWRNORM ((uint32_t) EPOLLWRNORM) #define EPOLLWRNORM (1U << 8)
#define EPOLLWRBAND ((uint32_t) EPOLLWRBAND) #define EPOLLWRBAND (1U << 9)
#define EPOLLMSG ((uint32_t) EPOLLMSG) #define EPOLLMSG (1U << 10)
#define EPOLLRDHUP ((uint32_t) EPOLLRDHUP) #define EPOLLRDHUP (1U << 13)
#define EPOLLONESHOT ((uint32_t) 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
#define EPOLL_CTL_DEL 3 #define EPOLL_CTL_DEL 3
/* clang-format on */
typedef void* HANDLE; typedef void* HANDLE;
typedef uintptr_t SOCKET; typedef uintptr_t SOCKET;
@ -87,7 +83,7 @@ typedef union epoll_data {
} 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 */
}; };