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