From 89d55438b847ed025035fde1c1ff8d7e5f16505f Mon Sep 17 00:00:00 2001 From: Marc Alexander Lehmann Date: Sun, 7 Jul 2019 06:00:31 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 3 ++- ev.3 | 16 +++++++++++----- ev.c | 26 +++++++++++++------------- ev_epoll.c | 2 +- ev_poll.c | 2 +- ev_port.c | 2 +- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Changes b/Changes index 38aa21c..c96b9c1 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,7 @@ TODO: maybe use timerfd to detect time jumps on linux libecb counterparts. - move syscall infrastructure from ev_linuxaio.c to ev.c. - prepare io_uring integration. + - tweak ev_floor. 4.27 Thu Jun 27 22:43:44 CEST 2019 - linux aio backend almost completely rewritten to work around its @@ -35,7 +36,7 @@ TODO: maybe use timerfd to detect time jumps on linux 4.25 Fri Dec 21 07:49:20 CET 2018 - INCOMPATIBLE CHANGE: EV_THROW was renamed to EV_NOEXCEPT (EV_THROW still provided) and now uses noexcept on C++11 or newer. - - move the darwin select workaround highe rin ev.c, as newer versions of + - move the darwin select workaround higher in ev.c, as newer versions of darwin managed to break their broken select even more. - ANDROID => __ANDROID__ (reported by enh@google.com). - disable epoll_create1 on android because it has broken header files diff --git a/ev.3 b/ev.3 index 8603e82..8c06f47 100644 --- a/ev.3 +++ b/ev.3 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "LIBEV 3" -.TH LIBEV 3 "2019-06-25" "libev-4.25" "libev - high performance full featured event loop" +.TH LIBEV 3 "2019-07-07" "libev-4.27" "libev - high performance full featured event loop" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -1873,7 +1873,7 @@ reuse the same code path. \fIThe special problem of fork\fR .IX Subsection "The special problem of fork" .PP -Some backends (epoll, kqueue, probably linuxaio) do not support \f(CW\*(C`fork ()\*(C'\fR +Some backends (epoll, kqueue, linuxaio, iouring) do not support \f(CW\*(C`fork ()\*(C'\fR at all or exhibit useless behaviour. Libev fully supports fork, but needs to be told about it in the child if you want to continue to use it in the child. @@ -4626,6 +4626,7 @@ in your include path (e.g. in libev/ when using \-Ilibev): \& ev_poll.c only when poll backend is enabled \& ev_epoll.c only when the epoll backend is enabled \& ev_linuxaio.c only when the linux aio backend is enabled +\& ev_iouring.c only when the linux io_uring backend is enabled \& ev_kqueue.c only when the kqueue backend is enabled \& ev_port.c only when the solaris port backend is enabled .Ve @@ -4818,10 +4819,15 @@ backend for GNU/Linux systems. If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc 2.4 or newer, otherwise disabled. .IP "\s-1EV_USE_LINUXAIO\s0" 4 .IX Item "EV_USE_LINUXAIO" +If defined to be \f(CW1\fR, libev will compile in support for the Linux aio +backend (\f(CW\*(C`EV_USE_EPOLL\*(C'\fR must also be enabled). If undefined, it will be +enabled on linux, otherwise disabled. +.IP "\s-1EV_USE_IOURING\s0" 4 +.IX Item "EV_USE_IOURING" If defined to be \f(CW1\fR, libev will compile in support for the Linux -aio backend. Due to it's currenbt limitations it has to be requested -explicitly. If undefined, it will be enabled on linux, otherwise -disabled. +io_uring backend (\f(CW\*(C`EV_USE_EPOLL\*(C'\fR must also be enabled). Due to it's +current limitations it has to be requested explicitly. If undefined, it +will be enabled on linux, otherwise disabled. .IP "\s-1EV_USE_KQUEUE\s0" 4 .IX Item "EV_USE_KQUEUE" If defined to be \f(CW1\fR, libev will compile in support for the \s-1BSD\s0 style diff --git a/ev.c b/ev.c index e3d43c4..432aa68 100644 --- a/ev.c +++ b/ev.c @@ -1728,19 +1728,7 @@ ev_floor (ev_tstamp v) const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 18446744073709551616. : 4294967296.; #endif - /* argument too large for an unsigned long? */ - if (ecb_expect_false (v >= shift)) - { - ev_tstamp f; - - if (v == v - 1.) - return v; /* very large number */ - - f = shift * ev_floor (v * (1. / shift)); - return f + ev_floor (v - f); - } - - /* special treatment for negative args? */ + /* special treatment for negative arguments */ if (ecb_expect_false (v < 0.)) { ev_tstamp f = -ev_floor (-v); @@ -1748,6 +1736,18 @@ ev_floor (ev_tstamp v) return f - (f == v ? 0 : 1); } + /* argument too large for an unsigned long? then reduce it */ + if (ecb_expect_false (v >= shift)) + { + ev_tstamp f; + + if (v == v - 1.) + return v; /* very large numbers are assumed to be integer */ + + f = shift * ev_floor (v * (1. / shift)); + return f + ev_floor (v - f); + } + /* fits into an unsigned long */ return (unsigned long)v; } diff --git a/ev_epoll.c b/ev_epoll.c index a343fcb..ab6033e 100644 --- a/ev_epoll.c +++ b/ev_epoll.c @@ -152,7 +152,7 @@ epoll_poll (EV_P_ ev_tstamp timeout) /* 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, timeout * 1e3); + eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, timeout * 1e3 + 0.9999); EV_ACQUIRE_CB; if (ecb_expect_false (eventcnt < 0)) diff --git a/ev_poll.c b/ev_poll.c index fa1bbcc..880d592 100644 --- a/ev_poll.c +++ b/ev_poll.c @@ -95,7 +95,7 @@ poll_poll (EV_P_ ev_tstamp timeout) int res; EV_RELEASE_CB; - res = poll (polls, pollcnt, timeout * 1e3); + res = poll (polls, pollcnt, timeout * 1e3 + 0.9999); EV_ACQUIRE_CB; if (ecb_expect_false (res < 0)) diff --git a/ev_port.c b/ev_port.c index a08e3df..2941bac 100644 --- a/ev_port.c +++ b/ev_port.c @@ -154,7 +154,7 @@ port_init (EV_P_ int flags) /* 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 + * elapsed and doesn't round up if that is the case, 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. */