BuildSystem: Move all userpace libraries under the userspace directory
As the number of libraries is increasing, root directory starts to expand. This adds better organization for libraries
This commit is contained in:
31
userspace/libraries/LibC/sys/select.cpp
Normal file
31
userspace/libraries/LibC/sys/select.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <sys/select.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int pselect(int nfds, fd_set* __restrict readfds, fd_set* __restrict writefds, fd_set* __restrict errorfds, const struct timespec* __restrict timeout, const sigset_t* __restrict sigmask)
|
||||
{
|
||||
sys_pselect_t arguments {
|
||||
.nfds = nfds,
|
||||
.readfds = readfds,
|
||||
.writefds = writefds,
|
||||
.errorfds = errorfds,
|
||||
.timeout = timeout,
|
||||
.sigmask = sigmask
|
||||
};
|
||||
return syscall(SYS_PSELECT, &arguments);
|
||||
}
|
||||
|
||||
int select(int nfds, fd_set* __restrict readfds, fd_set* __restrict writefds, fd_set* __restrict errorfds, struct timeval* __restrict timeout)
|
||||
{
|
||||
timespec* pts = nullptr;
|
||||
timespec ts;
|
||||
if (timeout)
|
||||
{
|
||||
ts.tv_sec = timeout->tv_sec;
|
||||
ts.tv_nsec = timeout->tv_usec * 1000;
|
||||
pts = &ts;
|
||||
}
|
||||
|
||||
// TODO: "select may update timeout", should we?
|
||||
return pselect(nfds, readfds, writefds, errorfds, pts, nullptr);
|
||||
}
|
||||
Reference in New Issue
Block a user