forked from LemonOSProject/LemonOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel: Implement syscalls for epoll
- Loading branch information
Showing
4 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <ABI/EPoll.h> | ||
#include <Fs/Filesystem.h> | ||
#include <List.h> | ||
#include <Pair.h> | ||
|
||
namespace fs { | ||
|
||
class EPoll : | ||
public FsNode { | ||
public: | ||
EPoll() = default; | ||
|
||
void Close() override { | ||
handleCount--; | ||
|
||
if(handleCount <= 0){ | ||
delete this; | ||
} | ||
} | ||
|
||
bool IsEPoll() const override { | ||
return true; | ||
} | ||
|
||
List<Pair<int, epoll_event>> fds; | ||
lock_t epLock = 0; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <Compiler.h> | ||
|
||
template <typename T> | ||
concept CleanupFunction = requires(T t) { | ||
t(); | ||
}; | ||
|
||
template <CleanupFunction F> class OnCleanup { | ||
public: | ||
ALWAYS_INLINE OnCleanup(F&& func) : m_func(func) {} | ||
|
||
ALWAYS_INLINE ~OnCleanup() { m_func(); } | ||
|
||
private: | ||
F m_func; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
#define EPOLL_CLOEXEC 1 | ||
#define EPOLL_NONBLOCK 2 | ||
|
||
#define EPOLLIN 0x001 | ||
#define EPOLLPRI 0x002 | ||
#define EPOLLOUT 0x004 | ||
#define EPOLLRDNORM 0x040 | ||
#define EPOLLRDBAND 0x080 | ||
#define EPOLLWRNORM 0x100 | ||
#define EPOLLWRBAND 0x200 | ||
#define EPOLLMSG 0x400 | ||
#define EPOLLERR 0x008 | ||
#define EPOLLHUP 0x010 | ||
#define EPOLLRDHUP 0x2000 | ||
#define EPOLLEXCLUSIVE (1U << 28) | ||
#define EPOLLWAKEUP (1U << 29) | ||
#define EPOLLONESHOT (1U << 30) | ||
#define EPOLLET (1U << 31) | ||
|
||
#define EPOLL_CTL_ADD 1 | ||
#define EPOLL_CTL_DEL 2 | ||
#define EPOLL_CTL_MOD 3 | ||
|
||
struct epoll_event { | ||
uint32_t events; | ||
uint64_t data; | ||
}; |