2 dnl Copyright (c) 2003, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_POLL],
9 AC_CHECK_HEADERS(poll.h)
10 if test "$ac_cv_header_poll_h" = no; then
18 [# Check whether poll() works on special files (like /dev/null) and
19 # and ttys (like /dev/tty). On MacOS X 10.4.0 and AIX 5.3, it doesn't.
26 /* Try /dev/null for reading. */
27 ufd.fd = open ("/dev/null", O_RDONLY);
29 /* If /dev/null does not exist, it's not MacOS X nor AIX. */
33 if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLIN))
35 /* Try /dev/null for writing. */
36 ufd.fd = open ("/dev/null", O_WRONLY);
38 /* If /dev/null does not exist, it's not MacOS X nor AIX. */
42 if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLOUT))
44 /* Trying /dev/tty may be too environment dependent. */
47 [gl_cv_func_poll=yes],
49 [# When cross-compiling, assume that poll() works everywhere except on
50 # MacOS X or AIX, regardless of its version.
51 AC_EGREP_CPP([MacOSX], [
52 #if (defined(__APPLE__) && defined(__MACH__)) || defined(_AIX)
55 ], [gl_cv_func_poll=no], [gl_cv_func_poll=yes])])])
56 if test $gl_cv_func_poll = yes; then
57 AC_DEFINE([HAVE_POLL], 1,
58 [Define to 1 if you have the 'poll' function and it works.])
61 if test $gl_cv_func_poll = no; then
62 POLL_H=poll.h # Avoid differing declaration from a system header.
64 AC_DEFINE(poll, rpl_poll,
65 [Define to poll if the replacement function should be used.])
70 # Prerequisites of lib/poll.c.
71 AC_DEFUN([gl_PREREQ_POLL],
73 AC_REQUIRE([AC_HEADER_TIME])
74 AC_CHECK_HEADERS_ONCE(sys/time.h)