diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index 8aebbdca9c..c82977cae1 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -203,18 +203,11 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev) } /**************************************************************************** - * Name: epoll_wait - * - * Description: - * - * Input Parameters: - * - * Returned Value: - * + * Name: epoll_pwait ****************************************************************************/ -int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, - int timeout) +int epoll_pwait(int epfd, FAR struct epoll_event *evs, + int maxevents, int timeout, FAR const sigset_t *sigmask) { /* REVISIT: This will not work on machines where: * sizeof(struct epoll_head *) > sizeof(int) @@ -225,7 +218,21 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int rc; int i; - rc = poll((FAR struct pollfd *)eph->evs, eph->occupied, timeout); + if (timeout < 0) + { + rc = ppoll((FAR struct pollfd *)eph->evs, + eph->occupied, NULL, sigmask); + } + else + { + struct timespec timeout_ts; + + timeout_ts.tv_sec = timeout / 1000; + timeout_ts.tv_nsec = timeout % 1000 * 1000; + + rc = ppoll((FAR struct pollfd *)eph->evs, + eph->occupied, &timeout_ts, sigmask); + } if (rc <= 0) { @@ -262,3 +269,20 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, return i; } + +/**************************************************************************** + * Name: epoll_wait + * + * Description: + * + * Input Parameters: + * + * Returned Value: + * + ****************************************************************************/ + +int epoll_wait(int epfd, FAR struct epoll_event *evs, + int maxevents, int timeout) +{ + return epoll_pwait(epfd, evs, maxevents, timeout, NULL); +} diff --git a/include/sys/epoll.h b/include/sys/epoll.h index bf0200f2a4..29a93abf61 100644 --- a/include/sys/epoll.h +++ b/include/sys/epoll.h @@ -80,13 +80,13 @@ enum EPOLL_EVENTS enum { - EPOLL_CLOEXEC = 02000000 + EPOLL_CLOEXEC = 02000000 #define EPOLL_CLOEXEC EPOLL_CLOEXEC }; typedef union poll_data { - void *ptr; + FAR void *ptr; int fd; uint32_t u32; } epoll_data_t; @@ -99,7 +99,7 @@ struct epoll_event /* Non-standard fields used internally by NuttX. */ pollevent_t revents; /* The output event flags */ - void *reserved; /* reserved field sync with struct pollfd */ + FAR void *reserved; /* reserved field sync with struct pollfd */ FAR sem_t *sem; /* Pointer to semaphore used to post output event */ FAR void *priv; /* For use by drivers */ }; @@ -117,9 +117,11 @@ struct epoll_head int epoll_create(int size); int epoll_create1(int flags); -int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev); -int epoll_wait(int epfd, struct epoll_event *evs, +int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev); +int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout); +int epoll_pwait(int epfd, FAR struct epoll_event *evs, + int maxevents, int timeout, FAR const sigset_t *sigmask); void epoll_close(int epfd);