xref: /aosp_15_r20/external/ltp/include/tst_epoll.h (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2022 SUSE LLC <[email protected]>
4  */
5 
6 #include <sys/epoll.h>
7 
8 #ifndef TST_EPOLL_H
9 #define TST_EPOLL_H
10 
11 typedef int (*tst_on_epoll_fn)(void *, uint32_t);
12 struct tst_epoll_event_data {
13 	tst_on_epoll_fn on_epoll;
14 	void *self;
15 };
16 
17 int safe_epoll_create1(const char *const file, const int lineno,
18 		       const int flags);
19 
20 #define SAFE_EPOLL_CREATE1(flags) \
21 	safe_epoll_create1(__FILE__, __LINE__, (flags))
22 
23 int safe_epoll_ctl(const char *const file, const int lineno,
24 		   int epfd, int op, int fd, struct epoll_event *ev);
25 
26 #define SAFE_EPOLL_CTL(epfd, op, fd, ev) \
27 	safe_epoll_ctl(__FILE__, __LINE__, epfd, op, fd, ev)
28 
29 int safe_epoll_wait(const char *const file, const int lineno,
30 		    int epfd, struct epoll_event *events,
31 		    int maxevents, int timeout);
32 
33 #define SAFE_EPOLL_WAIT(epfd, events, maxevents, timeout)\
34 	safe_epoll_wait(__FILE__, __LINE__, epfd, events, maxevents, timeout)
35 
36 #endif
37