Revision history for libev, a high-performance and full-featured event loop.
+Rspamd local extensions (not present in upstream libev):
+ - ev_active_cnt: returns the loop's activecnt counter.
+ - ev_now_update_if_cheap: cheap variant of ev_now_update for paths
+ that need a fresh cached time but cannot afford a realtime read.
+ - ev_now_resync: force-resync the loop's cached realtime/monotonic
+ state from the current time sources, discarding interpolation.
+ Use after installing/removing a fake clock.
+ - ev_set_fake_time_cb / ev_get_fake_time_cb: process-global fake
+ clock hook for unit tests; when set, replaces both ev_time() and
+ the internal monotonic clock so timers and ev_now() advance under
+ test control. NULL by default; cost in production is one
+ predicted-false branch.
+
4.25 Fri Dec 21 07:49:20 CET 2018
- INCOMPATIBLE CHANGE: EV_THROW was renamed to EV_NOEXCEPT
(EV_THROW sitll provided) and now uses noexcept on C++11 or newer.
alloc = cb;
}
+/* RSPAMD LOCAL EXTENSION: process-global fake-clock hook for unit tests.
+ * When non-NULL, both ev_time() and get_clock() return the callback's value
+ * instead of reading the system clocks. See ev.h for the public API.
+ */
+static ev_fake_time_cb fake_time_cb = 0;
+
+ecb_cold
+void
+ev_set_fake_time_cb (ev_fake_time_cb cb) EV_NOEXCEPT
+{
+ fake_time_cb = cb;
+}
+
+ecb_cold
+ev_fake_time_cb
+ev_get_fake_time_cb (void) EV_NOEXCEPT
+{
+ return fake_time_cb;
+}
+
inline_speed void *
ev_realloc (void *ptr, long size)
{
ev_tstamp
ev_time (void) EV_NOEXCEPT
{
+ /* RSPAMD LOCAL EXTENSION: fake clock hook for unit tests. */
+ if (ecb_expect_false (fake_time_cb != 0))
+ return fake_time_cb ();
+
#if EV_USE_REALTIME
if (ecb_expect_true (have_realtime))
{
inline_size ev_tstamp
get_clock (void)
{
+ /* RSPAMD LOCAL EXTENSION: fake clock hook for unit tests. */
+ if (ecb_expect_false (fake_time_cb != 0))
+ return fake_time_cb ();
+
#if EV_USE_MONOTONIC
if (ecb_expect_true (have_monotonic))
{
if (have_cheap_timer) time_update (EV_A_ 1e100);
}
+/* RSPAMD LOCAL EXTENSION: see ev.h. */
+void
+ev_now_resync (EV_P) EV_NOEXCEPT
+{
+ ev_rt_now = ev_time ();
+ mn_now = get_clock ();
+ now_floor = mn_now;
+ rtmn_diff = ev_rt_now - mn_now;
+}
+
int
ev_active_cnt (EV_P) EV_NOEXCEPT
{
*/
EV_API_DECL void ev_set_syserr_cb (void (*cb)(const char *msg) EV_NOEXCEPT) EV_NOEXCEPT;
+/* RSPAMD LOCAL EXTENSION:
+ * Install a process-global fake clock callback used by ev_time() and the
+ * internal monotonic clock read. When set, the callback's return value
+ * replaces both the realtime and monotonic clock sources, so timers and
+ * ev_now()/ev_now_update() advance under test control. Pass NULL to
+ * restore the system clocks. Intended for unit tests only.
+ */
+typedef ev_tstamp (*ev_fake_time_cb)(void);
+EV_API_DECL void ev_set_fake_time_cb (ev_fake_time_cb cb) EV_NOEXCEPT;
+EV_API_DECL ev_fake_time_cb ev_get_fake_time_cb (void) EV_NOEXCEPT;
+
#if EV_MULTIPLICITY
/* the default loop is the only one that handles signals and child watchers */
* are used in system.
*/
EV_API_DECL void ev_now_update_if_cheap (EV_P) EV_NOEXCEPT;
+/* RSPAMD LOCAL EXTENSION:
+ * Force-resync the loop's cached realtime/monotonic state from the current
+ * time sources, discarding any interpolation state. Use after installing
+ * or removing a fake clock via ev_set_fake_time_cb(), or after any other
+ * large discontinuity in the clock source.
+ */
+EV_API_DECL void ev_now_resync (EV_P) EV_NOEXCEPT;
#if EV_WALK_ENABLE
/* walk (almost) all watchers in the loop of a given type, invoking the */