From 0a12aa09b65c67033b5021057dd04fde0a3cabb5 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Tue, 17 Apr 2012 22:50:30 +0200 Subject: Change the way the polling system is selected All polling systems are now checked and corresponding macros set accordingly (e.g. detection of a working poll() function will define XS_HAVE_POLL). Additionally if the user selects a specific polling system via the --with-poller switch a corresponding XS_FORCE_* macro will be defined. The select() and poll() tests now conditionally include headers which makes them more robust on various target platforms. Signed-off-by: Gabriele Svelto --- configure.ac | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 4 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 8156cbe..b602df5 100644 --- a/configure.ac +++ b/configure.ac @@ -220,10 +220,6 @@ AS_CASE(["${host_cpu}"], # Check whether to build docs / install man pages LIBXS_CHECK_DOC_BUILD -# Check polling system -LIBXS_CHECK_POLLER([], - [AC_MSG_ERROR([Unable to continue without polling system])]) - # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([ \ @@ -245,6 +241,80 @@ AC_CHECK_HEADERS([ \ AC_CHECK_HEADERS([ifaddrs.h], [AC_DEFINE([XS_HAVE_IFADDRS], [1], [Have ifaddrs.h header.])]) +############################################################################### +# Check polling system # +############################################################################### + +# Allow users to override the polling system +AC_ARG_WITH([poller], + [AS_HELP_STRING([--with-poller], + [choose polling system manually. valid values are kqueue, epoll, devpoll, poll or select [default=autodetect]])], + [], [with_poller=autodetect]) + +# Check the various polling systems +LIBXS_CHECK_KQUEUE +LIBXS_CHECK_EPOLL +LIBXS_CHECK_DEVPOLL +LIBXS_CHECK_POLL +LIBXS_CHECK_SELECT + +# Select the best available poller +AS_CASE([${with_poller}], + [kqueue], [ + AS_IF([test x$acx_cv_have_kqueue != xyes], [ + AC_MSG_ERROR([kqueue() poller selected but not available]) + ]) + AC_DEFINE([XS_FORCE_KQUEUE], [1], [Forces use of kqueue()]) + libxs_cv_poller=kqueue + ], + [epoll], [ + AS_IF([test x$acx_cv_have_epoll != xyes], [ + AC_MSG_ERROR([epoll() poller selected but not available]) + ]) + AC_DEFINE([XS_FORCE_EPOLL], [1], [Forces use of epoll()]) + libxs_cv_poller=epoll + ], + [devpoll], [ + AS_IF([test x$acx_cv_have_devpoll != xyes], [ + AC_MSG_ERROR([/dev/poll poller selected but not available]) + ]) + AC_DEFINE([XS_FORCE_DEVPOLL], [1], [Forces use of /dev/poll]) + libxs_cv_poller=devpoll + ], + [poll], [ + AS_IF([test x$acx_cv_have_poll != xyes], [ + AC_MSG_ERROR([poll() poller selected but not available]) + ]) + AC_DEFINE([XS_FORCE_POLL], [1], [Forces use of poll()]) + libxs_cv_poller=poll + ], + [select], [ + AS_IF([test x$acx_cv_have_select != xyes], [ + AC_MSG_ERROR([select() poller selected but not available]) + ]) + AC_DEFINE([XS_FORCE_SELECT], [1], [Forces use of select()]) + libxs_cv_poller=select + ], + [autodetect], [ + AS_IF([test x$acx_cv_have_kqueue = xyes], [ + libxs_cv_poller=kqueue + ], [test x$acx_cv_have_epoll = xyes], [ + libxs_cv_poller=epoll + ], [test x$acx_cv_have_devpoll = xyes], [ + libxs_cv_poller=devpoll + ], [test x$acx_cv_have_poll = xyes], [ + libxs_cv_poller=poll + ], [test x$acx_cv_have_select = xyes], [ + libxs_cv_poller=select + ], [ + AC_MSG_ERROR([no suitable polling system found]) + ]) + ], + [*], [ + AC_MSG_ERROR([Invalid poller selected: ${with_poller}]) + ] +) + # Force not to use eventfd AC_ARG_ENABLE([eventfd], [AS_HELP_STRING([--disable-eventfd], [disable eventfd [default=no]])], -- cgit v1.2.3