#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <sys/_libevent_time.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <sys/queue.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#ifdef CHECK_INVARIANTS
#include <assert.h>
#endif
#include "event.h"
#include "evutil.h"
#include "event-internal.h"
#include "evsignal.h"
#include "log.h"
#ifndef howmany
#define howmany(x, y) …
#endif
#ifndef _EVENT_HAVE_FD_MASK
#undef NFDBITS
#define NFDBITS …
typedef unsigned long fd_mask;
#endif
struct selectop { … };
static void *select_init (struct event_base *);
static int select_add (void *, struct event *);
static int select_del (void *, struct event *);
static int select_dispatch (struct event_base *, void *, struct timeval *);
static void select_dealloc (struct event_base *, void *);
const struct eventop selectops = …;
static int select_resize(struct selectop *sop, int fdsz);
static void *
select_init(struct event_base *base)
{ … }
#ifdef CHECK_INVARIANTS
static void
check_selectop(struct selectop *sop)
{
int i;
for (i = 0; i <= sop->event_fds; ++i) {
if (FD_ISSET(i, sop->event_readset_in)) {
assert(sop->event_r_by_fd[i]);
assert(sop->event_r_by_fd[i]->ev_events & EV_READ);
assert(sop->event_r_by_fd[i]->ev_fd == i);
} else {
assert(! sop->event_r_by_fd[i]);
}
if (FD_ISSET(i, sop->event_writeset_in)) {
assert(sop->event_w_by_fd[i]);
assert(sop->event_w_by_fd[i]->ev_events & EV_WRITE);
assert(sop->event_w_by_fd[i]->ev_fd == i);
} else {
assert(! sop->event_w_by_fd[i]);
}
}
}
#else
#define check_selectop(sop) …
#endif
static int
select_dispatch(struct event_base *base, void *arg, struct timeval *tv)
{ … }
static int
select_resize(struct selectop *sop, int fdsz)
{ … }
static int
select_add(void *arg, struct event *ev)
{ … }
static int
select_del(void *arg, struct event *ev)
{ … }
static void
select_dealloc(struct event_base *base, void *arg)
{ … }