]> Savannah Git Hosting - gnulib.git/commitdiff
poll-h: Fix compilation error on mingw with _WIN32_WINNT >= 0x0600.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2019 12:43:44 +0000 (14:43 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2019 12:43:44 +0000 (14:43 +0200)
Reported by Hannes Müller <h.c.f.mueller@gmx.de>.

* lib/poll.in.h: Include <winsock2.h>.
(POLL*, pollfd): Override on native Windows.
* m4/poll_h.m4 (gl_POLL_H): Invoke gl_PREREQ_SYS_H_WINSOCK2.
* modules/poll-h (Files): Add m4/sys_socket_h.m4.
(Makefile.am): Substitute HAVE_WINSOCK2_H.

ChangeLog
lib/poll.in.h
m4/poll_h.m4
modules/poll-h

index e808c30a063cf1717c3f61b5ad79408d94c9a183..6fe1531a04b8c9f14cbfc9550d23b0c61802a541 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-06-30  Bruno Haible  <bruno@clisp.org>
+
+       poll-h: Fix compilation error on mingw with _WIN32_WINNT >= 0x0600.
+       Reported by Hannes Müller <h.c.f.mueller@gmx.de>.
+       * lib/poll.in.h: Include <winsock2.h>.
+       (POLL*, pollfd): Override on native Windows.
+       * m4/poll_h.m4 (gl_POLL_H): Invoke gl_PREREQ_SYS_H_WINSOCK2.
+       * modules/poll-h (Files): Add m4/sys_socket_h.m4.
+       (Makefile.am): Substitute HAVE_WINSOCK2_H.
+
 2019-06-28  Bruno Haible  <bruno@clisp.org>
 
        accept4: Fix compilation error on OpenIndiana.
index 5cf65665b83cae961d8bc1d1c13312706f51958e..0b115dcb3122e48e25819a196b6b81710d76649a 100644 (file)
 #ifndef _@GUARD_PREFIX@_POLL_H
 #define _@GUARD_PREFIX@_POLL_H
 
+/* On native Windows, get the 'struct pollfd' type and the POLL* macro
+   definitions before we override them.  mingw defines them in <winsock2.h>
+   if _WIN32_WINNT >= 0x0600.  */
+#if @HAVE_WINSOCK2_H@
+# include <winsock2.h>
+#endif
+
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 
 #if !@HAVE_POLL_H@
 
+# if @HAVE_WINSOCK2_H@
+/* Override the definitions from <winsock2.h>.  */
+#  undef POLLIN
+#  undef POLLPRI
+#  undef POLLOUT
+#  undef POLLERR
+#  undef POLLHUP
+#  undef POLLNVAL
+#  undef POLLRDNORM
+#  undef POLLRDBAND
+#  undef POLLWRNORM
+#  undef POLLWRBAND
+#  define pollfd rpl_pollfd
+# endif
+
 /* fake a poll(2) environment */
 # define POLLIN      0x0001      /* any readable data available   */
 # define POLLPRI     0x0002      /* OOB/Urgent readable data      */
index 94de19b4886cc0667b83106530c3ec3f91d88f27..8f0e105287bd5321f00c9f12237c4104faaf3cb2 100644 (file)
@@ -1,4 +1,4 @@
-# poll_h.m4 serial 2
+# poll_h.m4 serial 3
 dnl Copyright (C) 2010-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -23,6 +23,8 @@ AC_DEFUN([gl_POLL_H],
   dnl <poll.h> is always overridden, because of GNULIB_POSIXCHECK.
   gl_CHECK_NEXT_HEADERS([poll.h])
 
+  gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
+
   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>]],
index c1d3969f41d53acd71df7f6c2086912f56efb4f0..3c687589918383a479b19236e7a156ea81190e00 100644 (file)
@@ -4,6 +4,7 @@ A POSIX-like <poll.h>.
 Files:
 lib/poll.in.h
 m4/poll_h.m4
+m4/sys_socket_h.m4
 
 Depends-on:
 extensions
@@ -29,6 +30,7 @@ poll.h: poll.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_POLL_H''@|$(NEXT_POLL_H)|g' \
              -e 's/@''GNULIB_POLL''@/$(GNULIB_POLL)/g' \
+             -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
              -e 's|@''HAVE_POLL''@|$(HAVE_POLL)|g' \
              -e 's|@''REPLACE_POLL''@|$(REPLACE_POLL)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \