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>
This commit is contained in:

committed by
Junio C Hamano

parent
fe8321ec05
commit
d7e357fb9c
@ -29,9 +29,6 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/* Specification. */
|
|
||||||
#include <poll.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -55,6 +52,9 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include "poll.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
# include <sys/ioctl.h>
|
# include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,6 +21,21 @@
|
|||||||
#ifndef _GL_POLL_H
|
#ifndef _GL_POLL_H
|
||||||
#define _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 */
|
/* fake a poll(2) environment */
|
||||||
#define POLLIN 0x0001 /* any readable data available */
|
#define POLLIN 0x0001 /* any readable data available */
|
||||||
#define POLLPRI 0x0002 /* OOB/Urgent readable data */
|
#define POLLPRI 0x0002 /* OOB/Urgent readable data */
|
||||||
|
Reference in New Issue
Block a user