From 4b05fe94e44407cd62092863e204337c521e7d8a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 6 Nov 2007 16:51:20 +0000 Subject: *** empty log message *** --- README | 5 +++++ ev.c | 32 ++++++++++++++++---------------- ev_epoll.c | 6 +++--- event.c | 4 ++-- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/README b/README index e1963fd..6dc26f9 100644 --- a/README +++ b/README @@ -64,6 +64,11 @@ at http://libev.schmorp.de/bench.html). - a event.h compatibility header exists, and can be used to run a wide range of libevent programs unchanged (such as evdns.c). +- win32 compatibility for the core parts. + +- the event core library (ev and event layer) compiles and works both as + C and C++. + whats missing? - evbuffer, evhttp, bufferevent are missing. diff --git a/ev.c b/ev.c index 630a6db..e3e7e57 100644 --- a/ev.c +++ b/ev.c @@ -270,28 +270,28 @@ ev_now (EV_P) return rt_now; } -#define array_roundsize(base,n) ((n) | 4 & ~3) +#define array_roundsize(type,n) ((n) | 4 & ~3) -#define array_needsize(base,cur,cnt,init) \ +#define array_needsize(type,base,cur,cnt,init) \ if (expect_false ((cnt) > cur)) \ { \ int newcnt = cur; \ do \ { \ - newcnt = array_roundsize (base, newcnt << 1); \ + newcnt = array_roundsize (type, newcnt << 1); \ } \ while ((cnt) > newcnt); \ \ - base = ev_realloc (base, sizeof (*base) * (newcnt)); \ + base = (type *)ev_realloc (base, sizeof (type) * (newcnt));\ init (base + cur, newcnt - cur); \ cur = newcnt; \ } -#define array_slim(stem) \ +#define array_slim(type,stem) \ if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ { \ stem ## max = array_roundsize (stem ## cnt >> 1); \ - base = ev_realloc (base, sizeof (*base) * (stem ## max)); \ + base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\ fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ } @@ -328,7 +328,7 @@ event (EV_P_ W w, int events) } w->pending = ++pendingcnt [ABSPRI (w)]; - array_needsize (pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void)); + array_needsize (ANPENDING, pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void)); pendings [ABSPRI (w)][w->pending - 1].w = w; pendings [ABSPRI (w)][w->pending - 1].events = events; } @@ -393,7 +393,7 @@ fd_change (EV_P_ int fd) anfds [fd].reify = 1; ++fdchangecnt; - array_needsize (fdchanges, fdchangemax, fdchangecnt, (void)); + array_needsize (int, fdchanges, fdchangemax, fdchangecnt, (void)); fdchanges [fdchangecnt - 1] = fd; } @@ -1211,7 +1211,7 @@ ev_io_start (EV_P_ struct ev_io *w) assert (("ev_io_start called with negative fd", fd >= 0)); ev_start (EV_A_ (W)w, 1); - array_needsize (anfds, anfdmax, fd + 1, anfds_init); + array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); wlist_add ((WL *)&anfds[fd].head, (WL)w); fd_change (EV_A_ fd); @@ -1241,7 +1241,7 @@ ev_timer_start (EV_P_ struct ev_timer *w) assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); ev_start (EV_A_ (W)w, ++timercnt); - array_needsize (timers, timermax, timercnt, (void)); + array_needsize (struct ev_timer *, timers, timermax, timercnt, (void)); timers [timercnt - 1] = w; upheap ((WT *)timers, timercnt - 1); @@ -1298,7 +1298,7 @@ ev_periodic_start (EV_P_ struct ev_periodic *w) ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; ev_start (EV_A_ (W)w, ++periodiccnt); - array_needsize (periodics, periodicmax, periodiccnt, (void)); + array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, (void)); periodics [periodiccnt - 1] = w; upheap ((WT *)periodics, periodiccnt - 1); @@ -1330,7 +1330,7 @@ ev_idle_start (EV_P_ struct ev_idle *w) return; ev_start (EV_A_ (W)w, ++idlecnt); - array_needsize (idles, idlemax, idlecnt, (void)); + array_needsize (struct ev_idle *, idles, idlemax, idlecnt, (void)); idles [idlecnt - 1] = w; } @@ -1352,7 +1352,7 @@ ev_prepare_start (EV_P_ struct ev_prepare *w) return; ev_start (EV_A_ (W)w, ++preparecnt); - array_needsize (prepares, preparemax, preparecnt, (void)); + array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, (void)); prepares [preparecnt - 1] = w; } @@ -1374,7 +1374,7 @@ ev_check_start (EV_P_ struct ev_check *w) return; ev_start (EV_A_ (W)w, ++checkcnt); - array_needsize (checks, checkmax, checkcnt, (void)); + array_needsize (struct ev_check *, checks, checkmax, checkcnt, (void)); checks [checkcnt - 1] = w; } @@ -1405,7 +1405,7 @@ ev_signal_start (EV_P_ struct ev_signal *w) assert (("ev_signal_start called with illegal signal number", w->signum > 0)); ev_start (EV_A_ (W)w, 1); - array_needsize (signals, signalmax, w->signum, signals_init); + array_needsize (ANSIG, signals, signalmax, w->signum, signals_init); wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); if (!((WL)w)->next) @@ -1498,7 +1498,7 @@ once_cb_to (EV_P_ struct ev_timer *w, int revents) void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) { - struct ev_once *once = ev_malloc (sizeof (struct ev_once)); + struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); if (!once) cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); diff --git a/ev_epoll.c b/ev_epoll.c index 9f5bd25..957b71b 100644 --- a/ev_epoll.c +++ b/ev_epoll.c @@ -52,7 +52,7 @@ static void epoll_poll (EV_P_ ev_tstamp timeout) { int i; - int eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, ceil (timeout * 1000.)); + int eventcnt = epoll_wait (epoll_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.)); if (eventcnt < 0) { @@ -75,7 +75,7 @@ epoll_poll (EV_P_ ev_tstamp timeout) { ev_free (epoll_events); epoll_eventmax = array_roundsize (epoll_events, epoll_eventmax << 1); - epoll_events = ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); + epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); } } @@ -94,7 +94,7 @@ epoll_init (EV_P_ int flags) method_poll = epoll_poll; epoll_eventmax = 64; /* intiial number of events receivable per poll */ - epoll_events = ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); + epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax); return EVMETHOD_EPOLL; } diff --git a/event.c b/event.c index 0fc6850..783eef1 100644 --- a/event.c +++ b/event.c @@ -332,7 +332,7 @@ struct x_once static void x_once_cb (int revents, void *arg) { - struct x_once *once = arg; + struct x_once *once = (struct x_once *)arg; once->cb (once->fd, revents, once->arg); free (once); @@ -340,7 +340,7 @@ x_once_cb (int revents, void *arg) int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) { - struct x_once *once = malloc (sizeof (struct x_once)); + struct x_once *once = (struct x_once *)malloc (sizeof (struct x_once)); dLOOPbase; if (!once) -- cgit v1.2.3