1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

LibC+Kernel: Implement ppoll

ppoll() is similar() to poll(), but it takes its timeout
as timespec instead of as int, and it takes an additional
sigmask parameter.

Change the sys$poll parameters to match ppoll() and implement
poll() in terms of ppoll().
This commit is contained in:
Nico Weber 2020-06-22 11:41:51 -04:00 committed by Andreas Kling
parent 4b19b99b36
commit d2684a8645
5 changed files with 55 additions and 19 deletions

View file

@ -27,12 +27,25 @@
#include <Kernel/Syscall.h>
#include <errno.h>
#include <poll.h>
#include <sys/time.h>
extern "C" {
int poll(struct pollfd* fds, int nfds, int timeout)
int poll(pollfd* fds, nfds_t nfds, int timeout_ms)
{
int rc = syscall(SC_poll, fds, nfds, timeout);
timespec timeout;
timespec* timeout_ts = &timeout;
if (timeout_ms < 0)
timeout_ts = nullptr;
else
timeout = { timeout_ms / 1000, (timeout_ms % 1000) * 1'000'000 };
return ppoll(fds, nfds, timeout_ts, nullptr);
}
int ppoll(pollfd* fds, nfds_t nfds, const timespec* timeout, const sigset_t* sigmask)
{
Syscall::SC_poll_params params { fds, nfds, timeout, sigmask };
int rc = syscall(SC_poll, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}