*** empty log message ***

This commit is contained in:
Marc Alexander Lehmann 2019-08-17 05:30:16 +00:00
parent 2114cc0f41
commit 05948cda35
9 changed files with 34 additions and 29 deletions

View File

@ -20,6 +20,8 @@ TODO: document EV_TSTAMP_T
- tweak ev_floor.
- epoll, poll, win32 Sleep and other places that use millisecond
reslution now all try to round up times.
- solaris port backend didn't compile.
- abstract time constants into their macros, for more flexibility.
4.27 Thu Jun 27 22:43:44 CEST 2019
- linux aio backend almost completely rewritten to work around its

37
ev.c
View File

@ -546,12 +546,15 @@ struct signalfd_siginfo
: 0 < (time_t)4294967295 ? 4294967295. \
: 2147483647.) \
#define EV_TS_TO_MSEC(a) a * 1e3 + 0.9999
#define EV_TS_FROM_USEC(us) us * 1e-6
#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
#define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9); } while (0)
#define EV_TV_GET(tv) ((tv).tv_sec + (tv).tv_usec * 1e-6)
#define EV_TS_GET(ts) ((ts).tv_sec + (ts).tv_nsec * 1e-9)
#ifndef EV_TS_CONST
# define EV_TS_CONST(nv) nv
# define EV_TS_TO_MSEC(a) a * 1e3 + 0.9999
# define EV_TS_FROM_USEC(us) us * 1e-6
# define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
# define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9); } while (0)
# define EV_TV_GET(tv) ((tv).tv_sec + (tv).tv_usec * 1e-6)
# define EV_TS_GET(ts) ((ts).tv_sec + (ts).tv_nsec * 1e-9)
#endif
/* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */
/* ECB.H BEGIN */
@ -1967,7 +1970,7 @@ typedef struct
#else
EV_API_DECL ev_tstamp ev_rt_now = 0; /* needs to be initialised to make it a definition despite extern */
EV_API_DECL ev_tstamp ev_rt_now = EV_TS_CONST (0.); /* needs to be initialised to make it a definition despite extern */
#define VAR(name,decl) static decl;
#include "ev_vars.h"
#undef VAR
@ -2035,7 +2038,7 @@ ev_now (EV_P) EV_NOEXCEPT
void
ev_sleep (ev_tstamp delay) EV_NOEXCEPT
{
if (delay > 0.)
if (delay > EV_TS_CONST (0.))
{
#if EV_USE_NANOSLEEP
struct timespec ts;
@ -3546,7 +3549,7 @@ timers_reify (EV_P)
if (ev_at (w) < mn_now)
ev_at (w) = mn_now;
assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > EV_TS_CONST (0.)));
ANHE_at_cache (timers [HEAP0]);
downheap (timers, timercnt, HEAP0);
@ -3687,7 +3690,7 @@ time_update (EV_P_ ev_tstamp max_block)
/* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */
/* interpolate in the meantime */
if (ecb_expect_true (mn_now - now_floor < MIN_TIMEJUMP * .5))
if (ecb_expect_true (mn_now - now_floor < EV_TS_CONST (MIN_TIMEJUMP * .5)))
{
ev_rt_now = rtmn_diff + mn_now;
return;
@ -3711,7 +3714,7 @@ time_update (EV_P_ ev_tstamp max_block)
diff = odiff - rtmn_diff;
if (ecb_expect_true ((diff < 0. ? -diff : diff) < MIN_TIMEJUMP))
if (ecb_expect_true ((diff < EV_TS_CONST (0.) ? -diff : diff) < EV_TS_CONST (MIN_TIMEJUMP)))
return; /* all is well */
ev_rt_now = ev_time ();
@ -3730,7 +3733,7 @@ time_update (EV_P_ ev_tstamp max_block)
{
ev_rt_now = ev_time ();
if (ecb_expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP))
if (ecb_expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + EV_TS_CONST (MIN_TIMEJUMP)))
{
/* adjust timers. this is easy, as the offset is the same for all of them */
timers_reschedule (EV_A_ ev_rt_now - mn_now);
@ -3809,7 +3812,7 @@ ev_run (EV_P_ int flags)
ev_tstamp prev_mn_now = mn_now;
/* update time to cancel out callback processing overhead */
time_update (EV_A_ 1e100);
time_update (EV_A_ EV_TS_CONST (EV_TSTAMP_HUGE));
/* from now on, we want a pipe-wake-up */
pipe_write_wanted = 1;
@ -3818,7 +3821,7 @@ ev_run (EV_P_ int flags)
if (ecb_expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt || pipe_write_skipped)))
{
waittime = MAX_BLOCKTIME;
waittime = EV_TS_CONST (MAX_BLOCKTIME);
if (timercnt)
{
@ -3851,7 +3854,7 @@ ev_run (EV_P_ int flags)
if (sleeptime > waittime - backend_mintime)
sleeptime = waittime - backend_mintime;
if (ecb_expect_true (sleeptime > 0.))
if (ecb_expect_true (sleeptime > EV_TS_CONST (0.)))
{
ev_sleep (sleeptime);
waittime -= sleeptime;
@ -3935,7 +3938,7 @@ ev_unref (EV_P) EV_NOEXCEPT
void
ev_now_update (EV_P) EV_NOEXCEPT
{
time_update (EV_A_ 1e100);
time_update (EV_A_ EV_TSTAMP_HUGE);
}
void
@ -4176,7 +4179,7 @@ ev_timer_again (EV_P_ ev_timer *w) EV_NOEXCEPT
ev_tstamp
ev_timer_remaining (EV_P_ ev_timer *w) EV_NOEXCEPT
{
return ev_at (w) - (ev_is_active (w) ? mn_now : 0.);
return ev_at (w) - (ev_is_active (w) ? mn_now : EV_TS_CONST (0.));
}
#if EV_PERIODIC_ENABLE

View File

@ -147,7 +147,7 @@ epoll_poll (EV_P_ ev_tstamp timeout)
int eventcnt;
if (ecb_expect_false (epoll_epermcnt))
timeout = 0.;
timeout = EV_TS_CONST (0.);
/* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */
/* the default libev max wait time, however. */
@ -266,7 +266,7 @@ epoll_init (EV_P_ int flags)
if ((backend_fd = epoll_epoll_create ()) < 0)
return 0;
backend_mintime = 1e-3; /* epoll does sometimes return early, this is just to avoid the worst */
backend_mintime = EV_TS_CONST (1e-3); /* epoll does sometimes return early, this is just to avoid the worst */
backend_modify = epoll_modify;
backend_poll = epoll_poll;

View File

@ -576,7 +576,7 @@ iouring_poll (EV_P_ ev_tstamp timeout)
{
/* if we have events, no need for extra syscalls, but we might have to queue events */
if (iouring_handle_cq (EV_A))
timeout = 0.;
timeout = EV_TS_CONST (0.);
else
/* no events, so maybe wait for some */
iouring_tfd_update (EV_A_ timeout);
@ -589,7 +589,7 @@ iouring_poll (EV_P_ ev_tstamp timeout)
EV_RELEASE_CB;
res = evsys_io_uring_enter (iouring_fd, iouring_to_submit, 1,
timeout ? IORING_ENTER_GETEVENTS : 0, 0, 0);
timeout > EV_TS_CONST (0.) ? IORING_ENTER_GETEVENTS : 0, 0, 0);
iouring_to_submit = 0;
EV_ACQUIRE_CB;

View File

@ -170,7 +170,7 @@ kqueue_init (EV_P_ int flags)
fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
backend_mintime = 1e-9; /* apparently, they did the right thing in freebsd */
backend_mintime = EV_TS_CONST (1e-9); /* apparently, they did the right thing in freebsd */
backend_modify = kqueue_modify;
backend_poll = kqueue_poll;

View File

@ -439,7 +439,7 @@ linuxaio_get_events (EV_P_ ev_tstamp timeout)
else
break; /* no events from the kernel, we are done */
timeout = 0; /* only wait in the first iteration */
timeout = EV_TS_CONST (0.); /* only wait in the first iteration */
}
}
@ -519,7 +519,7 @@ linuxaio_poll (EV_P_ ev_tstamp timeout)
backend_poll = epoll_poll;
}
timeout = 0;
timeout = EV_TS_CONST (0.);
/* it's easiest to handle this mess in another iteration */
return;
}

