[lib] Add timestamp_equals()

owl_timestamp_equals() allows to compare two owl_timestamp more
accurately and efficiently than "owl_time_elapsed_ms() == 0".
This commit is contained in:
Matteo Cypriani 2011-03-25 10:37:06 +01:00
parent 4720399513
commit 67a271596c
2 changed files with 8 additions and 0 deletions

View File

@ -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 ;

View File

@ -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,