summaryrefslogtreecommitdiff
path: root/src/libstddjb/tain_now_set_stopwatch.c
blob: a8f94d7397d96c751f2674efd82079a5abf8ee09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* ISC license. */

/* MT-unsafe */

#include <skalibs/tai.h>

#if defined(SKALIBS_HASCLOCKRT) && (defined(SKALIBS_HASCLOCKMON) || defined(SKALIBS_HASCLOCKBOOT))

#include <time.h>

#ifdef SKALIBS_HASCLOCKMON
# define SKALIBS_STOPWATCH CLOCK_MONOTONIC
#else
# define SKALIBS_STOPWATCH CLOCK_BOOTTIME
#endif

static tain_t offset ;

static int tain_now_stopwatch (tain_t *a)
{
  return tain_stopwatch_read(a, SKALIBS_STOPWATCH, &offset) ;
}

void tain_now_set_stopwatch (void)
{
  if (!tain_stopwatch_init(SKALIBS_STOPWATCH, &offset)) return ;
  tain_now = &tain_now_stopwatch ;
}

#else

void tain_now_set_stopwatch (void)
{
}

#endif