/[svn]/ircd-hybrid/trunk/m4/ax_arg_ioloop_mechanism.m4
ViewVC logotype

Contents of /ircd-hybrid/trunk/m4/ax_arg_ioloop_mechanism.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5875 - (show annotations)
Wed Apr 29 11:09:28 2015 UTC (7 years, 9 months ago) by michael
File size: 3582 byte(s)
- Style corrections; removed trailing whitespaces

1 AC_DEFUN([AX_ARG_IOLOOP_MECHANISM],[
2 desired_iopoll_mechanism="none"
3 dnl FIXME need to handle arguments a bit better (see ac_arg_disable_block_alloc)
4
5 AC_ARG_ENABLE([kqueue], [AS_HELP_STRING([--enable-kqueue], [Force kqueue usage.])], [desired_iopoll_mechanism="kqueue"])
6 AC_ARG_ENABLE([epoll], [AS_HELP_STRING([--enable-epoll], [Force epoll usage.])], [desired_iopoll_mechanism="epoll"])
7 AC_ARG_ENABLE([devpoll],[AS_HELP_STRING([--enable-devpoll],[Force devpoll usage.])],[desired_iopoll_mechanism="devpoll"])
8 AC_ARG_ENABLE([poll], [AS_HELP_STRING([--enable-poll], [Force poll usage.])], [desired_iopoll_mechanism="poll"])
9
10 AC_MSG_CHECKING([for optimal/desired iopoll mechanism])
11
12 iopoll_mechanism_none=0
13 AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_NONE],[$iopoll_mechanism_none],[no iopoll mechanism])
14
15 iopoll_mechanism_kqueue=1
16 AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_KQUEUE],[$iopoll_mechanism_kqueue],[kqueue mechanism])
17 AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([kevent])],[is_kqueue_mechanism_available="yes"],[is_kqueue_mechanism_available="no"])
18
19 iopoll_mechanism_epoll=2
20 AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_EPOLL],[$iopoll_mechanism_epoll],[epoll mechanism])
21 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(256);])], [is_epoll_mechanism_available="yes"],[is_epoll_mechanism_available="no"])
22
23 iopoll_mechanism_devpoll=3
24 AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_DEVPOLL],[$iopoll_mechanism_devpoll],[devpoll mechanism])
25 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <devpoll.h>])],[is_devpoll_mechanism_available="yes"],[is_devpoll_mechanism_available="no"])
26 if test "$is_devpoll_mechanism_available" = "yes" ; then
27 AC_DEFINE([HAVE_DEVPOLL_H],[1],[Define to 1 if you have the <devpoll.h> header file.])
28 fi
29 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/devpoll.h>])],[is_devpoll_mechanism_available="yes"],[is_devpoll_mechanism_available="no"])
30 if test "$is_devpoll_mechanism_available" = "yes" ; then
31 AC_DEFINE([HAVE_SYS_DEVPOLL_H],[1],[Define to 1 if you have the <sys/devpoll.h> header file.])
32 fi
33
34 iopoll_mechanism_poll=4
35 AC_DEFINE_UNQUOTED([__IOPOLL_MECHANISM_POLL],[$iopoll_mechanism_poll],[poll mechanism])
36 AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([poll])],[is_poll_mechanism_available="yes"],[is_poll_mechanism_available="no"])
37
38 optimal_iopoll_mechanism="none"
39 for mechanism in "kqueue" "epoll" "devpoll" "poll" ; do # order is important
40 eval "is_optimal_iopoll_mechanism_available=\$is_${mechanism}_mechanism_available"
41 if test "$is_optimal_iopoll_mechanism_available" = "yes" ; then
42 optimal_iopoll_mechanism="$mechanism"
43 break
44 fi
45 done
46
47 if test "$desired_iopoll_mechanism" = "none" ; then
48 if test "$optimal_iopoll_mechanism" = "none" ; then
49 AC_MSG_RESULT([none])
50 AC_MSG_ERROR([no iopoll mechanism found!])
51 else
52 selected_iopoll_mechanism=$optimal_iopoll_mechanism
53 AC_MSG_RESULT([$selected_iopoll_mechanism])
54 fi
55 else
56 eval "is_desired_iopoll_mechanism_available=\$is_${desired_iopoll_mechanism}_mechanism_available"
57 if test "$is_desired_iopoll_mechanism_available" = "yes" ; then
58 selected_iopoll_mechanism=$desired_iopoll_mechanism
59 AC_MSG_RESULT([$selected_iopoll_mechanism])
60 else
61 AC_MSG_RESULT([none])
62 AC_MSG_ERROR([desired iopoll mechanism, $desired_iopoll_mechanism, is not available])
63 fi
64 fi
65
66 eval "use_iopoll_mechanism=\$iopoll_mechanism_${selected_iopoll_mechanism}"
67 AC_DEFINE_UNQUOTED([USE_IOPOLL_MECHANISM],[$use_iopoll_mechanism],[use this iopoll mechanism])
68 ])

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28