diff options
Diffstat (limited to 'src/libstddjb/tain_now_set_stopwatch.c')
-rw-r--r-- | src/libstddjb/tain_now_set_stopwatch.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libstddjb/tain_now_set_stopwatch.c b/src/libstddjb/tain_now_set_stopwatch.c new file mode 100644 index 0000000..184a40a --- /dev/null +++ b/src/libstddjb/tain_now_set_stopwatch.c @@ -0,0 +1,36 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <skalibs/tai.h> + +#if defined(SKALIBS_HAS_CLOCKRT) && (defined(SKALIBS_HAS_CLOCKMON) || defined(SKALIBS_HAS_CLOCKBOOT)) + +#include <time.h> + +#ifdef SKALIBS_HAS_CLOCKMON +# 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 |