Skip to content

Commit

Permalink
Check does arch have the epoll_create and __NR_epoll_wait syscalls.
Browse files Browse the repository at this point in the history
Some architectures (like AArch64) do not have deprecated syscalls.

Signed-off-by: Marcin Juszkiewicz <[email protected]>
  • Loading branch information
hrw authored and nmathewson committed Jan 22, 2014
1 parent eaa79cd commit dfe1e52
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions epoll_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@
#include <sys/syscall.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <errno.h>

int
epoll_create(int size)
{
#if !defined(__NR_epoll_create) && defined(__NR_epoll_create1)
if (size <= 0) {
errno = EINVAL;
return -1;
}
return (syscall(__NR_epoll_create1, 0));
#else
return (syscall(__NR_epoll_create, size));
#endif
}

int
Expand All @@ -48,5 +57,9 @@ 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)
{
#if !defined(__NR_epoll_wait) && defined(__NR_epoll_pwait)
return (syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0));
#else
return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout));
#endif
}

0 comments on commit dfe1e52

Please sign in to comment.