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