Kernel/LibC: Implement basic epoll
This implementation is on top of inodes instead of fds as linux does it. If I start finding ports/software that relies on epoll allowing duplicate inodes, I will do what linux does. I'm probably missing multiple epoll_notify's which may cause hangs but the system seems to work fine :dd:
This commit is contained in:
49
userspace/libraries/LibC/include/sys/epoll.h
Normal file
49
userspace/libraries/LibC/include/sys/epoll.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef _SYS_EPOLL_H
|
||||
#define _SYS_EPOLL_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <stdint.h>
|
||||
#include <signal.h>
|
||||
|
||||
union epoll_data
|
||||
{
|
||||
void* ptr;
|
||||
int fd;
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
};
|
||||
typedef union epoll_data epoll_data_t;
|
||||
|
||||
struct epoll_event
|
||||
{
|
||||
uint32_t events;
|
||||
epoll_data_t data;
|
||||
};
|
||||
|
||||
#define EPOLL_CTL_ADD 0
|
||||
#define EPOLL_CTL_MOD 1
|
||||
#define EPOLL_CTL_DEL 2
|
||||
|
||||
#define EPOLLIN 0x01
|
||||
#define EPOLLOUT 0x02
|
||||
#define EPOLLPRI 0x04
|
||||
#define EPOLLERR 0x08
|
||||
#define EPOLLHUP 0x10
|
||||
#define EPOLLET 0x20
|
||||
#define EPOLLONESHOT 0x40
|
||||
|
||||
#define EPOLL_CLOEXEC 1
|
||||
|
||||
int epoll_create(int size);
|
||||
int epoll_create1(int flags);
|
||||
int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event);
|
||||
int epoll_wait(int epfd, struct epoll_event* events, int maxevents, int timeout);
|
||||
int epoll_pwait(int epfd, struct epoll_event* events, int maxevents, int timeout, const sigset_t* sigmask);
|
||||
int epoll_pwait2(int epfd, struct epoll_event* events, int maxevents, const struct timespec* timeout, const sigset_t* sigmask);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -98,6 +98,9 @@ __BEGIN_DECLS
|
||||
O(SYS_PTHREAD_EXIT, pthread_exit) \
|
||||
O(SYS_PTHREAD_JOIN, pthread_join) \
|
||||
O(SYS_PTHREAD_SELF, pthread_self) \
|
||||
O(SYS_EPOLL_CREATE1, epoll_create1) \
|
||||
O(SYS_EPOLL_CTL, epoll_ctl) \
|
||||
O(SYS_EPOLL_PWAIT2, epoll_pwait2) \
|
||||
|
||||
enum Syscall
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user