From c499fc7bc9e1c3b8fe04ea5c80e5a7e0b16b11fc Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Wed, 19 Jun 2019 11:58:03 +0300 Subject: time: add a generalized time comparison function. Signed-off-by: Gediminas Jakutis --- src/time/time.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/time') diff --git a/src/time/time.c b/src/time/time.c index 13a102f..d9f00b7 100644 --- a/src/time/time.c +++ b/src/time/time.c @@ -60,8 +60,17 @@ struct timespec rin_time_normalize(const struct timespec * const t) } return ret; +} +long int rin_time_cmp(const struct timespec * const a, const struct timespec * const b) +{ + if (a->tv_sec != b->tv_sec) { + return a->tv_sec - b->tv_sec; + } else { + return a->tv_nsec - b->tv_nsec; + } } + unsigned int rin_time_cmp_less(const struct timespec * const a, const struct timespec * const b) { if (a->tv_sec > b->tv_sec) { -- cgit v1.2.3