aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-03-03 11:29:45 +0000
committerRon Yorston <rmy@pobox.com>2023-03-03 11:29:45 +0000
commite9ea698021018cb94e6075598eda0c01cf61b28e (patch)
tree312016ba1959040988b3df93635021cd04b13557
parent3cf3b5d29e68d5f85034b6fdc8d1fc2151048197 (diff)
downloadbusybox-w32-e9ea698021018cb94e6075598eda0c01cf61b28e.tar.gz
busybox-w32-e9ea698021018cb94e6075598eda0c01cf61b28e.tar.bz2
busybox-w32-e9ea698021018cb94e6075598eda0c01cf61b28e.zip
win32: update poll(2) to match latest gnulib version
-rw-r--r--win32/poll.c49
1 files 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 @@
1/* Emulation for poll(2) 1/* Emulation for poll(2)
2 Contributed by Paolo Bonzini. 2 Contributed by Paolo Bonzini.
3 3
4 Copyright 2001-2003, 2006-2018 Free Software Foundation, Inc. 4 Copyright 2001-2003, 2006-2022 Free Software Foundation, Inc.
5 5
6 This file is part of gnulib. 6 This file is part of gnulib.
7 7
8 This program is free software; you can redistribute it and/or modify 8 This file is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU Lesser General Public License as
10 the Free Software Foundation; either version 2, or (at your option) 10 published by the Free Software Foundation; either version 2.1 of the
11 any later version. 11 License, or (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This file is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU Lesser General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License along 18 You should have received a copy of the GNU Lesser General Public License
19 with this program; if not, see <https://www.gnu.org/licenses/>. */ 19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 20
21/* Tell gcc not to warn about the (nfd < 0) tests, below. */ 21/* Tell gcc not to warn about the (nfd < 0) tests, below. */
22#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ 22#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
@@ -35,9 +35,8 @@
35#include <limits.h> 35#include <limits.h>
36#include <assert.h> 36#include <assert.h>
37 37
38#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 38#if defined _WIN32 && ! defined __CYGWIN__
39# define WINDOWS_NATIVE 39# define WINDOWS_NATIVE
40# define WIN32_NATIVE
41# include <winsock2.h> 40# include <winsock2.h>
42# include <windows.h> 41# include <windows.h>
43# include <io.h> 42# include <io.h>
@@ -71,6 +70,25 @@
71 70
72#ifdef WINDOWS_NATIVE 71#ifdef WINDOWS_NATIVE
73 72
73/* Don't assume that UNICODE is not defined. */
74# undef GetModuleHandle
75# define GetModuleHandle GetModuleHandleA
76# undef PeekConsoleInput
77# define PeekConsoleInput PeekConsoleInputA
78# undef CreateEvent
79# define CreateEvent CreateEventA
80# undef PeekMessage
81# define PeekMessage PeekMessageA
82# undef DispatchMessage
83# define DispatchMessage DispatchMessageA
84
85/* Do *not* use the function WSAPoll
86 <https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-wsapoll>
87 because there is a bug named “Windows 8 Bugs 309411 - WSAPoll does not
88 report failed connections” that Microsoft won't fix.
89 See Daniel Stenberg: "WASPoll is broken"
90 <https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/>. */
91
74/* Here we need the recv() function from Windows, that takes a SOCKET as 92/* Here we need the recv() function from Windows, that takes a SOCKET as
75 first argument, not any possible gnulib override. */ 93 first argument, not any possible gnulib override. */
76# undef recv 94# undef recv
@@ -79,6 +97,14 @@
79 of SOCKETs, not bit masks of FDs. */ 97 of SOCKETs, not bit masks of FDs. */
80# undef select 98# undef select
81 99
100/* Here we need timeval from Windows since this is what the select() function
101 from Windows requires. */
102# undef timeval
103
104/* Avoid warnings from gcc -Wcast-function-type. */
105# define GetProcAddress \
106 (void *) GetProcAddress
107
82static BOOL IsConsoleHandle (HANDLE h) 108static BOOL IsConsoleHandle (HANDLE h)
83{ 109{
84 DWORD mode; 110 DWORD mode;
@@ -402,7 +428,6 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
402 } 428 }
403 if (pfd[i].events & (POLLIN | POLLRDNORM)) 429 if (pfd[i].events & (POLLIN | POLLRDNORM))
404 FD_SET (pfd[i].fd, &rfds); 430 FD_SET (pfd[i].fd, &rfds);
405
406 /* see select(2): "the only exceptional condition detectable 431 /* see select(2): "the only exceptional condition detectable
407 is out-of-band data received on a socket", hence we push 432 is out-of-band data received on a socket", hence we push
408 POLLWRBAND events onto wfds instead of efds. */ 433 POLLWRBAND events onto wfds instead of efds. */