Git fork

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>

authored by

Johannes Schindelin and committed by
Junio C Hamano
d7e357fb fe8321ec

+18 -3
+3 -3
compat/poll/poll.c
··· 29 29 30 30 #include <sys/types.h> 31 31 32 - /* Specification. */ 33 - #include <poll.h> 34 - 35 32 #include <errno.h> 36 33 #include <limits.h> 37 34 #include <assert.h> ··· 54 51 # endif 55 52 # include <unistd.h> 56 53 #endif 54 + 55 + /* Specification. */ 56 + #include "poll.h" 57 57 58 58 #ifdef HAVE_SYS_IOCTL_H 59 59 # include <sys/ioctl.h>
+15
compat/poll/poll.h
··· 21 21 #ifndef _GL_POLL_H 22 22 #define _GL_POLL_H 23 23 24 + #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 25 + /* Vista has its own, socket-only poll() */ 26 + #undef POLLIN 27 + #undef POLLPRI 28 + #undef POLLOUT 29 + #undef POLLERR 30 + #undef POLLHUP 31 + #undef POLLNVAL 32 + #undef POLLRDNORM 33 + #undef POLLRDBAND 34 + #undef POLLWRNORM 35 + #undef POLLWRBAND 36 + #define pollfd compat_pollfd 37 + #endif 38 + 24 39 /* fake a poll(2) environment */ 25 40 #define POLLIN 0x0001 /* any readable data available */ 26 41 #define POLLPRI 0x0002 /* OOB/Urgent readable data */