1/* SPDX-License-Identifier: GPL-2.0-or-later 2 * 3 * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz> 4 * Copyright (c) 2021 Xie Ziyao <xieziyao@huawei.com> 5 */ 6 7#ifndef LAPI_EPOLL_H__ 8#define LAPI_EPOLL_H__ 9 10#include "lapi/syscalls.h" 11#include "tst_timer.h" 12 13#ifndef EPOLL_CLOEXEC 14#define EPOLL_CLOEXEC 02000000 15#endif 16 17static inline void epoll_pwait_supported(void) 18{ 19 /* allow the tests to fail early */ 20 tst_syscall(__NR_epoll_pwait); 21} 22 23#ifndef HAVE_EPOLL_PWAIT 24static inline int epoll_pwait(int epfd, struct epoll_event *events, 25 int maxevents, int timeout, 26 const sigset_t *sigmask) 27{ 28 return tst_syscall(__NR_epoll_pwait, epfd, events, maxevents, 29 timeout, sigmask, _NSIG / 8); 30} 31#endif 32 33static inline void epoll_pwait2_supported(void) 34{ 35 /* allow the tests to fail early */ 36 tst_syscall(__NR_epoll_pwait2); 37} 38 39#ifndef HAVE_EPOLL_PWAIT2 40static inline int epoll_pwait2(int epfd, struct epoll_event *events, 41 int maxevents, const struct timespec *timeout, 42 const sigset_t *sigmask) 43{ 44 if (timeout == NULL) 45 return tst_syscall(__NR_epoll_pwait2, epfd, events, maxevents, 46 NULL, sigmask, _NSIG / 8); 47 48 struct __kernel_timespec ts; 49 50 ts.tv_sec = timeout->tv_sec; 51 ts.tv_nsec = timeout->tv_nsec; 52 53 return tst_syscall(__NR_epoll_pwait2, epfd, events, maxevents, 54 &ts, sigmask, _NSIG / 8); 55} 56#endif 57 58#endif /* LAPI_EPOLL_H__ */ 59