1dnl * I/O loop function
2AC_DEFUN([DOVECOT_IOLOOP], [
3  have_ioloop=no
4
5  if test "$ioloop" = "best" || test "$ioloop" = "epoll"; then
6    AC_CACHE_CHECK([whether we can use epoll],i_cv_epoll_works,[
7      AC_TRY_RUN([
8        #include <sys/epoll.h>
9
10        int main()
11        {
12  	return epoll_create(5) < 1;
13        }
14      ], [
15        i_cv_epoll_works=yes
16      ], [
17        i_cv_epoll_works=no
18      ])
19    ])
20    if test $i_cv_epoll_works = yes; then
21      AC_DEFINE(IOLOOP_EPOLL,, [Implement I/O loop with Linux 2.6 epoll()])
22      have_ioloop=yes
23      ioloop=epoll
24    else
25      if test "$ioloop" = "epoll" ; then
26        AC_MSG_ERROR([epoll ioloop requested but epoll_create() is not available])
27      fi
28    fi
29  fi
30
31  if test "$ioloop" = "best" || test "$ioloop" = "kqueue"; then
32      if test "$ac_cv_func_kqueue" = yes && test "$ac_cv_func_kevent" = yes; then
33        AC_DEFINE(IOLOOP_KQUEUE,, [Implement I/O loop with BSD kqueue()])
34        ioloop=kqueue
35        have_ioloop=yes
36      elif test "$ioloop" = "kqueue"; then
37        AC_MSG_ERROR([kqueue ioloop requested but kqueue() is not available])
38      fi
39  fi
40
41  if test "$ioloop" = "best" || test "$ioloop" = "poll"; then
42    AC_CHECK_FUNC(poll, [
43      AC_DEFINE(IOLOOP_POLL,, [Implement I/O loop with poll()])
44      ioloop=poll
45      have_ioloop=yes
46    ])
47  fi
48
49  if test "$have_ioloop" = "no"; then
50    AC_DEFINE(IOLOOP_SELECT,, [Implement I/O loop with select()])
51    ioloop="select"
52  fi
53])
54