2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-01-23 09:27:41 +03:00
|
|
|
#include <errno.h>
|
2019-06-07 12:49:03 +03:00
|
|
|
#include <poll.h>
|
2020-06-22 18:41:51 +03:00
|
|
|
#include <sys/time.h>
|
2021-02-05 14:16:30 +03:00
|
|
|
#include <syscall.h>
|
2019-01-23 09:27:41 +03:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2020-06-22 18:41:51 +03:00
|
|
|
int poll(pollfd* fds, nfds_t nfds, int timeout_ms)
|
2019-01-23 09:27:41 +03:00
|
|
|
{
|
2020-06-22 18:41:51 +03:00
|
|
|
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, ¶ms);
|
2019-01-23 09:27:41 +03:00
|
|
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
|
|
}
|
|
|
|
}
|