From: Bruno Haible Date: Tue, 28 Sep 2010 23:51:18 +0000 (+0200) Subject: poll-h: Create poll.h on all platforms. X-Git-Tag: v0.1~3747 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=55898ee1c7c12e63772c65e772577f10bb7adb31;p=gnulib.git 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 . * 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. --- diff --git a/ChangeLog b/ChangeLog index d8b9f0e15..8eba95109 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2010-09-28 Bruno Haible + 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 . + * 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 + 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 e7f211bfc..cb8a6f886 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 6f041689a..2ae995a0f 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 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 . AC_DEFUN([gl_REPLACE_POLL_H], [ - AC_REQUIRE([gl_POLL_H_DEFAULTS]) - POLL_H='poll.h' + dnl This is a no-op, because 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 7ba11adc0..c456ae530 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 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)' \