]>
git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/cloudlibc/src/libc/sys/select/select.c
5d4bc934aab038d977e2894b741b8e5873691afe
1 // Copyright (c) 2015 Nuxi, https://nuxi.nl/
3 // SPDX-License-Identifier: BSD-2-Clause
5 #include <sys/select.h>
10 int select(int nfds
, fd_set
*restrict readfds
, fd_set
*restrict writefds
,
11 fd_set
*restrict errorfds
, struct timeval
*restrict timeout
) {
12 if (timeout
!= NULL
) {
14 if (timeout
->tv_usec
< 0 || timeout
->tv_usec
>= 1000000) {
18 struct timespec ts
= {.tv_sec
= timeout
->tv_sec
,
19 .tv_nsec
= (long)timeout
->tv_usec
* 1000};
20 #ifdef __wasilibc_unmodified_upstream
21 return pselect(nfds
, readfds
, writefds
, errorfds
, &ts
);
23 return pselect(nfds
, readfds
, writefds
, errorfds
, &ts
, NULL
);
26 // No timeout specified.
27 #ifdef __wasilibc_unmodified_upstream
28 return pselect(nfds
, readfds
, writefds
, errorfds
, NULL
);
30 return pselect(nfds
, readfds
, writefds
, errorfds
, NULL
, NULL
);