1 |
michael |
4359 |
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 |
michael |
5874 |
AC_ARG_ENABLE([poll], [AS_HELP_STRING([--enable-poll], [Force poll usage.])], [desired_iopoll_mechanism="poll"]) |
8 |
michael |
4359 |
|
9 |
|
|
AC_MSG_CHECKING([for optimal/desired iopoll mechanism]) |
10 |
|
|
|
11 |
|
|
iopoll_mechanism_none=0 |
12 |
michael |
10196 |
AC_DEFINE_UNQUOTED([AX_IOPOLL_MECHANISM_NONE],[$iopoll_mechanism_none],[no iopoll mechanism]) |
13 |
michael |
4359 |
|
14 |
|
|
iopoll_mechanism_kqueue=1 |
15 |
michael |
10196 |
AC_DEFINE_UNQUOTED([AX_IOPOLL_MECHANISM_KQUEUE],[$iopoll_mechanism_kqueue],[kqueue mechanism]) |
16 |
michael |
4359 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([kevent])],[is_kqueue_mechanism_available="yes"],[is_kqueue_mechanism_available="no"]) |
17 |
|
|
|
18 |
|
|
iopoll_mechanism_epoll=2 |
19 |
michael |
10196 |
AC_DEFINE_UNQUOTED([AX_IOPOLL_MECHANISM_EPOLL],[$iopoll_mechanism_epoll],[epoll mechanism]) |
20 |
michael |
8531 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create1(EPOLL_CLOEXEC);])], [is_epoll_mechanism_available="yes"],[is_epoll_mechanism_available="no"]) |
21 |
michael |
4359 |
|
22 |
michael |
10033 |
iopoll_mechanism_poll=3 |
23 |
michael |
10196 |
AC_DEFINE_UNQUOTED([AX_IOPOLL_MECHANISM_POLL],[$iopoll_mechanism_poll],[poll mechanism]) |
24 |
michael |
4359 |
AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([poll])],[is_poll_mechanism_available="yes"],[is_poll_mechanism_available="no"]) |
25 |
|
|
|
26 |
|
|
optimal_iopoll_mechanism="none" |
27 |
michael |
10033 |
for mechanism in "kqueue" "epoll" "poll" ; do # order is important |
28 |
michael |
4359 |
eval "is_optimal_iopoll_mechanism_available=\$is_${mechanism}_mechanism_available" |
29 |
|
|
if test "$is_optimal_iopoll_mechanism_available" = "yes" ; then |
30 |
|
|
optimal_iopoll_mechanism="$mechanism" |
31 |
|
|
break |
32 |
|
|
fi |
33 |
|
|
done |
34 |
|
|
|
35 |
|
|
if test "$desired_iopoll_mechanism" = "none" ; then |
36 |
|
|
if test "$optimal_iopoll_mechanism" = "none" ; then |
37 |
|
|
AC_MSG_RESULT([none]) |
38 |
|
|
AC_MSG_ERROR([no iopoll mechanism found!]) |
39 |
|
|
else |
40 |
|
|
selected_iopoll_mechanism=$optimal_iopoll_mechanism |
41 |
|
|
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
42 |
|
|
fi |
43 |
|
|
else |
44 |
|
|
eval "is_desired_iopoll_mechanism_available=\$is_${desired_iopoll_mechanism}_mechanism_available" |
45 |
|
|
if test "$is_desired_iopoll_mechanism_available" = "yes" ; then |
46 |
|
|
selected_iopoll_mechanism=$desired_iopoll_mechanism |
47 |
|
|
AC_MSG_RESULT([$selected_iopoll_mechanism]) |
48 |
|
|
else |
49 |
|
|
AC_MSG_RESULT([none]) |
50 |
|
|
AC_MSG_ERROR([desired iopoll mechanism, $desired_iopoll_mechanism, is not available]) |
51 |
|
|
fi |
52 |
|
|
fi |
53 |
|
|
|
54 |
|
|
eval "use_iopoll_mechanism=\$iopoll_mechanism_${selected_iopoll_mechanism}" |
55 |
|
|
AC_DEFINE_UNQUOTED([USE_IOPOLL_MECHANISM],[$use_iopoll_mechanism],[use this iopoll mechanism]) |
56 |
|
|
]) |