diff options
author | Josh Blum | 2013-06-11 17:55:31 -0700 |
---|---|---|
committer | Josh Blum | 2013-06-11 17:55:31 -0700 |
commit | c73eb9bf1954135372b1cc8e7b21d7cc0cdfd489 (patch) | |
tree | c68ba6daf09021df58c6ae11f18bb3dc36e88eae /include/gras/detail | |
parent | 8ff889a8160bdf61739066c74c469ca2bcad093e (diff) | |
download | sandhi-c73eb9bf1954135372b1cc8e7b21d7cc0cdfd489.tar.gz sandhi-c73eb9bf1954135372b1cc8e7b21d7cc0cdfd489.tar.bz2 sandhi-c73eb9bf1954135372b1cc8e7b21d7cc0cdfd489.zip |
gras: reverted chrono changes w/ 32-bit math fix
The seconds * ticks per second math was 32 bit,
because UL follows the system width, we needed long long.
* for loop for heartier unit testing
* use get_tps rather than duplicate const number
Diffstat (limited to 'include/gras/detail')
-rw-r--r-- | include/gras/detail/chrono.hpp | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/include/gras/detail/chrono.hpp b/include/gras/detail/chrono.hpp index 9fe317a..6225e55 100644 --- a/include/gras/detail/chrono.hpp +++ b/include/gras/detail/chrono.hpp @@ -29,7 +29,6 @@ namespace gras #else #include <ctime> -#include <sys/time.h> namespace gras { @@ -37,14 +36,8 @@ namespace gras GRAS_FORCE_INLINE time_ticks_t time_now(void) { struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) - return ts.tv_sec*1000000000UL + ts.tv_nsec; - - struct timeval tv; - if (gettimeofday(&tv, NULL) == 0) - return tv.tv_sec*1000000000UL + tv.tv_usec*1000UL; - - return 0; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec*time_tps() + ts.tv_nsec; } GRAS_FORCE_INLINE time_ticks_t time_tps(void) |