summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Koppanen <mkoppanen@php.net>2011-09-04 10:28:15 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-09-04 10:28:15 +0200
commit9d0e122bfad431d7b84ad43c0c62c8ebc9540a36 (patch)
tree8c785db91e3727a4f1aff244380264317d68008a
parent193fa1c079fd886623e55810556a9461561ca139 (diff)
Added option to choose internal polling system
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
-rw-r--r--acinclude.m4165
-rw-r--r--configure.in4
2 files changed, 169 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index c518789..42e5851 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -580,3 +580,168 @@ AC_DEFUN([LIBZMQ_CHECK_LANG_VISIBILITY], [{
AS_IF([test "x$libzmq_cv_[]_AC_LANG_ABBREV[]_visibility_flag" != "x"],
[AC_MSG_RESULT(yes) ; $1], [AC_MSG_RESULT(no) ; $2])
}])
+
+dnl ################################################################################
+dnl # LIBZMQ_CHECK_POLLER_KQUEUE([action-if-found], [action-if-not-found]) #
+dnl # Checks kqueue polling system #
+dnl ################################################################################
+AC_DEFUN([LIBZMQ_CHECK_POLLER_KQUEUE], [{
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+#include <sys/types.h>
+#include <sys/event.h>
+#include <sys/time.h>
+ ],
+[[
+struct kevent t_kev;
+kqueue();
+]]
+ )],
+ [libzmq_cv_have_poller_kqueue="yes" ; $1],
+ [libzmq_cv_have_poller_kqueue="no" ; $2])
+}])
+
+dnl ################################################################################
+dnl # LIBZMQ_CHECK_POLLER_EPOLL([action-if-found], [action-if-not-found]) #
+dnl # Checks epoll polling system #
+dnl ################################################################################
+AC_DEFUN([LIBZMQ_CHECK_POLLER_EPOLL], [{
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+#include <sys/epoll.h>
+ ],
+[[
+struct epoll_event t_ev;
+epoll_create(10);
+]]
+ )],
+ [libzmq_cv_have_poller_epoll="yes" ; $1],
+ [libzmq_cv_have_poller_epoll="no" ; $2])
+}])
+
+dnl ################################################################################
+dnl # LIBZMQ_CHECK_POLLER_DEVPOLL([action-if-found], [action-if-not-found]) #
+dnl # Checks devpoll polling system #
+dnl ################################################################################
+AC_DEFUN([LIBZMQ_CHECK_POLLER_DEVPOLL], [{
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+#include <sys/devpoll.h>
+ ],
+[[
+struct pollfd t_devpoll;
+int fd = open("/dev/poll", O_RDWR);
+]]
+ )],
+ [libzmq_cv_have_poller_devpoll="yes" ; $1],
+ [libzmq_cv_have_poller_devpoll="no" ; $2])
+}])
+
+dnl ################################################################################
+dnl # LIBZMQ_CHECK_POLLER_POLL([action-if-found], [action-if-not-found]) #
+dnl # Checks poll polling system #
+dnl ################################################################################
+AC_DEFUN([LIBZMQ_CHECK_POLLER_POLL], [{
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+#include <poll.h>
+ ],
+[[
+struct pollfd t_poll;
+poll(&t_poll, 1, 1);
+]]
+ )],
+ [libzmq_cv_have_poller_poll="yes" ; $1],
+ [libzmq_cv_have_poller_poll="no" ; $2])
+}])
+
+dnl ################################################################################
+dnl # LIBZMQ_CHECK_POLLER_SELECT([action-if-found], [action-if-not-found]) #
+dnl # Checks select polling system #
+dnl ################################################################################
+AC_DEFUN([LIBZMQ_CHECK_POLLER_SELECT], [{
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+#include <sys/select.h>
+#include <stdlib.h>
+ ],
+[[
+fd_set t_rfds;
+struct timeval tv;
+
+FD_ZERO(&t_rfds);
+FD_SET(0, &t_rfds);
+
+tv.tv_sec = 5;
+v.tv_usec = 0;
+
+select(1, &t_rfds, NULL, NULL, &tv);
+]]
+ )],
+ [libzmq_cv_have_poller_select="yes" ; $1],
+ [libzmq_cv_have_poller_select="no" ; $2])
+}])
+
+dnl ################################################################################
+dnl # LIBZMQ_CHECK_POLLER([action-if-found], [action-if-not-found]) #
+dnl # Choose polling system #
+dnl ################################################################################
+AC_DEFUN([LIBZMQ_CHECK_POLLER], [{
+
+ # Allow user to disable doc build
+ AC_ARG_WITH([poller], [AS_HELP_STRING([--with-poller],
+ [choose polling system manually. valid values are kqueue, epoll, devpoll, poll or select [default=autodetect]])])
+
+ AC_MSG_CHECKING([for suitable polling system])
+
+ case "${with_poller}" in
+ kqueue|epoll|devpoll|poll|select)
+ # User has chosen polling system
+ libzmq_cv_poller="${with_poller}"
+ ;;
+
+ *)
+ # try to find suitable polling system. the order of testing is:
+ # kqueue -> epoll -> devpoll -> poll -> select
+ for subsystem in kqueue epoll devpoll poll select; do
+
+ case "${subsystem}" in
+ kqueue)
+ LIBZMQ_CHECK_POLLER_KQUEUE([libzmq_cv_poller=$subsystem], [])
+ ;;
+
+ epoll)
+ LIBZMQ_CHECK_POLLER_EPOLL([libzmq_cv_poller=$subsystem], [])
+ ;;
+
+ devpoll)
+ LIBZMQ_CHECK_POLLER_DEVPOLL([libzmq_cv_poller=$subsystem], [])
+ ;;
+
+ poll)
+ LIBZMQ_CHECK_POLLER_POLL([libzmq_cv_poller=$subsystem], [])
+ ;;
+
+ select)
+ LIBZMQ_CHECK_POLLER_SELECT([libzmq_cv_poller=$subsystem], [])
+ ;;
+ esac
+
+ if test "x${libzmq_cv_poller}" != "x"; then
+ break
+ fi
+ done
+ ;;
+ esac
+
+ libzmq_cv_poller_flag=`echo "ZMQ_FORCE_${libzmq_cv_poller}" | tr a-z A-Z`
+
+ AS_IF([test "x${libzmq_cv_poller}" != "x"],
+ [AC_MSG_RESULT([using $libzmq_cv_poller]) ; $1], [AC_MSG_RESULT(no suitable polling system found) ; $2])
+}])
+
diff --git a/configure.in b/configure.in
index 8a31177..4065252 100644
--- a/configure.in
+++ b/configure.in
@@ -229,6 +229,10 @@ esac
# Check whether to build docs / install man pages
LIBZMQ_CHECK_DOC_BUILD
+# Check polling system
+LIBZMQ_CHECK_POLLER([CPPFLAGS="${CPPFLAGS} -D${libzmq_cv_poller_flag}"],
+ [AC_MSG_ERROR([Unable to continue without polling system])])
+
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h \