View File

@ -136,7 +136,7 @@ inline_size
int
poll_init (EV_P_ int flags)
{
backend_mintime = 1e-3;
backend_mintime = EV_TS_CONST (1e-3);
backend_modify = poll_modify;
backend_poll = poll_poll;

View File

@ -70,7 +70,7 @@ port_associate_and_check (EV_P_ int fd, int ev)
{
if (errno == EBADFD)
{
assert (("libev: port_associate found invalid fd", errno != EBADFD);
assert (("libev: port_associate found invalid fd", errno != EBADFD));
fd_kill (EV_A_ fd);
}
else
@ -158,7 +158,7 @@ port_init (EV_P_ int flags)
* 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_mintime = EV_TS_CONST (1e-3); /* needed to compensate for port_getn returning early */
backend_modify = port_modify;
backend_poll = port_poll;

View File

@ -197,7 +197,7 @@ select_poll (EV_P_ ev_tstamp timeout)
{
if (timeout)
{
unsigned long ms = timeout * 1e3;
unsigned long ms = EV_TS_TO_MSEC (timeout);
Sleep (ms ? ms : 1);
}
@ -275,7 +275,7 @@ inline_size
int
select_init (EV_P_ int flags)
{
backend_mintime = 1e-6;
backend_mintime = EV_TS_CONST (1e-6);
backend_modify = select_modify;
backend_poll = select_poll;