From 54ee0e28ab7d3d15eef7c5b7c58ed943c0dd2795 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 12 Oct 2020 12:50:05 +0200 Subject: [PATCH] event/PollGroup: check _WIN32 instead of USE_WINSELECT --- meson.build | 6 +----- src/event/PollGroup.hxx | 18 ++++++++++-------- src/event/PollGroupPoll.cxx | 6 ------ src/event/PollGroupWinSelect.cxx | 6 ------ src/event/meson.build | 10 ++++++++-- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/meson.build b/meson.build index fe37628a1..3c5277863 100644 --- a/meson.build +++ b/meson.build @@ -172,12 +172,8 @@ conf.set('HAVE_PRCTL', is_linux) conf.set('USE_EVENTFD', is_linux and get_option('eventfd')) conf.set('USE_SIGNALFD', is_linux and get_option('signalfd')) -if is_windows - conf.set('USE_WINSELECT', true) -elif is_linux and get_option('epoll') +if is_linux and get_option('epoll') conf.set('USE_EPOLL', true) -else - conf.set('USE_POLL', true) endif if not get_option('syslog').disabled() diff --git a/src/event/PollGroup.hxx b/src/event/PollGroup.hxx index c14171b95..66c668fd0 100644 --- a/src/event/PollGroup.hxx +++ b/src/event/PollGroup.hxx @@ -22,22 +22,24 @@ #include "config.h" -#ifdef USE_EPOLL -#include "PollGroupEpoll.hxx" -typedef PollResultEpoll PollResult; -typedef PollGroupEpoll PollGroup; -#endif +#ifdef _WIN32 -#ifdef USE_WINSELECT #include "PollGroupWinSelect.hxx" typedef PollResultGeneric PollResult; typedef PollGroupWinSelect PollGroup; -#endif -#ifdef USE_POLL +#elif defined(USE_EPOLL) + +#include "PollGroupEpoll.hxx" +typedef PollResultEpoll PollResult; +typedef PollGroupEpoll PollGroup; + +#else + #include "PollGroupPoll.hxx" typedef PollResultGeneric PollResult; typedef PollGroupPoll PollGroup; + #endif #endif diff --git a/src/event/PollGroupPoll.cxx b/src/event/PollGroupPoll.cxx index 69901e689..47951a131 100644 --- a/src/event/PollGroupPoll.cxx +++ b/src/event/PollGroupPoll.cxx @@ -17,10 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" - -#ifdef USE_POLL - #include "PollGroupPoll.hxx" #include @@ -89,5 +85,3 @@ PollGroupPoll::ReadEvents(PollResultGeneric &result, int timeout_ms) noexcept } } } - -#endif diff --git a/src/event/PollGroupWinSelect.cxx b/src/event/PollGroupWinSelect.cxx index aee392dec..29a6f5e0a 100644 --- a/src/event/PollGroupWinSelect.cxx +++ b/src/event/PollGroupWinSelect.cxx @@ -17,10 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" - -#ifdef USE_WINSELECT - #include "PollGroupWinSelect.hxx" static constexpr int EVENT_READ = 0; @@ -165,5 +161,3 @@ PollGroupWinSelect::ReadEvents(PollResultGeneric &result, i.second.events = 0; } } - -#endif diff --git a/src/event/meson.build b/src/event/meson.build index e4de136b0..6e4119777 100644 --- a/src/event/meson.build +++ b/src/event/meson.build @@ -4,10 +4,16 @@ if uring_dep.found() event_sources += 'UringManager.cxx' endif +if is_windows + event_sources += 'PollGroupWinSelect.cxx' +elif is_linux and get_option('epoll') + # epoll support is header-only +else + event_sources += 'PollGroupPoll.cxx' +endif + event = static_library( 'event', - 'PollGroupPoll.cxx', - 'PollGroupWinSelect.cxx', 'SignalMonitor.cxx', 'TimerEvent.cxx', 'IdleMonitor.cxx',