2 dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 dnl University Research and Technology
4 dnl Corporation. All rights reserved.
5 dnl Copyright (c) 2004-2005 The University of Tennessee and The University
6 dnl of Tennessee Research Foundation. All rights
8 dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 dnl University of Stuttgart. All rights reserved.
10 dnl Copyright (c) 2004-2005 The Regents of the University of California.
11 dnl All rights reserved.
14 dnl Additional copyrights may follow
19 AC_DEFUN([OMPI_SETUP_LIBEVENT],[
21 dnl OMPI: don't use AC_LIBOBJ
24 dnl Check for optional stuff
25 AC_ARG_WITH(event-rtsig,
26 AC_HELP_STRING([--with-event-rtsig],
27 [compile with support for real time signals (experimental)]),
28 [usertsig=yes], [usertsig=no])
30 dnl Checks for libraries.
31 dnl AC_CHECK_LIB(socket, socket)
33 dnl Checks for header files.
35 AC_CHECK_HEADERS(inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h)
36 if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
37 AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
40 #include <sys/queue.h>
44 ], [AC_MSG_RESULT(yes)
45 AC_DEFINE(HAVE_TAILQFOREACH, 1,
46 [Define if TAILQ_FOREACH is defined in <sys/queue.h>])],
51 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
52 AC_MSG_CHECKING(for timeradd in sys/time.h)
59 ], [ AC_DEFINE(HAVE_TIMERADD, 1,
60 [Define if timeradd is defined in <sys/time.h>])
61 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
65 dnl Checks for typedefs, structures, and compiler characteristics.
68 dnl Checks for library functions.
69 AC_CHECK_FUNCS(gettimeofday)
73 AC_CHECK_FUNCS(select, [haveselect=yes], )
74 if test "x$haveselect" = "xyes" ; then
75 # OMPI: Don't use AC_LIBOBJ
76 sources="select.c $sources"
82 AC_CHECK_FUNCS(poll, [havepoll=yes], )
88 if test "$havepoll" = "yes" ; then
95 AC_DEFINE_UNQUOTED([HAVE_WORKING_POLL], [$haveworkingpoll],
96 [Whether poll works for file descriptors and devices])
97 if test "x$havepoll" = "xyes" -a "$haveworkingpoll" = "1" ; then
98 # OMPI: Don't use AC_LIBOBJ
99 sources="poll.c $sources"
102 if test "x$usertsig" = "xyes" ; then
103 AC_CHECK_FUNCS(sigtimedwait, [havertsig=yes], )
106 if test "x$havertsig" = "xyes" ; then
107 AC_MSG_CHECKING(for F_SETSIG in fcntl.h)
115 ], [ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no); havertsig=no])
117 if test "x$havertsig" = "xyes" ; then
118 AC_DEFINE(HAVE_RTSIG, 1, [Define if your system supports POSIX realtime signals])
119 # OMPI: Don't use AC_LIBOBJ
120 sources="rtsig.c $sources"
121 AC_MSG_CHECKING(for working rtsig on pipes)
140 signal(SIGIO, sigio);
141 fcntl(fd[0], F_SETOWN, getpid());
142 fcntl(fd[0], F_SETSIG, SIGIO);
143 fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL) | O_ASYNC);
147 ], [ AC_MSG_RESULT(yes)
148 AC_DEFINE(HAVE_WORKING_RTSIG, 1, [Define if realtime signals work on pipes])],
153 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
154 if test "x$haveepoll" = "xyes" -a "$cross_compiling" != "yes" ; then
156 # OMPI: Unfortunately, this test is not sufficient on some
157 # Linux distros (e.g., RH 9), where the function is defined
158 # and you can link against it, but it's hardwired to return
159 # ENOSYS -- and /usr/include/gnu/stubs.h fails to define
160 # __stub_epoll_ctl (the usual mechanism in glibc to indicate
161 # that a function is a stub and isn't really implemented).
162 # Hence, the test succeeds because it thinks it can use
163 # epoll_ctl (and friends). So we have to do a better test
164 # after we determine that epoll_ctl is linkable. Grumble.
165 # If we are cross compiling, just trust AC_CHECK_FUNCS
167 AC_MSG_CHECKING([for epoll_ctl on broken Linux distros])
169 AC_RUN_IFELSE(AC_LANG_PROGRAM([[
171 #include <sys/epoll.h>]],
172 [[int i = epoll_create(2);
173 FILE *fp = fopen("conftest.out", "w");
174 fprintf(fp, "%d", i);
177 if test -f conftest.out -a "`cat conftest.out`" = "0"; then
181 AC_MSG_RESULT([$haveepoll])
184 if test "x$haveepoll" = "xyes" ; then
185 AC_DEFINE(HAVE_EPOLL, 1,
186 [Define if your system supports the epoll system calls])
187 # OMPI: Don't use AC_LIBOBJ
188 sources="epoll.c $sources"
193 if test "x$ac_cv_header_sys_event_h" = "xyes"; then
194 AC_CHECK_FUNCS(kqueue, [havekqueue=yes], )
195 if test "x$havekqueue" = "xyes" ; then
196 AC_MSG_CHECKING(for working kqueue)
198 #include <sys/types.h>
199 #include <sys/time.h>
200 #include <sys/event.h>
207 main(int argc, char **argv)
218 if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1)
221 while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf))
224 if ((kq = kqueue()) == -1)
228 ev.filter = EVFILT_WRITE;
229 ev.flags = EV_ADD | EV_ENABLE;
230 n = kevent(kq, &ev, 1, NULL, 0, NULL);
234 read(fd[[0]], buf, sizeof(buf));
238 n = kevent(kq, NULL, 0, &ev, 1, &ts);
239 if (n == -1 || n == 0)
243 }, [AC_MSG_RESULT(yes)
244 AC_DEFINE(HAVE_WORKING_KQUEUE, 1,
245 [Define if kqueue works correctly with pipes])
246 sources="kqueue.c $sources"], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
247 # OMPI: don't use AC_LIBOBJ
252 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
253 if test "x$haveepoll" = "xno" ; then
254 AC_MSG_CHECKING(for epoll system call)
257 #include <sys/param.h>
258 #include <sys/types.h>
259 #include <sys/syscall.h>
260 #include <sys/epoll.h>
265 epoll_create(int size)
267 return (syscall(__NR_epoll_create, size));
271 main(int argc, char **argv)
275 epfd = epoll_create(256);
276 exit (epfd == -1 ? 1 : 0);
277 }, [AC_MSG_RESULT(yes)
278 AC_DEFINE(HAVE_EPOLL, 1,
279 [Define if your system supports the epoll system calls])
281 # OMPI: don't use AC_LIBOBJ
282 sources="epoll_sub.c epoll.c $sources"
283 ], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
287 if test "x$needsignal" = "xyes" ; then
288 # OMPI: don't use AC_LIBOBJ
289 sources="signal.c $sources"
292 # OMPI: AC_REPLACE_FUNCS doesn't have much meaning here because it
293 # uses AC_LIBOBJ; use our own test
294 #AC_REPLACE_FUNCS(err)
295 AC_CHECK_FUNC(err, [], [sources="err.c $sources"])
299 AC_CHECK_TYPE(u_int64_t, unsigned long long)
300 AC_CHECK_TYPE(u_int32_t, unsigned int)
301 AC_CHECK_TYPE(u_int16_t, unsigned short)
302 AC_CHECK_TYPE(u_int8_t, unsigned char)
305 # OMPI: Save the libobj sources
306 OMPI_LIBEVENT_SOURCES="$sources"
307 AC_SUBST(OMPI_LIBEVENT_SOURCES)