diff options
author | Gabriele Svelto <gabriele.svelto@gmail.com> | 2012-04-30 21:14:04 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-05-02 09:44:04 +0200 |
commit | 357a20ef6feae94c033eed392b025e57fe8eaa81 (patch) | |
tree | cf3c151ea004d762d5f1f967a1d49c4c2e6a3229 /src/upoll.cpp | |
parent | 971cbeda3de6691b212ad18bed9e9f08b278cfe1 (diff) |
Conditionally include header files required by select() and poll()
Feature checks are introduced to check for all the headers required by
the select() and poll() calls. Include files are then included
conditionally without the use of any OS-specific directive. The change
also fixes a couple of problems:
- Fixed compilation under FreeBSD, NetBSD and OpenBSD when forcing the
use of select() in the poller
- Quieted a warning mixed-sign comparison warning on FreeBSD caused by
FD_SETSIZE being declared as an unsigned constant on that OS
- Removed the obsolescent AC_HEADER_TIME macro from the configure script
Signed-off-by: Gabriele Svelto <gabriele.svelto@gmail.com>
Diffstat (limited to 'src/upoll.cpp')
-rw-r--r-- | src/upoll.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/upoll.cpp b/src/upoll.cpp index 089a6a5..4d61b77 100644 --- a/src/upoll.cpp +++ b/src/upoll.cpp @@ -33,13 +33,31 @@ // instead of 'events' and 'revents' and defines macros to map from POSIX-y // names to AIX-specific names). #if defined XS_USE_SYNC_POLL -#include <poll.h> +# if HAVE_SYS_TYPES +# include <sys/types.h> +# endif +# if HAVE_SYS_SELECT_H +# include <sys/select.h> +# endif +# if HAVE_POLL_H +# include <poll.h> +# elif HAVE_SYS_POLL_H +# include <sys/poll.h> +# endif #endif #if defined XS_HAVE_WINDOWS -#include "windows.hpp" +# include "windows.hpp" #else -#include <unistd.h> +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# endif +# if HAVE_TIME_H +# include <time.h> +# endif +# if HAVE_UNISTD_H +# include <unistd.h> +# endif #endif int xs::upoll (xs_pollitem_t *items_, int nitems_, int timeout_) @@ -227,7 +245,7 @@ int xs::upoll (xs_pollitem_t *items_, int nitems_, int timeout_) // Ensure we do not attempt to select () on more than FD_SETSIZE // file descriptors. - xs_assert (nitems_ <= FD_SETSIZE); + xs_assert (nitems_ <= (int)FD_SETSIZE); fd_set pollset_in; FD_ZERO (&pollset_in); |