From 0fb5a016497d3061a6edf40752c06127f3abb796 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 20 Apr 2012 07:42:10 +0200 Subject: Select polling mechanisms at one place This patch provides a single place for selecting polling mechanisms (polling.hpp). Up to now the selection was spread among the build system and several source files. Signed-off-by: Martin Sustrik --- src/upoll.cpp | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'src/upoll.cpp') diff --git a/src/upoll.cpp b/src/upoll.cpp index d99deec..089a6a5 100644 --- a/src/upoll.cpp +++ b/src/upoll.cpp @@ -26,27 +26,13 @@ #include "clock.hpp" #include "likely.hpp" #include "platform.hpp" - -#if defined XS_HAVE_SELECT -#define XS_POLL_BASED_ON_SELECT -#elif defined XS_HAVE_POLL -#define XS_POLL_BASED_ON_POLL -#elif defined XS_HAVE_LINUX || defined XS_HAVE_FREEBSD ||\ - defined XS_HAVE_OPENBSD || defined XS_HAVE_SOLARIS ||\ - defined XS_HAVE_OSX || defined XS_HAVE_QNXNTO ||\ - defined XS_HAVE_HPUX || defined XS_HAVE_AIX ||\ - defined XS_HAVE_NETBSD -#define XS_POLL_BASED_ON_POLL -#elif defined XS_HAVE_WINDOWS || defined XS_HAVE_OPENVMS ||\ - defined XS_HAVE_CYGWIN -#define XS_POLL_BASED_ON_SELECT -#endif +#include "polling.hpp" // On AIX platform, poll.h has to be included first to get consistent // definition of pollfd structure (AIX uses 'reqevents' and 'retnevents' // instead of 'events' and 'revents' and defines macros to map from POSIX-y // names to AIX-specific names). -#if defined XS_POLL_BASED_ON_POLL +#if defined XS_USE_SYNC_POLL #include #endif @@ -58,7 +44,7 @@ int xs::upoll (xs_pollitem_t *items_, int nitems_, int timeout_) { -#if defined XS_POLL_BASED_ON_POLL +#if defined XS_USE_SYNC_POLL if (unlikely (nitems_ < 0)) { errno = EINVAL; return -1; @@ -213,7 +199,7 @@ int xs::upoll (xs_pollitem_t *items_, int nitems_, int timeout_) free (pollfds); return nevents; -#elif defined XS_POLL_BASED_ON_SELECT +#elif defined XS_USE_SYNC_SELECT if (unlikely (nitems_ < 0)) { errno = EINVAL; @@ -403,15 +389,7 @@ int xs::upoll (xs_pollitem_t *items_, int nitems_, int timeout_) return nevents; #else - // Exotic platforms that support neither poll() nor select(). - errno = ENOTSUP; - return -1; +#error #endif } -#if defined XS_POLL_BASED_ON_SELECT -#undef XS_POLL_BASED_ON_SELECT -#endif -#if defined XS_POLL_BASED_ON_POLL -#undef XS_POLL_BASED_ON_POLL -#endif -- cgit v1.2.3