mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibC: Implement pselect
pselect() is similar() to select(), but it takes its timeout as timespec instead of as timeval, and it takes an additional sigmask parameter. Change the sys$select parameters to match pselect() and implement select() in terms of pselect().
This commit is contained in:
parent
29f509a2a0
commit
d23e655c83
6 changed files with 46 additions and 19 deletions
|
@ -28,12 +28,24 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout)
|
||||
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timeval* timeout_tv)
|
||||
{
|
||||
Syscall::SC_select_params params { nfds, readfds, writefds, exceptfds, timeout };
|
||||
timespec* timeout_ts = nullptr;
|
||||
timespec timeout;
|
||||
if (timeout_tv) {
|
||||
timeout_ts = &timeout;
|
||||
TIMEVAL_TO_TIMESPEC(timeout_tv, timeout_ts);
|
||||
}
|
||||
return pselect(nfds, readfds, writefds, exceptfds, timeout_ts, nullptr);
|
||||
}
|
||||
|
||||
int pselect(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const timespec* timeout, const sigset_t* sigmask)
|
||||
{
|
||||
Syscall::SC_select_params params { nfds, readfds, writefds, exceptfds, timeout, sigmask };
|
||||
int rc = syscall(SC_select, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue