summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-10-03 19:43:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-04 12:39:56 (GMT)
commitd7e357fb9c702979d5b3a7d9faa869844a12e4d9 (patch)
tree4523cf36dbfeaf303ead7dd2b404ead3e02b58f2 /compat
parentfe8321ec057f9231c26c29b364721568e58040f7 (diff)
downloadgit-d7e357fb9c702979d5b3a7d9faa869844a12e4d9.zip
git-d7e357fb9c702979d5b3a7d9faa869844a12e4d9.tar.gz
git-d7e357fb9c702979d5b3a7d9faa869844a12e4d9.tar.bz2
compat/poll: prepare for targeting Windows Vista
Windows Vista (and later) actually have a working poll(), but we still cannot use it because it only works on sockets. So let's detect when we are targeting Windows Vista and undefine those constants, and define `pollfd` so that we can declare our own pollfd struct. We also need to make sure that we override those constants *after* `winsock2.h` has been `#include`d (otherwise we would not really override those constants). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/poll/poll.c6
-rw-r--r--compat/poll/poll.h15
2 files changed, 18 insertions, 3 deletions
diff --git a/compat/poll/poll.c b/compat/poll/poll.c
index 7ed3fbb..ad5dcde 100644
--- a/compat/poll/poll.c
+++ b/compat/poll/poll.c
@@ -29,9 +29,6 @@
#include <sys/types.h>
-/* Specification. */
-#include <poll.h>
-
#include <errno.h>
#include <limits.h>
#include <assert.h>
@@ -55,6 +52,9 @@
# include <unistd.h>
#endif
+/* Specification. */
+#include "poll.h"
+
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
diff --git a/compat/poll/poll.h b/compat/poll/poll.h
index cd19952..1e15973 100644
--- a/compat/poll/poll.h
+++ b/compat/poll/poll.h
@@ -21,6 +21,21 @@
#ifndef _GL_POLL_H
#define _GL_POLL_H
+#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
+/* Vista has its own, socket-only poll() */
+#undef POLLIN
+#undef POLLPRI
+#undef POLLOUT
+#undef POLLERR
+#undef POLLHUP
+#undef POLLNVAL
+#undef POLLRDNORM
+#undef POLLRDBAND
+#undef POLLWRNORM
+#undef POLLWRBAND
+#define pollfd compat_pollfd
+#endif
+
/* fake a poll(2) environment */
#define POLLIN 0x0001 /* any readable data available */
#define POLLPRI 0x0002 /* OOB/Urgent readable data */