summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorGabriele Svelto <gabriele.svelto@gmail.com>2012-04-17 22:50:30 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-21 07:30:16 +0200
commit0a12aa09b65c67033b5021057dd04fde0a3cabb5 (patch)
tree269d991abda829e40cced4c53fa1a26d7b5dfc29 /configure.ac
parentf4149b0500b8011c58cd3f5acbb4225dd79e8b85 (diff)
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 <gabriele.svelto@gmail.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac78
1 files changed, 74 insertions, 4 deletions
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]])],