1 #ifndef _FF_EPOLL_H 2 #define _FF_EPOLL_H 3 4 //#include <sys/stdint.h> 5 //#include <sys/queue.h> 6 7 #ifndef _KERNEL 8 #include <stdint.h> 9 #else 10 #include <sys/stdint.h> 11 #include <sys/types.h> 12 #endif 13 14 enum EPOLL_EVENTS 15 { 16 EPOLLIN = 0x001, 17 #define EPOLLIN EPOLLIN 18 EPOLLPRI = 0x002, 19 #define EPOLLPRI EPOLLPRI 20 EPOLLOUT = 0x004, 21 #define EPOLLOUT EPOLLOUT 22 EPOLLRDNORM = 0x040, 23 #define EPOLLRDNORM EPOLLRDNORM 24 EPOLLRDBAND = 0x080, 25 #define EPOLLRDBAND EPOLLRDBAND 26 EPOLLWRNORM = 0x100, 27 #define EPOLLWRNORM EPOLLWRNORM 28 EPOLLWRBAND = 0x200, 29 #define EPOLLWRBAND EPOLLWRBAND 30 EPOLLMSG = 0x400, 31 #define EPOLLMSG EPOLLMSG 32 EPOLLERR = 0x008, 33 #define EPOLLERR EPOLLERR 34 EPOLLHUP = 0x010, 35 #define EPOLLHUP EPOLLHUP 36 EPOLLRDHUP = 0x2000, 37 #define EPOLLRDHUP EPOLLRDHUP 38 EPOLLWAKEUP = 1u << 29, 39 #define EPOLLWAKEUP EPOLLWAKEUP 40 EPOLLONESHOT = 1u << 30, 41 #define EPOLLONESHOT EPOLLONESHOT 42 EPOLLET = 1u << 31 43 #define EPOLLET EPOLLET 44 }; 45 46 47 /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ 48 #define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ 49 #define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ 50 #define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ 51 52 53 typedef union epoll_data 54 { 55 void *ptr; 56 int fd; 57 uint32_t u32; 58 uint64_t u64; 59 } epoll_data_t; 60 61 struct epoll_event 62 { 63 uint32_t events; /* Epoll events */ 64 epoll_data_t data; /* User data variable */ 65 }; 66 67 /*warpper epoll api.*/ 68 int ff_epoll_create(int size); 69 int ff_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); 70 int ff_epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); 71 int ff_epoll_close(int epfd); 72 73 #endif 74