Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
WuJin committed Jul 19, 2024
1 parent c17212a commit d3c5549
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/platform/unix/platform-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

void platform_event_add(cdk_pollfd_t pfd, cdk_sock_t sfd, int events, void* ud) {
struct epoll_event ee;
if (events & EVENT_TYPE_R) {
if (events & EVENT_RD) {
ee.events |= EPOLLIN;
}
if (events & EVENT_TYPE_W) {
if (events & EVENT_WR) {
ee.events |= EPOLLOUT;
}
ee.data.ptr = ud;
Expand All @@ -37,10 +37,10 @@ void platform_event_add(cdk_pollfd_t pfd, cdk_sock_t sfd, int events, void* ud)

void platform_event_mod(cdk_pollfd_t pfd, cdk_sock_t sfd, int events, void* ud) {
struct epoll_event ee;
if (events & EVENT_TYPE_R) {
if (events & EVENT_RD) {
ee.events |= EPOLLIN;
}
if (events & EVENT_TYPE_W) {
if (events & EVENT_WR) {
ee.events |= EPOLLOUT;
}
ee.data.ptr = ud;
Expand All @@ -65,10 +65,10 @@ int platform_event_wait(cdk_pollfd_t pfd, cdk_pollevent_t* events, int timeout)
for (int i = 0; i < n; i++) {
events[i].ptr = __events[i].data.ptr;
if (__events[i].events & (EPOLLIN | EPOLLHUP | EPOLLERR)) {
events[i].events |= EVENT_TYPE_R;
events[i].events |= EVENT_RD;
}
if (__events[i].events & (EPOLLOUT | EPOLLHUP | EPOLLERR)) {
events[i].events |= EVENT_TYPE_W;
events[i].events |= EVENT_WR;
}
}
return n;
Expand All @@ -78,23 +78,23 @@ int platform_event_wait(cdk_pollfd_t pfd, cdk_pollevent_t* events, int timeout)
#if defined(__APPLE__)
void platform_event_add(cdk_pollfd_t pfd, cdk_sock_t sfd, int events, void* ud) {
struct kevent ke;
if (events & EVENT_TYPE_R) {
if (events & EVENT_RD) {
EV_SET(&ke, sfd, EVFILT_READ, EV_ADD, 0, 0, ud);
kevent(pfd, &ke, 1, NULL, 0, NULL);
}
if (events & EVENT_TYPE_W) {
if (events & EVENT_WR) {
EV_SET(&ke, sfd, EVFILT_WRITE, EV_ADD, 0, 0, ud);
kevent(pfd, &ke, 1, NULL, 0, NULL);
}
}

void platform_event_mod(cdk_pollfd_t pfd, cdk_sock_t sfd, int events, void* ud) {
struct kevent ke;
if (events & EVENT_TYPE_R) {
if (events & EVENT_RD) {
EV_SET(&ke, sfd, EVFILT_READ, EV_ADD, 0, 0, ud);
kevent(pfd, &ke, 1, NULL, 0, NULL);
}
if (events & EVENT_TYPE_W) {
if (events & EVENT_WR) {
EV_SET(&ke, sfd, EVFILT_WRITE, EV_ADD, 0, 0, ud);
kevent(pfd, &ke, 1, NULL, 0, NULL);
}
Expand Down Expand Up @@ -132,10 +132,10 @@ int platform_event_wait(cdk_pollfd_t pfd, cdk_pollevent_t* events, int timeout)
for (int i = 0; i < n; i++) {
events[i].ptr = __events[i].udata;
if (__events[i].filter == EVFILT_READ) {
events[i].events |= EVENT_TYPE_R;
events[i].events |= EVENT_RD;
}
if (__events[i].filter == EVFILT_WRITE) {
events[i].events |= EVENT_TYPE_W;
events[i].events |= EVENT_WR;
}
}
return n;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/unix/platform-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void platform_loader_destroy(void* module) {
}

void* platform_loader_load(void* module, const char* restrict func) {
void* ret = dlsym(module, f);
void* ret = dlsym(module, func);
if (ret == NULL) {
platform_loader_destroy(module);
}
Expand Down

0 comments on commit d3c5549

Please sign in to comment.