]> rtime.felk.cvut.cz Git - sojka/libev.git/commitdiff
periodic_recalc, hpux
authorMarc Alexander Lehmann <libev@schmorp.de>
Sun, 30 Jan 2011 19:05:40 +0000 (19:05 +0000)
committerMarc Alexander Lehmann <libev@schmorp.de>
Sun, 30 Jan 2011 19:05:40 +0000 (19:05 +0000)
Changes
ev.c
ev_select.c

diff --git a/Changes b/Changes
index 9fa01e55ee24360aaced6e396818f29dce9156e1..da55f1a8aba86ec6025100730af152c506ba92d8 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,7 +2,9 @@ Revision history for libev, a high-performance and full-featured event loop.
 
 TODO: signal mask problem documentation
 TODO: ev_loop_wakeup
+TODO: windows handle caching, added/not removed in ev_select.c
        - do no rely on ceil() in ev_e?poll.c.
+        - backport libev to HP-UX versions before 11 v3.
 
 4.03 Tue Jan 11 14:37:25 CET 2011
        - officially support polling files with all backends.
diff --git a/ev.c b/ev.c
index 23d1bd2007261441b21696d866943f2eee02c8ae..c888e22910e98df7004a49dc44689c6498ac9280 100644 (file)
--- a/ev.c
+++ b/ev.c
@@ -378,7 +378,8 @@ EV_CPP(extern "C" {)
 #endif
 
 #if !EV_USE_NANOSLEEP
-# ifndef _WIN32
+/* hp-ux has it in sys/time.h, which we unconditionally include above */
+# if !defined(_WIN32) && !defined(__hpux)
 #  include <sys/select.h>
 # endif
 #endif
@@ -2193,6 +2194,15 @@ timers_reify (EV_P)
 }
 
 #if EV_PERIODIC_ENABLE
+
+inline_speed
+periodic_recalc (EV_P_ ev_periodic *w)
+{
+  /* TODO: use slow but potentially more correct incremental algo, */
+  /* also do not rely on ceil */
+  ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
+}
+
 /* make periodics pending */
 inline_size void
 periodics_reify (EV_P)
@@ -2221,7 +2231,8 @@ periodics_reify (EV_P)
             }
           else if (w->interval)
             {
-              ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
+              periodic_recalc (EV_A_ w);
+
               /* if next trigger time is not sufficiently in the future, put it there */
               /* this might happen because of floating point inexactness */
               if (ev_at (w) - ev_rt_now < TIME_EPSILON)
@@ -2265,7 +2276,7 @@ periodics_reschedule (EV_P)
       if (w->reschedule_cb)
         ev_at (w) = w->reschedule_cb (w, ev_rt_now);
       else if (w->interval)
-        ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
+        periodic_recalc (EV_A_ w);
 
       ANHE_at_cache (periodics [i]);
     }
@@ -2767,8 +2778,7 @@ ev_periodic_start (EV_P_ ev_periodic *w)
   else if (w->interval)
     {
       assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
-      /* this formula differs from the one in periodic_reify because we do not always round up */
-      ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
+      periodic_recalc (EV_A_ w);
     }
   else
     ev_at (w) = w->offset;
index 76ffa86b3b64953bea98104623fea43962eeec86..47a775e289184d7894220eec98c088b822a2c69f 100644 (file)
 
 #ifndef _WIN32
 /* for unix systems */
-# include <sys/select.h>
 # include <inttypes.h>
+# ifndef __hpux
+/* for REAL unix systems */
+# include <sys/select.h>
+# endif
 #endif
 
 #ifndef EV_SELECT_USE_FD_SET