| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#ifndef WEPOLL_H_ |
| 33 |
#define WEPOLL_H_ |
| 34 |
|
| 35 |
#ifndef WEPOLL_EXPORT |
| 36 |
#define WEPOLL_EXPORT |
| 37 |
#endif |
| 38 |
|
| 39 |
#include <stdint.h> |
| 40 |
|
| 41 |
enum EPOLL_EVENTS { |
| 42 |
EPOLLIN = (int) (1U << 0), |
| 43 |
EPOLLPRI = (int) (1U << 1), |
| 44 |
EPOLLOUT = (int) (1U << 2), |
| 45 |
EPOLLERR = (int) (1U << 3), |
| 46 |
EPOLLHUP = (int) (1U << 4), |
| 47 |
EPOLLRDNORM = (int) (1U << 6), |
| 48 |
EPOLLRDBAND = (int) (1U << 7), |
| 49 |
EPOLLWRNORM = (int) (1U << 8), |
| 50 |
EPOLLWRBAND = (int) (1U << 9), |
| 51 |
EPOLLMSG = (int) (1U << 10), |
| 52 |
EPOLLRDHUP = (int) (1U << 13), |
| 53 |
EPOLLONESHOT = (int) (1U << 31) |
| 54 |
}; |
| 55 |
|
| 56 |
#define EPOLLIN (1U << 0) |
| 57 |
#define EPOLLPRI (1U << 1) |
| 58 |
#define EPOLLOUT (1U << 2) |
| 59 |
#define EPOLLERR (1U << 3) |
| 60 |
#define EPOLLHUP (1U << 4) |
| 61 |
#define EPOLLRDNORM (1U << 6) |
| 62 |
#define EPOLLRDBAND (1U << 7) |
| 63 |
#define EPOLLWRNORM (1U << 8) |
| 64 |
#define EPOLLWRBAND (1U << 9) |
| 65 |
#define EPOLLMSG (1U << 10) |
| 66 |
#define EPOLLRDHUP (1U << 13) |
| 67 |
#define EPOLLONESHOT (1U << 31) |
| 68 |
|
| 69 |
#define EPOLL_CTL_ADD 1 |
| 70 |
#define EPOLL_CTL_MOD 2 |
| 71 |
#define EPOLL_CTL_DEL 3 |
| 72 |
|
| 73 |
typedef void* HANDLE; |
| 74 |
typedef uintptr_t SOCKET; |
| 75 |
|
| 76 |
typedef union epoll_data { |
| 77 |
void* ptr; |
| 78 |
int fd; |
| 79 |
uint32_t u32; |
| 80 |
uint64_t u64; |
| 81 |
SOCKET sock; |
| 82 |
HANDLE hnd; |
| 83 |
} epoll_data_t; |
| 84 |
|
| 85 |
struct epoll_event { |
| 86 |
uint32_t events; |
| 87 |
epoll_data_t data; |
| 88 |
}; |
| 89 |
|
| 90 |
#ifdef __cplusplus |
| 91 |
extern "C" { |
| 92 |
#endif |
| 93 |
|
| 94 |
WEPOLL_EXPORT HANDLE epoll_create(int size); |
| 95 |
WEPOLL_EXPORT HANDLE epoll_create1(int flags); |
| 96 |
|
| 97 |
WEPOLL_EXPORT int epoll_close(HANDLE ephnd); |
| 98 |
|
| 99 |
WEPOLL_EXPORT int epoll_ctl(HANDLE ephnd, |
| 100 |
int op, |
| 101 |
SOCKET sock, |
| 102 |
struct epoll_event* event); |
| 103 |
|
| 104 |
WEPOLL_EXPORT int epoll_wait(HANDLE ephnd, |
| 105 |
struct epoll_event* events, |
| 106 |
int maxevents, |
| 107 |
int timeout); |
| 108 |
|
| 109 |
#ifdef __cplusplus |
| 110 |
} |
| 111 |
#endif |
| 112 |
|
| 113 |
#endif |