uhd: simplify the mach time usage based on example from web

This commit is contained in:
Josh Blum 2011-01-31 15:25:13 -08:00
parent a7d7e0d289
commit d46058d75c

View file

@ -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 */