From 2af6b901ba20bcbf03a133995b10e4492818948a Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sun, 10 Dec 2017 03:51:25 +0100 Subject: [PATCH 1/3] util: define `static_assert` even if clang pretends to be msvc --- src/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.h b/src/util.h index e210b3a..2715803 100644 --- a/src/util.h +++ b/src/util.h @@ -31,7 +31,7 @@ typedef intptr_t ssize_t; #define inline __inline #endif -#if !defined(static_assert) && !defined(_MSC_VER) +#if (defined(__clang__) || defined(__GNUC__)) && !defined(static_assert) /* Polyfill `static_assert` for some versions of clang and gcc. */ #define static_assert(condition, message) typedef __attribute__( \ (__unused__)) int __static_assert_##__LINE__[(condition) ? 1 : -1]; From 0b4788e2af7242e970f887170ad55b98fda0c255 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sun, 10 Dec 2017 03:48:11 +0100 Subject: [PATCH 2/3] ci: add gcc and clang builds --- .appveyor.yml | 87 ++++++++++++++++++++++++++++++++++++++++---------- CMakeLists.txt | 4 +-- 2 files changed, 71 insertions(+), 20 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 99d02e8..e941ae1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,24 +2,73 @@ version: b{build}-{branch} environment: matrix: - - platform: x64 - generator: "Visual Studio 15 2017 Win64" - appveyor_build_worker_image: Visual Studio 2017 - - platform: x86 - generator: "Visual Studio 15 2017" - appveyor_build_worker_image: Visual Studio 2017 - - platform: x64 - generator: "Visual Studio 14 2015 Win64" - appveyor_build_worker_image: Visual Studio 2015 - - platform: x86 - generator: "Visual Studio 14 2015" - appveyor_build_worker_image: Visual Studio 2015 - - platform: x64 - generator: "Visual Studio 12 2013 Win64" + - job: msvc-vs2013-x86 appveyor_build_worker_image: Visual Studio 2013 - - platform: x86 - generator: "Visual Studio 12 2013" + cmake_options: -G "Visual Studio 12 2013" + + - job: msvc-vs2013-x64 appveyor_build_worker_image: Visual Studio 2013 + cmake_options: -G "Visual Studio 12 2013 Win64" + + - job: msvc-vs2015-x86 + appveyor_build_worker_image: Visual Studio 2015 + cmake_options: -G "Visual Studio 14 2015" + + - job: msvc-vs2015-x64 + appveyor_build_worker_image: Visual Studio 2015 + cmake_options: -G "Visual Studio 14 2015 Win64" + + - job: msvc-vs2017-x86 + appveyor_build_worker_image: Visual Studio 2017 + cmake_options: -G "Visual Studio 15 2017" + + - job: msvc-vs2017-x64 + appveyor_build_worker_image: Visual Studio 2017 + cmake_options: -G "Visual Studio 15 2017 Win64" + + - job: gcc-mingw-x86 + appveyor_build_worker_image: Visual Studio 2015 + mingw_path: c:\msys64\mingw32\bin + cmake_options: > + -G "MinGW Makefiles" + -DCMAKE_C_COMPILER=gcc + -DCMAKE_CXX_COMPILER=g++ + -DCMAKE_C_FLAGS=-m32 + -DCMAKE_CXX_FLAGS=-m32 + + - job: gcc-mingw-x64 + appveyor_build_worker_image: Visual Studio 2015 + mingw_path: c:\msys64\mingw64\bin + cmake_options: > + -G "MinGW Makefiles" + -DCMAKE_C_COMPILER=gcc + -DCMAKE_CXX_COMPILER=g++ + -DCMAKE_C_FLAGS=-m64 + -DCMAKE_CXX_FLAGS=-m64 + + - job: clang-mingw-x86 + appveyor_build_worker_image: Visual Studio 2015 + mingw_path: c:\msys64\mingw32\bin + vs_path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC + setup_script: vcvarsall.bat x86 + cmake_options: > + -G "MinGW Makefiles" + -DCMAKE_C_COMPILER=clang-cl + -DCMAKE_CXX_COMPILER=clang-cl + -DCMAKE_C_FLAGS=-m32 + -DCMAKE_CXX_FLAGS=-m32 + + - job: clang-mingw-x64 + appveyor_build_worker_image: Visual Studio 2015 + mingw_path: c:\msys64\mingw64\bin + vs_path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC + setup_script: vcvarsall.bat amd64 + cmake_options: > + -G "MinGW Makefiles" + -DCMAKE_C_COMPILER=clang-cl + -DCMAKE_CXX_COMPILER=clang-cl + -DCMAKE_C_FLAGS=-m64 + -DCMAKE_CXX_FLAGS=-m64 configuration: Debug @@ -32,9 +81,13 @@ init: install: - ps: Install-Product node 'Current' + - cmd: set path=%path:C:\Program Files\Git\usr\bin;=% + - cmd: set path=%path%;%mingw_path% + - cmd: set path=%path%;%vs_path% + - cmd: call %setup_script% before_build: - - cmd: cmake . -G "%generator%" + - cmd: cmake . %cmake_options% build_script: - cmd: cmake --build . --config "%configuration%" --target wepoll.dll diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eae4a0..53003b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 2.8.0) project(wepoll) -if(WIN32) - link_libraries(ws2_32) -endif() +link_libraries(ws2_32) if(MSVC) add_compile_options(/Wall /wd4127 /wd4201 /wd4242 /wd4710 /wd4711 /wd4820) From 3f24ebfa21ea5e86c7e005474f944d1c0d032a90 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 11 Dec 2017 16:55:04 +0100 Subject: [PATCH 3/3] doc: update readme prose --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c513314..fe95647 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![][ci status badge]][ci status link] This library implements the [epoll][man epoll] API for Windows -applications. It attempts to be efficient, and to match the Linux API -as semantics as closely as possible. +applications. It is fast and scalable, and it closely resembles the API +and behavior of Linux' epoll. ## Rationale @@ -21,18 +21,19 @@ to run on Linux. ## Features -* can poll 100000s of sockets efficiently -* fully thread safe -* multiple threads can poll the same epoll port -* sockets can be added to multiple epoll sets -* polling for `EPOLLIN`, `EPOLLOUT`, `EPOLLPRI`, `EPOLLRDHUP`, - `EPOLLHUP`, and `EPOLLERR` events -* `EPOLLONESTHOT` flag +* Can poll 100000s of sockets efficiently. +* Fully thread-safe. +* Multiple threads can poll the same epoll port. +* Sockets can be added to multiple epoll sets. +* All epoll events (`EPOLLIN`, `EPOLLOUT`, `EPOLLPRI`, `EPOLLRDHUP`) + are supported. +* Level-triggered and one-shot (`EPOLLONESTHOT`) modes are supported +* Trivial to embed: you need [only two files][dist]. ## Limitations -* only works with sockets -* some modes not suported: `EPOLLET`, `EPOLLEXCLUSIVE` +* Only works with sockets. +* Edge-triggered (`EPOLLET`) mode isn't supported. ## How to use