| 1 | #ifndef	_SYS_EPOLL_H |
| 2 | #define	_SYS_EPOLL_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | #include <sys/types.h> |
| 10 | #include <sys/ioctl.h> |
| 11 | #include <fcntl.h> |
| 12 | |
| 13 | #define __NEED_sigset_t |
| 14 | |
| 15 | #include <bits/alltypes.h> |
| 16 | |
| 17 | #define EPOLL_CLOEXEC O_CLOEXEC |
| 18 | #define EPOLL_NONBLOCK O_NONBLOCK |
| 19 | |
| 20 | enum EPOLL_EVENTS { __EPOLL_DUMMY }; |
| 21 | #define EPOLLIN 0x001 |
| 22 | #define EPOLLPRI 0x002 |
| 23 | #define EPOLLOUT 0x004 |
| 24 | #define EPOLLRDNORM 0x040 |
| 25 | #define EPOLLNVAL 0x020 |
| 26 | #define EPOLLRDBAND 0x080 |
| 27 | #define EPOLLWRNORM 0x100 |
| 28 | #define EPOLLWRBAND 0x200 |
| 29 | #define EPOLLMSG 0x400 |
| 30 | #define EPOLLERR 0x008 |
| 31 | #define EPOLLHUP 0x010 |
| 32 | #define EPOLLRDHUP 0x2000 |
| 33 | #define EPOLLEXCLUSIVE (1U<<28) |
| 34 | #define EPOLLWAKEUP (1U<<29) |
| 35 | #define EPOLLONESHOT (1U<<30) |
| 36 | #define EPOLLET (1U<<31) |
| 37 | |
| 38 | #define EPOLL_CTL_ADD 1 |
| 39 | #define EPOLL_CTL_DEL 2 |
| 40 | #define EPOLL_CTL_MOD 3 |
| 41 | |
| 42 | typedef union epoll_data { |
| 43 | 	void *ptr; |
| 44 | 	int fd; |
| 45 | 	uint32_t u32; |
| 46 | 	uint64_t u64; |
| 47 | } epoll_data_t; |
| 48 | |
| 49 | struct epoll_event { |
| 50 | 	uint32_t events; |
| 51 | 	epoll_data_t data; |
| 52 | } |
| 53 | #ifdef __x86_64__ |
| 54 | __attribute__ ((__packed__)) |
| 55 | #endif |
| 56 | ; |
| 57 | |
| 58 | struct epoll_params { |
| 59 | 	uint32_t busy_poll_usecs; |
| 60 | 	uint16_t busy_poll_budget; |
| 61 | 	uint8_t prefer_busy_poll; |
| 62 | |
| 63 | 	uint8_t __pad; |
| 64 | }; |
| 65 | |
| 66 | #define EPOLL_IOC_TYPE 0x8A |
| 67 | #define EPIOCSPARAMS _IOW(EPOLL_IOC_TYPE, 0x01, struct epoll_params) |
| 68 | #define EPIOCGPARAMS _IOR(EPOLL_IOC_TYPE, 0x02, struct epoll_params) |
| 69 | |
| 70 | int epoll_create(int); |
| 71 | int epoll_create1(int); |
| 72 | int epoll_ctl(int, int, int, struct epoll_event *); |
| 73 | int epoll_wait(int, struct epoll_event *, int, int); |
| 74 | int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *); |
| 75 | |
| 76 | |
| 77 | #ifdef __cplusplus |
| 78 | } |
| 79 | #endif |
| 80 | |
| 81 | #endif /* sys/epoll.h */ |