Skip to content

Commit

Permalink
Implement epoll_pwait
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Dec 26, 2018
1 parent 8bc7cb3 commit 5deb511
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions kernel/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ syscall_t syscall_table[] = {
[307] = (syscall_t) sys_faccessat,
[308] = (syscall_t) sys_pselect,
[309] = (syscall_t) sys_ppoll,
[319] = (syscall_t) sys_epoll_pwait,
[320] = (syscall_t) sys_utimensat,
[322] = (syscall_t) sys_timerfd_create,
[323] = (syscall_t) sys_eventfd,
Expand Down
1 change: 1 addition & 0 deletions kernel/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ fd_t sys_epoll_create(int_t flags);
fd_t sys_epoll_create0(void);
int_t sys_epoll_ctl(fd_t epoll, int_t op, fd_t fd, addr_t event_addr);
int_t sys_epoll_wait(fd_t epoll, addr_t events_addr, int_t max_events, int_t timeout);
int_t sys_epoll_pwait(fd_t epoll_f, addr_t events_addr, int_t max_events, int_t timeout, addr_t sigmask_addr, dword_t sigsetsize);

int_t sys_eventfd2(uint_t initval, int_t flags);
int_t sys_eventfd(uint_t initval);
Expand Down
16 changes: 16 additions & 0 deletions kernel/epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ int_t sys_epoll_wait(fd_t epoll_f, addr_t events_addr, int_t max_events, int_t t
int res = poll_wait(epoll->poll, epoll_callback, &context, timeout == -1 ? NULL : &timeout_ts);
if (user_write(events_addr, events, sizeof(struct epoll_event_) * res))
return _EFAULT;
}

int_t sys_epoll_pwait(fd_t epoll_f, addr_t events_addr, int_t max_events, int_t timeout, addr_t sigmask_addr, dword_t sigsetsize) {
sigset_t_ mask, old_mask;
if (sigmask_addr != 0) {
if (sigsetsize != sizeof(sigset_t_))
return _EINVAL;
if (user_get(sigmask_addr, mask))
return _EFAULT;
do_sigprocmask(SIG_SETMASK_, mask, &old_mask);
}

int_t res = sys_epoll_wait(epoll_f, events_addr, max_events, timeout);

if (sigmask_addr != 0)
do_sigprocmask(SIG_SETMASK_, old_mask, NULL);
return res;
}

Expand Down

0 comments on commit 5deb511

Please sign in to comment.