Skip to content

Commit d7e357f

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe8321e commit d7e357f

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

compat/poll/poll.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929

3030
#include <sys/types.h>
3131

32-
/* Specification. */
33-
#include <poll.h>
34-
3532
#include <errno.h>
3633
#include <limits.h>
3734
#include <assert.h>
@@ -55,6 +52,9 @@
5552
# include <unistd.h>
5653
#endif
5754

55+
/* Specification. */
56+
#include "poll.h"
57+
5858
#ifdef HAVE_SYS_IOCTL_H
5959
# include <sys/ioctl.h>
6060
#endif

compat/poll/poll.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@
2121
#ifndef _GL_POLL_H
2222
#define _GL_POLL_H
2323

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+
2439
/* fake a poll(2) environment */
2540
#define POLLIN 0x0001 /* any readable data available */
2641
#define POLLPRI 0x0002 /* OOB/Urgent readable data */

0 commit comments

Comments
 (0)