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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
Add detection for working epoll, inotify, kqueue, dnotify and poll.
This should solve the issue of inotify.h being present but the kernel
and/or glibc does not support it.
--- configure.in 2006-06-13 12:24:58.000000000 +0100
+++ configure.in 2006-06-18 02:34:41.000000000 +0100
@@ -364,29 +371,39 @@
dnl * I/O loop function
have_ioloop=no
-dnl we currently don't use epoll automatically because it fails at runtime
-dnl if we're not running 2.6 kernel
-if test "$ioloop" = "epoll"; then
- AC_CHECK_FUNC(epoll_create, [
+if test "$ioloop" = "" || test "$ioloop" = "epoll"; then
+ AC_TRY_RUN([
+ #include <stdint.h>
+ #include <sys/epoll.h>
+ #include <errno.h>
+
+ #include <linux/unistd.h>
+
+ _syscall1 (int, epoll_create, int, size)
+
+ int main()
+ {
+ return epoll_create(5) < 1;
+ }
+ ], [
AC_DEFINE(IOLOOP_EPOLL,, Implement I/O loop with Linux 2.6 epoll())
have_ioloop=yes
+ ioloop=epoll
], [
- ioloop=""
+ if test "$ioloop" != "" ; then
+ AC_MSG_WARN([epoll ioloop requested but epoll_create() is not available])
+ fi
])
fi
-if test "$ioloop" = "kqueue"; then
- if test "$ac_cv_func_kqueue" != yes ; then
- AC_MSG_WARN([kqueue ioloop requested but kqueue() is not available])
- ioloop=""
- elif test "$ac_cv_func_kevent" != yes ; then
- AC_MSG_WARN([kqueue ioloop requested but kevent() is not available])
- ioloop=""
- else
- AC_DEFINE(IOLOOP_KQUEUE,, [Implement I/O loop with BSD kqueue()])
- ioloop=kqueue
- have_ioloop=yes
- fi
+if test "$ioloop" = "" || 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_WARN([kqueue ioloop requested but kqueue() is not available])
+ fi
fi
if test "$ioloop" = "" || test "$ioloop" = "poll"; then
@@ -404,69 +421,94 @@
have_notify=none
-if test "$notify" = "" || test "$notify" = "dnotify"; then
- dnl * dnotify?
- AC_TRY_COMPILE([
- #define _GNU_SOURCE
- #include <fcntl.h>
- #include <signal.h>
- #include <unistd.h>
- ], [
- fcntl(0, F_SETSIG, SIGRTMIN);
- fcntl(0, F_NOTIFY, DN_CREATE | DN_DELETE | DN_RENAME | DN_MULTISHOT);
- ], [
- AC_DEFINE(IOLOOP_NOTIFY_DNOTIFY,, Use Linux dnotify)
- have_notify=dnotify
- ], [
- if test "$notify" = "dnotify"; then
- AC_MSG_ERROR([dnotify requested but not available])
- fi
- ])
-elif test "$notify" = "inotify"; then
+if test "$notify" = "" || test "$notify" = "inotify" ; then
+ AC_MSG_CHECKING([if we can use inotify])
dnl * inotify?
- AC_TRY_COMPILE([
+ AC_TRY_RUN([
#define _GNU_SOURCE
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/inotify.h>
#include <stdio.h>
- ], [
- int wd, fd;
- char * fn = "/tmp";
+
+ int main()
+ {
+ int wd, fd;
+ char * fn = "/tmp";
- fd = inotify_init ();
- if (fd < 0)
- perror ("inotify_init");
-
- wd = inotify_add_watch (fd, fn, IN_ALL_EVENTS);
+ fd = inotify_init ();
+ if (fd < 0)
+ {
+ perror ("inotify_init");
+ return (-1);
+ }
+
+ wd = inotify_add_watch (fd, fn, IN_ALL_EVENTS);
+
+ if (wd < 0)
+ {
+ perror ("inotify_add_watch");
+ return (-2);
+ }
- if (wd < 0)
- perror ("inotify_add_watch");
+ inotify_rm_watch (fd, wd);
- inotify_rm_watch (fd, wd);
-
- close (fd);
+ close (fd);
+ }
], [
have_notify=inotify
+ notify=inotify
AC_DEFINE(IOLOOP_NOTIFY_INOTIFY,, Use Linux inotify)
+ AC_MSG_RESULT("yes")
], [
- AC_MSG_ERROR([inotify requested but not available, check for existence of <sys/inotify.h>])
+ AC_MSG_RESULT("no")
+ if test "$notify" = "inotify"; then
+ AC_MSG_WARN([inotify requested but not available])
+ notify=""
+ fi
])
-elif test "$notify" = "kqueue"; then
+fi
+
+if test "$notify" = "" || test "$notify" = "kqueue"; then
+ AC_MSG_CHECKING([if we can use BSD kqueue() notify])
dnl * BSD kqueue() notify
- if test "$ac_cv_func_kqueue" != yes ; then
- AC_MSG_WARN([kqueue notify requested but kqueue() is not available])
- notify=""
- elif test "$ac_cv_func_kevent" != yes ; then
- AC_MSG_WARN([kqueue notify requested but kevent() is not available])
- notify=""
- else
+ if test "$ac_cv_func_kqueue" == yes && test "$ac_cv_func_kevent" == yes ; then
have_notify=kqueue
+ notify=kqueue
+ AC_MSG_RESULT("yes")
AC_DEFINE(IOLOOP_NOTIFY_KQUEUE,,
Use BSD kqueue directory changes notificaton)
+ else
+ AC_MSG_RESULT("no")
+ if test "$notfify" = "kqueue" ; then
+ AC_MSG_WARN([kqueue notify requested but kqueue() is not available])
+ notify=""
+ fi
fi
-else
- AC_MSG_ERROR([Unknown notify method: $notify])
+fi
+
+if test "$notify" = "" || test "$notify" = "dnotify"; then
+ AC_MSG_CHECKING([if we can use dnotify])
+ dnl * dnotify?
+ AC_TRY_COMPILE([
+ #define _GNU_SOURCE
+ #include <fcntl.h>
+ #include <signal.h>
+ #include <unistd.h>
+ ], [
+ fcntl(0, F_SETSIG, SIGRTMIN);
+ fcntl(0, F_NOTIFY, DN_CREATE | DN_DELETE | DN_RENAME | DN_MULTISHOT);
+ ], [
+ AC_MSG_RESULT("yes")
+ AC_DEFINE(IOLOOP_NOTIFY_DNOTIFY,, Use Linux dnotify)
+ have_notify=dnotify
+ notify=dnotify
+ ], [
+ AC_MSG_RESULT("no")
+ if test "$notify" = "dnotify"; then
+ AC_MSG_WARN([dnotify requested but not available])
+ fi
+ ])
fi
if test "$have_notify" = "none"; then
|