Commit 83587cd5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add TIM_mono() and TIM_real() which return double representations of

timestamps on a monotonic and the UTC timescales respectively.

Doubles are much more convenient than timespecs for comparisons etc.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1668 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent af817567
......@@ -47,6 +47,8 @@ uint32_t crc32_l(const void *p1, unsigned l);
/* 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 *);
......
......@@ -50,8 +50,30 @@
#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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment