From dfe1e526f5bb9db3c0b28d848170f35521ebd314 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Wed, 22 Jan 2014 11:17:35 +0100 Subject: [PATCH] Check does arch have the epoll_create and __NR_epoll_wait syscalls. Some architectures (like AArch64) do not have deprecated syscalls. Signed-off-by: Marcin Juszkiewicz --- epoll_sub.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/epoll_sub.c b/epoll_sub.c index 3738b26b..facbc09f 100644 --- a/epoll_sub.c +++ b/epoll_sub.c @@ -31,11 +31,20 @@ #include #include #include +#include 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 @@ -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 }