summaryrefslogtreecommitdiffstats
path: root/lib/qtime.h
diff options
context:
space:
mode:
authorChris Hall <chris.hall@highwayman.com>2011-03-29 01:49:16 +0100
committerChris Hall <chris.hall@highwayman.com>2011-03-29 01:49:16 +0100
commitf9956b9524ddafdb9d0cec042213eaa8229aad8c (patch)
treebf362c892837ef3f5a6a4d4265eb18e1b47ccf33 /lib/qtime.h
parent9470cb2c32eab220f796b1438b787528272cbe84 (diff)
downloadquagga-ex15p.tar.bz2
quagga-ex15p.tar.xz
Bring "ex" version up to date with 0.99.18ex15p
Release: 0.99.18ex15p -- Pipework Branch Also fixes issue with unknown attributes -- does not release them prematurely. Contains the "bgpd: New show commands for improved view and address family support", which is post 0.99.18. (But not RFC 5082 GTSM.)
Diffstat (limited to 'lib/qtime.h')
-rw-r--r--lib/qtime.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/qtime.h b/lib/qtime.h
index 38d717c0..577c34a3 100644
--- a/lib/qtime.h
+++ b/lib/qtime.h
@@ -96,6 +96,9 @@ Inline qtime_mono_t qt_get_monotonic(void) ;
/* OR equivalent using times() */
Inline qtime_mono_t qt_add_monotonic(qtime_t interval) ;
/* qt_get_monotonic() + interval */
+Inline time_t qt_get_mono_secs(void) ;
+ /* clock_gettime(CLOCK_MONOTONIC, ...) */
+ /* OR equivalent using times() */
/* These are provided just in case gettimeofday() != CLOCK_REALTIME */
Inline qtime_tod_t qt_get_timeofday(void) ;
@@ -181,6 +184,7 @@ qtime2timeval(struct timeval* p_tv, qtime_t qt)
/* Function to manufacture a monotonic clock. */
Private qtime_mono_t qt_craft_monotonic(void) ;
+Private time_t qt_craft_mono_secs(void) ;
/*------------------------------------------------------------------------------
* Read given clock & return a qtime_t value.
@@ -248,6 +252,30 @@ qt_add_monotonic(qtime_t interval)
} ;
/*------------------------------------------------------------------------------
+ * clock_gettime(CLOCK_MONOTONIC, ...) OR qt_craft_monotonic()
+ * -- returning time_t value
+ *
+ * Value returned is in seconds -- for coarser grain timings.
+ *
+ * While possibility of error is essentially theoretical, must treat it as a
+ * FATAL error -- cannot continue with broken time value !
+ */
+Inline time_t
+qt_get_mono_secs(void)
+{
+#ifdef HAVE_CLOCK_MONOTONIC
+ struct timespec ts ;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
+ zabort_errno("clock_gettime failed") ;
+
+ return ts.tv_sec ;
+#else
+ return qt_craft_mono_secs() ;
+#endif
+} ;
+
+/*------------------------------------------------------------------------------
* gettimeofday(&tv, NULL) -- returning qtime_t value
*/
Inline qtime_tod_t