summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--lib/poll.in.h47
-rw-r--r--m4/poll_h.m414
-rw-r--r--modules/poll-h9
4 files changed, 62 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index d8b9f0e151..8eba951098 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2010-09-28 Bruno Haible <bruno@clisp.org>
+ poll-h: Create poll.h on all platforms.
+ * lib/poll.in.h: Use double-inclusion guard. Don't define POLL*,
+ struct pollfd, nfds_t, INFTIM when the system has <poll.h>.
+ * m4/poll_h.m4 (gl_POLL_H): Set HAVE_POLL_H. Invoke
+ gl_CHECK_NEXT_HEADERS. Don't set POLL_H.
+ (gl_REPLACE_POLL_H): Don't set POLL_H.
+ (gl_POLL_H_DEFAULTS): Don't initialize POLL_H.
+ * modules/poll-h (Depends-on): Add include_next.
+ (Makefile.am): Create poll.h unconditionally. Substitute also
+ HAVE_POLL_H, INCLUDE_NEXT, PRAGMA_SYSTEM_HEADER, NEXT_POLL_H.
+
+2010-09-28 Bruno Haible <bruno@clisp.org>
+
Tests for module 'poll-h'.
* modules/poll-h-c++-tests: New file.
* tests/test-poll-h-c++.cc: New file.
diff --git a/lib/poll.in.h b/lib/poll.in.h
index e7f211bfcc..cb8a6f8869 100644
--- a/lib/poll.in.h
+++ b/lib/poll.in.h
@@ -20,6 +20,17 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _GL_POLL_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_POLL_H@
+# @INCLUDE_NEXT@ @NEXT_POLL_H@
+#endif
+
+#ifndef _GL_POLL_H
#define _GL_POLL_H
@@ -28,17 +39,19 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
+#if !@HAVE_POLL_H@
+
/* fake a poll(2) environment */
-#define POLLIN 0x0001 /* any readable data available */
-#define POLLPRI 0x0002 /* OOB/Urgent readable data */
-#define POLLOUT 0x0004 /* file descriptor is writeable */
-#define POLLERR 0x0008 /* some poll error occurred */
-#define POLLHUP 0x0010 /* file descriptor was "hung up" */
-#define POLLNVAL 0x0020 /* requested events "invalid" */
-#define POLLRDNORM 0x0040
-#define POLLRDBAND 0x0080
-#define POLLWRNORM 0x0100
-#define POLLWRBAND 0x0200
+# define POLLIN 0x0001 /* any readable data available */
+# define POLLPRI 0x0002 /* OOB/Urgent readable data */
+# define POLLOUT 0x0004 /* file descriptor is writeable */
+# define POLLERR 0x0008 /* some poll error occurred */
+# define POLLHUP 0x0010 /* file descriptor was "hung up" */
+# define POLLNVAL 0x0020 /* requested events "invalid" */
+# define POLLRDNORM 0x0040
+# define POLLRDBAND 0x0080
+# define POLLWRNORM 0x0100
+# define POLLWRBAND 0x0200
struct pollfd
{
@@ -49,6 +62,14 @@ struct pollfd
typedef unsigned long nfds_t;
+/* Define INFTIM only if doing so conforms to POSIX. */
+# if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
+# define INFTIM (-1)
+# endif
+
+#endif
+
+
#if @GNULIB_POLL@
# if @REPLACE_POLL@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -72,10 +93,6 @@ _GL_WARN_ON_USE (poll, "poll is unportable - "
# endif
#endif
-/* Define INFTIM only if doing so conforms to POSIX. */
-#if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
-#define INFTIM (-1)
-#endif
-
#endif /* _GL_POLL_H */
+#endif /* _GL_POLL_H */
diff --git a/m4/poll_h.m4 b/m4/poll_h.m4
index 6f041689ac..2ae995a0f5 100644
--- a/m4/poll_h.m4
+++ b/m4/poll_h.m4
@@ -13,9 +13,16 @@ AC_DEFUN([gl_POLL_H],
AC_REQUIRE([gl_POLL_H_DEFAULTS])
AC_CHECK_HEADERS_ONCE([poll.h])
- if test $ac_cv_header_poll_h != yes; then
+ if test $ac_cv_header_poll_h = yes; then
+ HAVE_POLL_H=1
+ else
+ HAVE_POLL_H=0
gl_REPLACE_POLL_H
fi
+ AC_SUBST([HAVE_POLL_H])
+
+ dnl <poll.h> is always overridden, because of GNULIB_POSIXCHECK.
+ gl_CHECK_NEXT_HEADERS([poll.h])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use.
@@ -26,8 +33,8 @@ AC_DEFUN([gl_POLL_H],
dnl Unconditionally enables the replacement of <poll.h>.
AC_DEFUN([gl_REPLACE_POLL_H],
[
- AC_REQUIRE([gl_POLL_H_DEFAULTS])
- POLL_H='poll.h'
+ dnl This is a no-op, because <poll.h> is always overridden.
+ :
])
AC_DEFUN([gl_POLL_MODULE_INDICATOR],
@@ -43,7 +50,6 @@ 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])
])
diff --git a/modules/poll-h b/modules/poll-h
index 7ba11adc0d..c456ae5300 100644
--- a/modules/poll-h
+++ b/modules/poll-h
@@ -8,20 +8,25 @@ m4/poll_h.m4
Depends-on:
c++defs
extensions
+include_next
warn-on-use
configure.ac:
gl_POLL_H
Makefile.am:
-BUILT_SOURCES += $(POLL_H)
+BUILT_SOURCES += poll.h
# We need the following in order to create <poll.h> when the system
# doesn't have one.
poll.h: poll.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GNULIB_POLL''@|$(GNULIB_POLL)|g' \
+ sed -e 's|@''HAVE_POLL_H''@|$(HAVE_POLL_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_POLL_H''@|$(NEXT_POLL_H)|g' \
+ -e 's|@''GNULIB_POLL''@|$(GNULIB_POLL)|g' \
-e 's|@''HAVE_POLL''@|$(HAVE_POLL)|g' \
-e 's|@''REPLACE_POLL''@|$(REPLACE_POLL)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \