summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-31 15:25:13 -0800
committerJosh Blum <josh@joshknows.com>2011-01-31 15:25:13 -0800
commitd46058d75c723402d7d135ff309afe4f00deca0c (patch)
treec90814d69ef4027a0c5402e855616fc493d959dc
parenta7d7e0d28925b01044ade6a5b9e288af8828239b (diff)
downloaduhd-d46058d75c723402d7d135ff309afe4f00deca0c.tar.gz
uhd-d46058d75c723402d7d135ff309afe4f00deca0c.tar.bz2
uhd-d46058d75c723402d7d135ff309afe4f00deca0c.zip
uhd: simplify the mach time usage based on example from web
-rw-r--r--host/lib/types/time_spec.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp
index 312c161cb..ece3b92f3 100644
--- a/host/lib/types/time_spec.cpp
+++ b/host/lib/types/time_spec.cpp
@@ -47,13 +47,10 @@ time_spec_t time_spec_t::get_system_time(void){
#ifdef TIME_SPEC_USE_MACH_ABSOLUTE_TIME
#include <mach/mach_time.h>
-static intmax_t get_freq(void){
- mach_timebase_info_data_t info; mach_timebase_info(&info);
- return intmax_t(1e9*(double(info.denom)/double(info.numer)));
-}
time_spec_t time_spec_t::get_system_time(void){
- static const intmax_t freq = get_freq();
- return time_spec_t_from_counts(mach_absolute_time(), freq);
+ mach_timebase_info_data_t info; mach_timebase_info(&info);
+ intmax_t nanosecs = mach_absolute_time()*info.numer/info.denom;
+ return time_spec_t_from_counts(nanosecs, intmax_t(1e9));
}
#endif /* TIME_SPEC_USE_MACH_ABSOLUTE_TIME */