summaryrefslogtreecommitdiff
path: root/lib/poll.in.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-06-30 14:43:44 +0200
committerBruno Haible <bruno@clisp.org>2019-06-30 14:43:44 +0200
commita734086a9b2783d74f01f8f5ac10d7b601c07120 (patch)
tree7005635a56fdf7c19acdf0e8f783356469e9b15f /lib/poll.in.h
parente597d4b8e50f57cfb72ee4fb8ee75c48ddbec97f (diff)
downloadgnulib-a734086a9b2783d74f01f8f5ac10d7b601c07120.tar.gz
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.
Diffstat (limited to 'lib/poll.in.h')
-rw-r--r--lib/poll.in.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/poll.in.h b/lib/poll.in.h
index 5cf65665b8..0b115dcb31 100644
--- a/lib/poll.in.h
+++ b/lib/poll.in.h
@@ -33,6 +33,13 @@
#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. */
@@ -41,6 +48,21 @@
#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 */