diff options
| author | Ron Yorston <rmy@pobox.com> | 2021-07-17 11:11:14 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2021-07-17 11:11:14 +0100 |
| commit | 09fac3deea3d74ca283f0a7109e4b190cdf97d95 (patch) | |
| tree | db3d3d67fd05a5cd5d18bc380e110cd092b6fa95 | |
| parent | 1bed117bea0e8cb51b2352c198bea158ddc68f64 (diff) | |
| download | busybox-w32-09fac3deea3d74ca283f0a7109e4b190cdf97d95.tar.gz busybox-w32-09fac3deea3d74ca283f0a7109e4b190cdf97d95.tar.bz2 busybox-w32-09fac3deea3d74ca283f0a7109e4b190cdf97d95.zip | |
mingw: update select(2) to latest gnulib version
| -rw-r--r-- | win32/select.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/win32/select.c b/win32/select.c index 2c9d2d873..2be221ac8 100644 --- a/win32/select.c +++ b/win32/select.c | |||
| @@ -1,30 +1,33 @@ | |||
| 1 | /* Emulation for select(2) | 1 | /* Emulation for select(2) |
| 2 | Contributed by Paolo Bonzini. | 2 | Contributed by Paolo Bonzini. |
| 3 | 3 | ||
| 4 | Copyright 2008-2015 Free Software Foundation, Inc. | 4 | Copyright 2008-2021 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 <http://www.gnu.org/licenses/>. */ | 19 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 20 | 20 | ||
| 21 | #include "libbb.h" | 21 | #include "libbb.h" |
| 22 | #include <malloc.h> | ||
| 23 | #include <assert.h> | ||
| 24 | 22 | ||
| 25 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | 23 | /* Specification. */ |
| 24 | #include <sys/select.h> | ||
| 25 | |||
| 26 | #if defined _WIN32 && ! defined __CYGWIN__ | ||
| 26 | /* Native Windows. */ | 27 | /* Native Windows. */ |
| 27 | 28 | ||
| 29 | #include <malloc.h> | ||
| 30 | #include <assert.h> | ||
| 28 | #include <sys/types.h> | 31 | #include <sys/types.h> |
| 29 | #include <errno.h> | 32 | #include <errno.h> |
| 30 | #include <limits.h> | 33 | #include <limits.h> |
| @@ -37,10 +40,25 @@ | |||
| 37 | #include <time.h> | 40 | #include <time.h> |
| 38 | 41 | ||
| 39 | /* Get the overridden 'struct timeval'. */ | 42 | /* Get the overridden 'struct timeval'. */ |
| 40 | #include <sys/time.h> | ||
| 41 | 43 | ||
| 42 | #undef select | 44 | #undef select |
| 43 | 45 | ||
| 46 | /* Don't assume that UNICODE is not defined. */ | ||
| 47 | #undef GetModuleHandle | ||
| 48 | #define GetModuleHandle GetModuleHandleA | ||
| 49 | #undef PeekConsoleInput | ||
| 50 | #define PeekConsoleInput PeekConsoleInputA | ||
| 51 | #undef CreateEvent | ||
| 52 | #define CreateEvent CreateEventA | ||
| 53 | #undef PeekMessage | ||
| 54 | #define PeekMessage PeekMessageA | ||
| 55 | #undef DispatchMessage | ||
| 56 | #define DispatchMessage DispatchMessageA | ||
| 57 | |||
| 58 | /* Avoid warnings from gcc -Wcast-function-type. */ | ||
| 59 | #define GetProcAddress \ | ||
| 60 | (void *) GetProcAddress | ||
| 61 | |||
| 44 | struct bitset { | 62 | struct bitset { |
| 45 | unsigned char in[FD_SETSIZE / CHAR_BIT]; | 63 | unsigned char in[FD_SETSIZE / CHAR_BIT]; |
| 46 | unsigned char out[FD_SETSIZE / CHAR_BIT]; | 64 | unsigned char out[FD_SETSIZE / CHAR_BIT]; |
| @@ -506,12 +524,13 @@ restart: | |||
| 506 | if (h != handle_array[nhandles]) | 524 | if (h != handle_array[nhandles]) |
| 507 | { | 525 | { |
| 508 | /* Perform handle->descriptor mapping. */ | 526 | /* Perform handle->descriptor mapping. */ |
| 509 | WSAEventSelect ((SOCKET) h, NULL, 0); | 527 | SOCKET s = (SOCKET) h; |
| 510 | if (FD_ISSET (h, &handle_rfds)) | 528 | WSAEventSelect (s, NULL, 0); |
| 529 | if (FD_ISSET (s, &handle_rfds)) | ||
| 511 | FD_SET (i, rfds); | 530 | FD_SET (i, rfds); |
| 512 | if (FD_ISSET (h, &handle_wfds)) | 531 | if (FD_ISSET (s, &handle_wfds)) |
| 513 | FD_SET (i, wfds); | 532 | FD_SET (i, wfds); |
| 514 | if (FD_ISSET (h, &handle_xfds)) | 533 | if (FD_ISSET (s, &handle_xfds)) |
| 515 | FD_SET (i, xfds); | 534 | FD_SET (i, xfds); |
| 516 | } | 535 | } |
| 517 | else | 536 | else |
| @@ -532,7 +551,6 @@ restart: | |||
| 532 | 551 | ||
| 533 | #else /* ! Native Windows. */ | 552 | #else /* ! Native Windows. */ |
| 534 | 553 | ||
| 535 | #include <sys/select.h> | ||
| 536 | #include <stddef.h> /* NULL */ | 554 | #include <stddef.h> /* NULL */ |
| 537 | #include <errno.h> | 555 | #include <errno.h> |
| 538 | #include <unistd.h> | 556 | #include <unistd.h> |
