diff options
author | Vincent Sanders <vince@kyllikki.org> | 2014-12-01 09:21:34 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2014-12-01 09:22:16 +0000 |
commit | 228710c55bc4e8f69ad56ad981b25a0c4ce41a4c (patch) | |
tree | 721e58e1a4723e228e22b5a67a8f451258c2fe88 | |
parent | b6e898b7518777b41d9d82dd3e861a64016cbe0a (diff) | |
download | libnsutils-228710c55bc4e8f69ad56ad981b25a0c4ce41a4c.tar.gz libnsutils-228710c55bc4e8f69ad56ad981b25a0c4ce41a4c.tar.bz2 |
do not report time in future if time did not move forwards.
-rw-r--r-- | include/nsutils/time.h | 5 | ||||
-rw-r--r-- | src/time.c | 4 |
2 files changed, 2 insertions, 7 deletions
diff --git a/include/nsutils/time.h b/include/nsutils/time.h index aa39d94..715d3e4 100644 --- a/include/nsutils/time.h +++ b/include/nsutils/time.h @@ -18,15 +18,12 @@ #include <nsutils/errors.h> /** - * Get a monotonically incriminating number of milliseconds. + * Get a monotonically incrementing number of milliseconds. * * Obtain a count of elapsed time in milliseconds from an arbitrary point in * time. Unlike gettimeofday this will continue linearly across time setting * and not go backwards. * - * \note The read value will always increment by at least 1 on each call meaning - * times less than 1ms cannot be differentiated. - * * \param current The current value of the counter. * \return NSERROR_OK on success else error code. */ @@ -87,12 +87,10 @@ nsuerror nsu_getmonotonic_ms(uint64_t *current_out) #endif /* ensure time never goes backwards */ - if (current > prev) { + if (current >= prev) { *current_out = current; prev = current; } else { - /** \todo is 1ms really correct or can we calculate a delta going forwards? */ - prev += 1; *current_out = prev; } return NSUERROR_OK; |