]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: remove a whole bunch of unused time stuff
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 28 Jul 2016 15:23:40 +0000 (17:23 +0200)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 28 Jul 2016 11:27:47 +0000 (07:27 -0400)
QUAGGA_CLK_REALTIME and QUAGGA_CLK_REALTIME_STABILISED aren't used
anywhere in the code.  Remove.  The enum is kept to avoid having to
change the calls everywhere.

Same applies to the workaround code for systems that don't have a
monotonic clock.  None of the systems Quagga works on fall into that
category;  Linux, BSD and Solaris all do clock_gettime, for OSX we have
mach_absolute_time() - that covers everything.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/thread.c
lib/thread.h

index 717210b950fecc4a254f7abe096a825495a50e84..0b50f9edeb5dbed8aa10d65ea4ea833c959a4500 100644 (file)
@@ -60,12 +60,8 @@ extern int agentx_enabled;
 
 /* Recent absolute time of day */
 struct timeval recent_time;
-static struct timeval last_recent_time;
 /* Relative time, since startup */
 static struct timeval relative_time;
-static struct timeval relative_time_base;
-/* init flag */
-static unsigned short timers_inited;
 
 static struct hash *cpu_record = NULL;
 
@@ -118,27 +114,6 @@ timeval_elapsed (struct timeval a, struct timeval b)
          + (a.tv_usec - b.tv_usec));
 }
 
-#if !defined(HAVE_CLOCK_MONOTONIC) && !defined(__APPLE__)
-static void
-quagga_gettimeofday_relative_adjust (void)
-{
-  struct timeval diff;
-  if (timeval_cmp (recent_time, last_recent_time) < 0)
-    {
-      relative_time.tv_sec++;
-      relative_time.tv_usec = 0;
-    }
-  else
-    {
-      diff = timeval_subtract (recent_time, last_recent_time);
-      relative_time.tv_sec += diff.tv_sec;
-      relative_time.tv_usec += diff.tv_usec;
-      relative_time = timeval_adjust (relative_time);
-    }
-  last_recent_time = recent_time;
-}
-#endif /* !HAVE_CLOCK_MONOTONIC && !__APPLE__ */
-
 /* gettimeofday wrapper, to keep recent_time updated */
 static int
 quagga_gettimeofday (struct timeval *tv)
@@ -149,12 +124,6 @@ quagga_gettimeofday (struct timeval *tv)
   
   if (!(ret = gettimeofday (&recent_time, NULL)))
     {
-      /* init... */
-      if (!timers_inited)
-        {
-          relative_time_base = last_recent_time = recent_time;
-          timers_inited = 1;
-        }
       /* avoid copy if user passed recent_time pointer.. */
       if (tv != &recent_time)
         *tv = recent_time;
@@ -194,8 +163,7 @@ quagga_get_relative (struct timeval *tv)
     return 0;
   }
 #else /* !HAVE_CLOCK_MONOTONIC && !__APPLE__ */
-  if (!(ret = quagga_gettimeofday (&recent_time)))
-    quagga_gettimeofday_relative_adjust();
+#error no monotonic clock on this system
 #endif /* HAVE_CLOCK_MONOTONIC */
 
   if (tv)
@@ -204,18 +172,6 @@ quagga_get_relative (struct timeval *tv)
   return ret;
 }
 
-/* Get absolute time stamp, but in terms of the internal timer
- * Could be wrong, but at least won't go back.
- */
-static void
-quagga_real_stabilised (struct timeval *tv)
-{
-  *tv = relative_time_base;
-  tv->tv_sec += relative_time.tv_sec;
-  tv->tv_usec += relative_time.tv_usec;
-  *tv = timeval_adjust (*tv);
-}
-
 /* Exported Quagga timestamp function.
  * Modelled on POSIX clock_gettime.
  */
@@ -224,13 +180,8 @@ quagga_gettime (enum quagga_clkid clkid, struct timeval *tv)
 {
   switch (clkid)
     {
-      case QUAGGA_CLK_REALTIME:
-        return quagga_gettimeofday (tv);
       case QUAGGA_CLK_MONOTONIC:
         return quagga_get_relative (tv);
-      case QUAGGA_CLK_REALTIME_STABILISED:
-        quagga_real_stabilised (tv);
-        return 0;
       default:
         errno = EINVAL;
         return -1;
@@ -245,19 +196,6 @@ quagga_monotime (void)
   return tv.tv_sec;
 }
 
-/* time_t value in terms of stabilised absolute time. 
- * replacement for POSIX time()
- */
-time_t
-quagga_time (time_t *t)
-{
-  struct timeval tv;
-  quagga_real_stabilised (&tv);
-  if (t)
-    *t = tv.tv_sec;
-  return tv.tv_sec;
-}
-
 /* Public export of recent_relative_time by value */
 struct timeval
 recent_relative_time (void)
index ac87595ee41a7358ef57c8b1c6f8c60201e840c3..3c0387eb117c7bd77237d03c6a87bcbaf3409216 100644 (file)
@@ -130,9 +130,7 @@ struct cpu_thread_history
 
 /* Clocks supported by Quagga */
 enum quagga_clkid {
-  QUAGGA_CLK_REALTIME = 0,     /* ala gettimeofday() */
-  QUAGGA_CLK_MONOTONIC,                /* monotonic, against an indeterminate base */
-  QUAGGA_CLK_REALTIME_STABILISED, /* like realtime, but non-decrementing */
+  QUAGGA_CLK_MONOTONIC = 1,    /* monotonic, against an indeterminate base */
 };
 
 /* Struct timeval's tv_usec one second value.  */
@@ -254,7 +252,6 @@ extern struct cmd_element clear_thread_cpu_cmd;
  */
 extern int quagga_gettime (enum quagga_clkid, struct timeval *);
 extern time_t quagga_monotime (void);
-extern time_t quagga_time (time_t *);
 
 /* Returns elapsed real (wall clock) time. */
 extern unsigned long thread_consumed_time(RUSAGE_T *after, RUSAGE_T *before,