39#define EPOLL_DEFAULT_SIZE 100
48STATIC pthread_mutex_t
g_epollMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
51#define MAX_EPOLL_FD CONFIG_EPOLL_DESCRIPTORS
73 for (i = 0; i < maxfdp; i++) {
74 if (fdset && !(FD_ISSET(i, fdset))) {
78 return i + EPOLL_FD_OFFSET;
95 int efd = fd - EPOLL_FD_OFFSET;
97 if ((efd < 0) || (efd >= MAX_EPOLL_FD)) {
103 if (fdset && FD_ISSET(efd, fdset)) {
119 int id = fd - EPOLL_FD_OFFSET;
121 if ((
id < 0) || (
id >= MAX_EPOLL_FD)) {
138 for (i = 0; i < epHead->
nodeCount; i++) {
155 if (epHead != NULL) {
156 if (epHead->
evs != NULL) {
185 if (epHead == NULL) {
191 epHead->
size = EPOLL_DEFAULT_SIZE;
194 if (epHead->
evs == NULL) {
224 if (epHead == NULL) {
240 if (epHead == NULL) {
258 if (epHead->
nodeCount == EPOLL_DEFAULT_SIZE) {
268 for (i = 0; i < epHead->
nodeCount; i++) {
283 for (i = 0; i < epHead->
nodeCount; i++) {
303 struct pollfd *pFd = NULL;
312 if ((maxevents <= 0) || (evs == NULL)) {
320 pollSize = maxevents;
323 pFd =
malloc(
sizeof(
struct pollfd) * pollSize);
329 for (i = 0; i < epHead->
nodeCount; i++) {
331 pFd[i].events = (short)epHead->
evs[i].
events;
335 ret = poll(pFd, pollSize, timeout);
341 for (i = 0, counter = 0; i < ret && counter < pollSize; counter++) {
342 if (pFd[counter].revents != 0) {
343 evs[i].data.fd = pFd[counter].fd;
344 evs[i].events = pFd[counter].revents;
static int EpollAllocSysFd(int maxfdp, struct epoll_head *head)
int epoll_close(int epfd)
int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout)
static int EpollFreeSysFd(int fd)
STATIC fd_set g_epollFdSet
static struct epoll_head * EpollGetDataBuff(int fd)
STATIC struct epoll_head * g_epPrivBuf[MAX_EPOLL_FD]
static int CheckFdExist(struct epoll_head *epHead, int fd)
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
static VOID DoEpollClose(struct epoll_head *epHead)
int epoll_create1(int flags)
STATIC pthread_mutex_t g_epollMutex
void * malloc(size_t size)
动态分配内存块大小
void free(void *ptr)
释放ptr所指向的内存空间
int pthread_mutex_lock(pthread_mutex_t *mutex)
互斥锁加锁操作
int pthread_mutex_unlock(pthread_mutex_t *mutex)
解锁互斥锁
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void