From d46058d75c723402d7d135ff309afe4f00deca0c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 31 Jan 2011 15:25:13 -0800 Subject: uhd: simplify the mach time usage based on example from web --- host/lib/types/time_spec.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'host/lib/types') 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 -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 */ -- cgit v1.2.3