timestamps on a monotonic and the UTC timescales respectively.
Doubles are much more convenient than timespecs for comparisons etc.
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1668
d4fa192b-c00b-0410-8231-
f00ffab90ce4
/* from libvarnish/time.c */
void TIM_format(time_t t, char *p);
time_t TIM_parse(const char *p);
+double TIM_mono(void);
+double TIM_real(void);
/* from libvarnish/version.c */
void varnish_version(const char *);
#include <string.h>
#include <time.h>
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
#include "libvarnish.h"
+double
+TIM_mono(void)
+{
+ struct timespec ts;
+
+ assert(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
+ return (ts.tv_sec + 1e-9 * ts.tv_nsec);
+}
+
+double
+TIM_real(void)
+{
+ struct timespec ts;
+
+ assert(clock_gettime(CLOCK_REALTIME, &ts) == 0);
+ return (ts.tv_sec + 1e-9 * ts.tv_nsec);
+}
+
void
TIM_format(time_t t, char *p)
{