From e9ea698021018cb94e6075598eda0c01cf61b28e Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 3 Mar 2023 11:29:45 +0000 Subject: win32: update poll(2) to match latest gnulib version --- win32/poll.c | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/win32/poll.c b/win32/poll.c index 8f16d93e9..18f8795ac 100644 --- a/win32/poll.c +++ b/win32/poll.c @@ -1,22 +1,22 @@ /* Emulation for poll(2) Contributed by Paolo Bonzini. - Copyright 2001-2003, 2006-2018 Free Software Foundation, Inc. + Copyright 2001-2003, 2006-2022 Free Software Foundation, Inc. This file is part of gnulib. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, see . */ + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ /* Tell gcc not to warn about the (nfd < 0) tests, below. */ #if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ @@ -35,9 +35,8 @@ #include #include -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +#if defined _WIN32 && ! defined __CYGWIN__ # define WINDOWS_NATIVE -# define WIN32_NATIVE # include # include # include @@ -71,6 +70,25 @@ #ifdef WINDOWS_NATIVE +/* Don't assume that UNICODE is not defined. */ +# undef GetModuleHandle +# define GetModuleHandle GetModuleHandleA +# undef PeekConsoleInput +# define PeekConsoleInput PeekConsoleInputA +# undef CreateEvent +# define CreateEvent CreateEventA +# undef PeekMessage +# define PeekMessage PeekMessageA +# undef DispatchMessage +# define DispatchMessage DispatchMessageA + +/* Do *not* use the function WSAPoll + + because there is a bug named “Windows 8 Bugs 309411 - WSAPoll does not + report failed connections” that Microsoft won't fix. + See Daniel Stenberg: "WASPoll is broken" + . */ + /* Here we need the recv() function from Windows, that takes a SOCKET as first argument, not any possible gnulib override. */ # undef recv @@ -79,6 +97,14 @@ of SOCKETs, not bit masks of FDs. */ # undef select +/* Here we need timeval from Windows since this is what the select() function + from Windows requires. */ +# undef timeval + +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + static BOOL IsConsoleHandle (HANDLE h) { DWORD mode; @@ -402,7 +428,6 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) } if (pfd[i].events & (POLLIN | POLLRDNORM)) FD_SET (pfd[i].fd, &rfds); - /* see select(2): "the only exceptional condition detectable is out-of-band data received on a socket", hence we push POLLWRBAND events onto wfds instead of efds. */ -- cgit v1.2.3-55-g6feb