18#ifndef _BOILERPLATE_TIME_H
19#define _BOILERPLATE_TIME_H
23typedef unsigned long long ticks_t;
25typedef long long sticks_t;
31void timespec_sub(
struct timespec *__restrict r,
32 const struct timespec *__restrict t1,
33 const struct timespec *__restrict t2);
35void timespec_subs(
struct timespec *__restrict r,
36 const struct timespec *__restrict t1,
39void timespec_add(
struct timespec *__restrict r,
40 const struct timespec *__restrict t1,
41 const struct timespec *__restrict t2);
43void timespec_adds(
struct timespec *__restrict r,
44 const struct timespec *__restrict t1,
47void timespec_sets(
struct timespec *__restrict r,
54static inline sticks_t timespec_scalar(
const struct timespec *__restrict t)
56 return t->tv_sec * 1000000000LL + t->tv_nsec;
59static inline int __attribute__ ((always_inline))
60timespec_before(
const struct timespec *__restrict t1,
61 const struct timespec *__restrict t2)
63 if (t1->tv_sec < t2->tv_sec)
66 if (t1->tv_sec == t2->tv_sec &&
67 t1->tv_nsec < t2->tv_nsec)
73static inline int __attribute__ ((always_inline))
74timespec_before_or_same(
const struct timespec *__restrict t1,
75 const struct timespec *__restrict t2)
77 if (t1->tv_sec < t2->tv_sec)
80 if (t1->tv_sec == t2->tv_sec &&
81 t1->tv_nsec <= t2->tv_nsec)
87static inline int __attribute__ ((always_inline))
88timespec_after(
const struct timespec *__restrict t1,
89 const struct timespec *__restrict t2)
91 return !timespec_before_or_same(t1, t2);
94static inline int __attribute__ ((always_inline))
95timespec_after_or_same(
const struct timespec *__restrict t1,
96 const struct timespec *__restrict t2)
98 return !timespec_before(t1, t2);