1 /* SPDX-License-Identifier: GPL-2.0-or-later
2 *
3 * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
4 * Author: Xie Ziyao <xieziyao@huawei.com>
5 */
6
7 #ifndef LTP_EPOLL_PWAIT_VAR_H
8 #define LTP_EPOLL_PWAIT_VAR_H
9
10 #include "lapi/epoll.h"
11
12 #define TEST_VARIANTS 2
13 #define MSEC_PER_SEC (1000L)
14 #define NSEC_PER_MSEC (1000000L)
15
do_epoll_pwait(int epfd,struct epoll_event * events,int maxevents,int timeout,const sigset_t * sigmask)16 static int do_epoll_pwait(int epfd, struct epoll_event *events, int
17 maxevents, int timeout, const sigset_t *sigmask)
18 {
19 if (tst_variant == 0)
20 return epoll_pwait(epfd, events, maxevents, timeout, sigmask);
21
22 struct timespec ts;
23
24 if (timeout < 0) {
25 return epoll_pwait2(epfd, events, maxevents, NULL, sigmask);
26 } else {
27 ts.tv_sec = timeout / MSEC_PER_SEC;
28 ts.tv_nsec = NSEC_PER_MSEC * (timeout % MSEC_PER_SEC);
29 }
30
31 return epoll_pwait2(epfd, events, maxevents, &ts, sigmask);
32
33 }
34
epoll_pwait_info(void)35 static void epoll_pwait_info(void)
36 {
37 if (tst_variant == 0)
38 tst_res(TINFO, "Test epoll_pwait()");
39 else
40 tst_res(TINFO, "Test epoll_pwait2()");
41 }
42
43 #endif /* LTP_EPOLL_PWAIT_VAR_H */
44