+static void
+time_update ()
+{
+ int i;
+ ev_now = ev_time ();
+
+ if (have_monotonic)
+ {
+ ev_tstamp odiff = diff;
+
+ /* detecting time jumps is much more difficult */
+ for (i = 2; --i; ) /* loop a few times, before making important decisions */
+ {
+ now = get_clock ();
+ diff = ev_now - now;
+
+ if (fabs (odiff - diff) < MIN_TIMEJUMP)
+ return; /* all is well */
+
+ ev_now = ev_time ();
+ }
+
+ /* time jump detected, reschedule atimers */
+ for (i = 0; i < atimercnt; ++i)
+ {
+ struct ev_timer *w = atimers [i];
+ w->at += ceil ((ev_now - w->at) / w->repeat + 1.) * w->repeat;
+ }
+ }
+ else
+ {
+ if (now > ev_now || now < ev_now - MAX_BLOCKTIME - MIN_TIMEJUMP)
+ /* time jump detected, adjust rtimers */
+ for (i = 0; i < rtimercnt; ++i)
+ rtimers [i]->at += ev_now - now;
+
+ now = ev_now;
+ }
+}
+