Commit 66bc867f authored by Denis Bilenko's avatar Denis Bilenko

update libev to latest CVS

parent 9f916ac0
......@@ -872,14 +872,6 @@ ev_sleep (ev_tstamp delay)
}
}
inline_speed int
ev_timeout_to_ms (ev_tstamp timeout)
{
int ms = timeout * 1000. + .999999;
return expect_true (ms) ? ms : timeout < 1e-6 ? 0 : 1;
}
/*****************************************************************************/
#define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */
......@@ -2515,14 +2507,14 @@ ev_run (EV_P_ int flags)
if (timercnt)
{
ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_fudge;
ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now + backend_mintime;
if (waittime > to) waittime = to;
}
#if EV_PERIODIC_ENABLE
if (periodiccnt)
{
ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_fudge;
ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_mintime;
if (waittime > to) waittime = to;
}
#endif
......@@ -2536,8 +2528,8 @@ ev_run (EV_P_ int flags)
{
sleeptime = io_blocktime - (mn_now - prev_mn_now);
if (sleeptime > waittime - backend_fudge)
sleeptime = waittime - backend_fudge;
if (sleeptime > waittime - backend_mintime)
sleeptime = waittime - backend_mintime;
if (expect_true (sleeptime > 0.))
{
......
......@@ -144,11 +144,13 @@ epoll_poll (EV_P_ ev_tstamp timeout)
int i;
int eventcnt;
if (expect_false (epoll_epermcnt))
timeout = 0.;
/* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */
/* the default libev max wait time, however. */
EV_RELEASE_CB;
eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax,
epoll_epermcnt ? 0 : ev_timeout_to_ms (timeout));
eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, timeout * 1e3);
EV_ACQUIRE_CB;
if (expect_false (eventcnt < 0))
......@@ -234,9 +236,9 @@ epoll_init (EV_P_ int flags)
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
backend_fudge = 0.; /* kernel sources seem to indicate this to be zero */
backend_modify = epoll_modify;
backend_poll = epoll_poll;
backend_mintime = 1./1024.; /* epoll does sometimes return early, this is just to avoid the worst */
backend_modify = epoll_modify;
backend_poll = epoll_poll;
epoll_eventmax = 64; /* initial number of events receivable per poll */
epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
......
/*
* libev kqueue backend
*
* Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -161,9 +161,9 @@ kqueue_init (EV_P_ int flags)
fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
backend_fudge = 0.;
backend_modify = kqueue_modify;
backend_poll = kqueue_poll;
backend_mintime = 1e-9; /* apparently, they did the right thing in freebsd */
backend_modify = kqueue_modify;
backend_poll = kqueue_poll;
kqueue_eventmax = 64; /* initial number of events receivable per poll */
kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
......
......@@ -92,7 +92,7 @@ poll_poll (EV_P_ ev_tstamp timeout)
int res;
EV_RELEASE_CB;
res = poll (polls, pollcnt, ev_timeout_to_ms (timeout));
res = poll (polls, pollcnt, timeout * 1e3);
EV_ACQUIRE_CB;
if (expect_false (res < 0))
......@@ -129,9 +129,9 @@ poll_poll (EV_P_ ev_tstamp timeout)
int inline_size
poll_init (EV_P_ int flags)
{
backend_fudge = 0.; /* posix says this is zero */
backend_modify = poll_modify;
backend_poll = poll_poll;
backend_mintime = 1e-3;
backend_modify = poll_modify;
backend_poll = poll_poll;
pollidxs = 0; pollidxmax = 0;
polls = 0; pollmax = 0; pollcnt = 0;
......
......@@ -147,9 +147,15 @@ port_init (EV_P_ int flags)
fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */
backend_modify = port_modify;
backend_poll = port_poll;
/* if my reading of the opensolaris kernel sources are correct, then
* opensolaris does something very stupid: it checks if the time has already
* elapsed and doesn't round up if that is the case,m otherwise it DOES round
* up. Since we can't know what the case is, we need to guess by using a
* "large enough" timeout. Normally, 1e-9 would be correct.
*/
backend_mintime = 1e-3; /* needed to compensate for port_getn returning early */
backend_modify = port_modify;
backend_poll = port_poll;
port_eventmax = 64; /* initial number of events receivable per poll */
port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax);
......
/*
* libev select fd activity backend
*
* Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -196,7 +196,11 @@ select_poll (EV_P_ ev_tstamp timeout)
if (errno == EINVAL)
{
if (timeout)
ev_sleep (timeout >= 1e-3 ? timeout : 1e-3);
{
unsigned long ms = timeout * 1e3;
Sleep (ms ? ms : 1);
}
return;
}
#endif
......@@ -270,13 +274,9 @@ select_poll (EV_P_ ev_tstamp timeout)
int inline_size
select_init (EV_P_ int flags)
{
#ifdef _WIN32
backend_fudge = 1e-6;
#else
backend_fudge = 0.; /* posix says this is zero */
#endif
backend_modify = select_modify;
backend_poll = select_poll;
backend_mintime = 1e-6;
backend_modify = select_modify;
backend_poll = select_poll;
#if EV_SELECT_USE_FD_SET
vec_ri = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_ri);
......@@ -312,4 +312,3 @@ select_destroy (EV_P)
#endif
}
......@@ -51,7 +51,7 @@ VARx(int, activecnt) /* total number of active events ("refcount") */
VARx(EV_ATOMIC_T, loop_done) /* signal by ev_break */
VARx(int, backend_fd)
VARx(ev_tstamp, backend_fudge) /* assumed typical timer resolution */
VARx(ev_tstamp, backend_mintime) /* assumed typical timer resolution */
VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev))
VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout))
......
......@@ -10,7 +10,7 @@
#define activecnt ((loop)->activecnt)
#define loop_done ((loop)->loop_done)
#define backend_fd ((loop)->backend_fd)
#define backend_fudge ((loop)->backend_fudge)
#define backend_mintime ((loop)->backend_mintime)
#define backend_modify ((loop)->backend_modify)
#define backend_poll ((loop)->backend_poll)
#define anfds ((loop)->anfds)
......@@ -107,7 +107,7 @@
#undef activecnt
#undef loop_done
#undef backend_fd
#undef backend_fudge
#undef backend_mintime
#undef backend_modify
#undef backend_poll
#undef anfds
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment