libc: Add wrapper for poll()

This commit is contained in:
apio 2023-08-02 17:19:16 +02:00
parent df4227eab8
commit 6593f9241b
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 34 additions and 0 deletions

View File

@ -32,6 +32,7 @@ set(SOURCES
src/sys/pstat.cpp
src/sys/resource.cpp
src/sys/socket.cpp
src/sys/poll.cpp
)
if(${LUNA_ARCH} STREQUAL "x86_64")

20
libc/include/sys/poll.h Normal file
View File

@ -0,0 +1,20 @@
/* sys/poll.h: Wait for events on multiple file descriptors. */
#ifndef _SYS_POLL_H
#define _SYS_POLL_H
#include <bits/poll.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* Wait for events on multiple file descriptors. */
int poll(struct pollfd* fds, nfds_t nfds, int timeout);
#ifdef __cplusplus
}
#endif
#endif

13
libc/src/sys/poll.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <bits/errno-return.h>
#include <sys/poll.h>
#include <sys/syscall.h>
#include <unistd.h>
extern "C"
{
int poll(struct pollfd* fds, nfds_t nfds, int timeout)
{
long rc = syscall(SYS_poll, fds, nfds, timeout);
__errno_return(rc, int);
}
}