From 1399d14e0ac5884ef00fe4aadd6b7964a288dcbb Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 24 Dec 2008 10:05:19 +0100 Subject: [PATCH] libport: Avoid including winsock2.h. --- configure | 2 -- configure.ac | 1 - include/config.h.in | 3 --- libs/port/poll.c | 23 ++++++++++++++++++++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/configure b/configure index ab27b58bc8c..ac42b9fef3d 100755 --- a/configure +++ b/configure @@ -7438,7 +7438,6 @@ done - for ac_header in \ AudioUnit/AudioUnit.h \ Carbon/Carbon.h \ @@ -7552,7 +7551,6 @@ for ac_header in \ termios.h \ unistd.h \ utime.h \ - winsock2.h \ valgrind/memcheck.h \ valgrind/valgrind.h diff --git a/configure.ac b/configure.ac index be295a4fd6e..a84c82283fa 100644 --- a/configure.ac +++ b/configure.ac @@ -351,7 +351,6 @@ AC_CHECK_HEADERS(\ termios.h \ unistd.h \ utime.h \ - winsock2.h \ valgrind/memcheck.h \ valgrind/valgrind.h ) diff --git a/include/config.h.in b/include/config.h.in index 7f3b8883584..b72a6bbc5c9 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -966,9 +966,6 @@ /* Define to 1 if you have the `waitpid' function. */ #undef HAVE_WAITPID -/* Define to 1 if you have the header file. */ -#undef HAVE_WINSOCK2_H - /* Define to 1 if you have the header file. */ #undef HAVE_X11_EXTENSIONS_SHAPE_H diff --git a/libs/port/poll.c b/libs/port/poll.c index b633a0d90ef..7ee585203f4 100644 --- a/libs/port/poll.c +++ b/libs/port/poll.c @@ -23,9 +23,6 @@ #ifndef HAVE_POLL -#ifdef HAVE_WINSOCK2_H -#include -#endif #ifdef HAVE_SYS_TIME_H #include #endif @@ -33,6 +30,26 @@ #include #endif +/* we can't include winsock2.h here so we have to duplicate the definitions for Windows */ +#if defined(__MINGW32__) || defined(_MSC_VER) + +#define FD_SETSIZE 64 + +typedef struct +{ + unsigned int fd_count; + int fd_array[FD_SETSIZE]; /* an array of SOCKETs */ +} fd_set; + +#define FD_ZERO(set) ((set)->fd_count = 0) +#define FD_ISSET(fd, set) __WSAFDIsSet((fd), (set)) +#define FD_SET(fd, set) do { if ((set)->fd_count < FD_SETSIZE) (set)->fd_array[(set)->fd_count++]=(fd); } while(0) + +int __stdcall select(int,fd_set*,fd_set*,fd_set*,const struct timeval*); +int __stdcall __WSAFDIsSet(int,fd_set*); + +#endif + int poll( struct pollfd *fds, unsigned int count, int timeout ) { fd_set read_set, write_set, except_set; -- 2.11.4.GIT