2 dnl Copyright (c) 2003, 2005, 2006, 2007, 2009, 2010 Free Software Foundation,
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_POLL],
10 AC_CHECK_HEADERS([poll.h])
11 if test "$ac_cv_header_poll_h" = no; then
15 [# Check whether poll() works on special files (like /dev/null) and
16 # and ttys (like /dev/tty). On MacOS X 10.4.0 and AIX 5.3, it doesn't.
17 AC_RUN_IFELSE([AC_LANG_SOURCE([[
23 /* Try /dev/null for reading. */
24 ufd.fd = open ("/dev/null", O_RDONLY);
26 /* If /dev/null does not exist, it's not MacOS X nor AIX. */
30 if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLIN))
32 /* Try /dev/null for writing. */
33 ufd.fd = open ("/dev/null", O_WRONLY);
35 /* If /dev/null does not exist, it's not MacOS X nor AIX. */
39 if (!(poll (&ufd, 1, 0) == 1 && ufd.revents == POLLOUT))
41 /* Trying /dev/tty may be too environment dependent. */
44 [gl_cv_func_poll=yes],
46 [# When cross-compiling, assume that poll() works everywhere except on
47 # MacOS X or AIX, regardless of its version.
48 AC_EGREP_CPP([MacOSX], [
49 #if (defined(__APPLE__) && defined(__MACH__)) || defined(_AIX)
52 ], [gl_cv_func_poll=no], [gl_cv_func_poll=yes])])])
54 if test $gl_cv_func_poll = yes; then
55 AC_DEFINE([HAVE_POLL], [1],
56 [Define to 1 if you have the 'poll' function and it works.])
60 AC_DEFINE([poll], [rpl_poll],
61 [Define to poll if the replacement function should be used.])
68 # Prerequisites of lib/poll.c.
69 AC_DEFUN([gl_PREREQ_POLL],
71 AC_CHECK_HEADERS_ONCE([sys/ioctl.h sys/filio.h])