ladybird/Userland/Libraries/LibC/sys/select.cpp
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

32 lines
891 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <errno.h>
#include <stdio.h>
#include <sys/select.h>
#include <sys/time.h>
#include <syscall.h>
extern "C" {
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, timeval* timeout_tv)
{
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, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}