From 67a271596cc8c183a877f24f3cd174665a87fefd Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 25 Mar 2011 10:37:06 +0100 Subject: [PATCH] [lib] Add timestamp_equals() owl_timestamp_equals() allows to compare two owl_timestamp more accurately and efficiently than "owl_time_elapsed_ms() == 0". --- libowlps/libowlps.c | 7 +++++++ libowlps/owlps.h | 1 + 2 files changed, 8 insertions(+) diff --git a/libowlps/libowlps.c b/libowlps/libowlps.c index 76d67e1..010d7b1 100644 --- a/libowlps/libowlps.c +++ b/libowlps/libowlps.c @@ -149,6 +149,13 @@ owl_timestamp owl_timeval_to_timestamp(const struct timeval d) +owl_bool owl_timestamp_equals(owl_timestamp d1, owl_timestamp d2) +{ + return d1.tv_sec == d2.tv_sec && d1.tv_nsec == d2.tv_nsec ; +} + + + owl_bool owl_timestamp_is_null(owl_timestamp d) { return d.tv_sec == 0 && d.tv_nsec == 0 ; diff --git a/libowlps/owlps.h b/libowlps/owlps.h index c53c198..aad0860 100644 --- a/libowlps/owlps.h +++ b/libowlps/owlps.h @@ -256,6 +256,7 @@ int owl_timestamp_now(owl_timestamp *now) ; owl_timestamp owl_timespec_to_timestamp(const struct timespec d) ; owl_timestamp owl_timeval_to_timestamp(const struct timeval d) ; void owl_timestamp_to_string(char *dst, owl_timestamp src) ; +owl_bool owl_timestamp_equals(owl_timestamp d1, owl_timestamp d2) ; owl_bool owl_timestamp_is_null(owl_timestamp d) ; uint64_t owl_timestamp_to_ms(owl_timestamp date) ; uint_fast32_t owl_time_elapsed_ms(const owl_timestamp d1,