| 1 |
/* Test of pselect() substitute. |
| 2 |
Copyright (C) 2011-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This program is free software: you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation, either version 3 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 16 |
|
| 17 |
#include <config.h> |
| 18 |
|
| 19 |
#include <sys/select.h> |
| 20 |
|
| 21 |
#include "signature.h" |
| 22 |
|
| 23 |
SIGNATURE_CHECK (pselect, int, |
| 24 |
(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, |
| 25 |
struct timespec const *restrict, const sigset_t *restrict)); |
| 26 |
|
| 27 |
#define TEST_PORT 12347 |
| 28 |
#include "test-select.h" |
| 29 |
|
| 30 |
static int |
| 31 |
my_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, |
| 32 |
struct timeval *timeout) |
| 33 |
{ |
| 34 |
struct timespec ts; |
| 35 |
struct timespec *pts = NULL; |
| 36 |
if (timeout) |
| 37 |
{ |
| 38 |
ts.tv_sec = timeout->tv_sec; |
| 39 |
ts.tv_nsec = timeout->tv_usec * 1000; |
| 40 |
pts = &ts; |
| 41 |
} |
| 42 |
return pselect (nfds, readfds, writefds, exceptfds, pts, NULL); |
| 43 |
} |
| 44 |
|
| 45 |
int |
| 46 |
main (void) |
| 47 |
{ |
| 48 |
int result = test_function (my_select); |
| 49 |
return (result ? result : test_exit_status); |
| 50 |
} |