summaryrefslogtreecommitdiff
path: root/m4/poll_h.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-09-29 01:00:17 +0200
committerBruno Haible <bruno@clisp.org>2010-09-29 01:00:17 +0200
commit11f1d3a976a737eb6ca30cf89e8b47c85bfe3d47 (patch)
tree2750fb1776792f916f4dcdb9ac73d360bca0764a /m4/poll_h.m4
parent532d19ed682a2fcc68f97fc63c63e0a514f851d5 (diff)
downloadgnulib-11f1d3a976a737eb6ca30cf89e8b47c85bfe3d47.tar.gz
New module 'poll-h'.
* lib/poll.in.h: Include c++defs.h and warn-on-use.h. (poll): Use modern idiom. * modules/poll-h: New file. * modules/poll (Files): Remove lib/poll.in.h. (Depends-on): Add poll-h. (configure.ac): Invoke gl_POLL_MODULE_INDICATOR. (Makefile.am): Move code for generation of poll.h to modules/poll-h. * m4/poll_h.m4: New file. * m4/poll.m4 (gl_FUNC_POLL): Require gl_POLL_H. Don't check for poll.h here. Don't set POLL_H here. Instead, set HAVE_POLL and REPLACE_POLL and invoke gl_REPLACE_POLL_H. * lib/poll.c: Use common idiom. * tests/test-poll.c: Likewise. * doc/posix-headers/poll.texi: Mention the poll-h module. Suggested by Eric Blake.
Diffstat (limited to 'm4/poll_h.m4')
-rw-r--r--m4/poll_h.m449
1 files changed, 49 insertions, 0 deletions
diff --git a/m4/poll_h.m4 b/m4/poll_h.m4
new file mode 100644
index 0000000000..6f041689ac
--- /dev/null
+++ b/m4/poll_h.m4
@@ -0,0 +1,49 @@
+# poll_h.m4 serial 1
+dnl Copyright (C) 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Bruno Haible.
+
+AC_DEFUN([gl_POLL_H],
+[
+ dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+ dnl once only, before all statements that occur in other macros.
+ AC_REQUIRE([gl_POLL_H_DEFAULTS])
+
+ AC_CHECK_HEADERS_ONCE([poll.h])
+ if test $ac_cv_header_poll_h != yes; then
+ gl_REPLACE_POLL_H
+ fi
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[#include <poll.h>]],
+ [poll])
+])
+
+dnl Unconditionally enables the replacement of <poll.h>.
+AC_DEFUN([gl_REPLACE_POLL_H],
+[
+ AC_REQUIRE([gl_POLL_H_DEFAULTS])
+ POLL_H='poll.h'
+])
+
+AC_DEFUN([gl_POLL_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_POLL_H_DEFAULTS])
+ gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+ dnl Define it also as a C macro, for the benefit of the unit tests.
+ gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_POLL_H_DEFAULTS],
+[
+ GNULIB_POLL=0; AC_SUBST([GNULIB_POLL])
+ dnl Assume proper GNU behavior unless another module says otherwise.
+ POLL_H=''; AC_SUBST([POLL_H])
+ HAVE_POLL=1; AC_SUBST([HAVE_POLL])
+ REPLACE_POLL=0; AC_SUBST([REPLACE_POLL])
+])