--- libev/ev.c 2007/11/03 22:10:39 1.52 +++ libev/ev.c 2007/11/03 22:31:11 1.53 @@ -115,44 +115,32 @@ typedef struct ev_watcher_list *WL; typedef struct ev_watcher_time *WT; -static ev_tstamp now_floor, mn_now, diff; /* monotonic clock */ -static ev_tstamp rt_now; -static int method; - -static int have_monotonic; /* runtime */ - -static ev_tstamp method_fudge; /* stupid epoll-returns-early bug */ -static void (*method_modify)(EV_P_ int fd, int oev, int nev); -static void (*method_poll)(EV_P_ ev_tstamp timeout); - -static int activecnt; /* number of active events */ - -#if EV_USE_SELECT -static unsigned char *vec_ri, *vec_ro, *vec_wi, *vec_wo; -static int vec_max; -#endif - -#if EV_USEV_POLL -static struct pollfd *polls; -static int pollmax, pollcnt; -static int *pollidxs; /* maps fds into structure indices */ -static int pollidxmax; -#endif +/*****************************************************************************/ -#if EV_USE_EPOLL -static int epoll_fd = -1; +typedef struct +{ + struct ev_watcher_list *head; + unsigned char events; + unsigned char reify; +} ANFD; -static struct epoll_event *events; -static int eventmax; -#endif +typedef struct +{ + W w; + int events; +} ANPENDING; -#if EV_USE_KQUEUE -static int kqueue_fd; -static struct kevent *kqueue_changes; -static int kqueue_changemax, kqueue_changecnt; -static struct kevent *kqueue_events; -static int kqueue_eventmax; +#ifdef EV_MULTIPLICITY +struct ev_loop +{ +# define VAR(name,decl) decl +# include "ev_vars.h" +}; +#else +# define VAR(name,decl) static decl +# include "ev_vars.h" #endif +#undef VAR /*****************************************************************************/ @@ -210,16 +198,6 @@ /*****************************************************************************/ -typedef struct -{ - struct ev_watcher_list *head; - unsigned char events; - unsigned char reify; -} ANFD; - -static ANFD *anfds; -static int anfdmax; - static void anfds_init (ANFD *base, int count) { @@ -233,15 +211,6 @@ } } -typedef struct -{ - W w; - int events; -} ANPENDING; - -static ANPENDING *pendings [NUMPRI]; -static int pendingmax [NUMPRI], pendingcnt [NUMPRI]; - static void event (EV_P_ W w, int events) { @@ -283,9 +252,6 @@ /*****************************************************************************/ -static int *fdchanges; -static int fdchangemax, fdchangecnt; - static void fd_reify (EV_P) { @@ -368,12 +334,6 @@ /*****************************************************************************/ -static struct ev_timer **timers; -static int timermax, timercnt; - -static struct ev_periodic **periodics; -static int periodicmax, periodiccnt; - static void upheap (WT *timers, int k) { @@ -428,7 +388,6 @@ static int sigpipe [2]; static sig_atomic_t volatile gotsig; -static struct ev_io sigev; static void signals_init (ANSIG *base, int count) @@ -494,20 +453,6 @@ /*****************************************************************************/ -static struct ev_idle **idles; -static int idlemax, idlecnt; - -static struct ev_prepare **prepares; -static int preparemax, preparecnt; - -static struct ev_check **checks; -static int checkmax, checkcnt; - -/*****************************************************************************/ - -static struct ev_child *childs [PID_HASHSIZE]; -static struct ev_signal childev; - #ifndef WIN32 #ifndef WCONTINUED @@ -594,6 +539,10 @@ int ev_init (EV_P_ int methods) { +#ifdef EV_MULTIPLICITY + memset (loop, 0, sizeof (struct ev_loop)); +#endif + if (!method) { #if EV_USE_MONOTONIC