Skip to content

Commit

Permalink
uhd: branch-less round for time spec convert to ticks
Browse files Browse the repository at this point in the history
This fixes valgrind warnings with branching on unit'd values,
and possible exceptions thrown on bad unit'd values.

As it turns out, sometimes tick_rate was passed unit'd,
however, the value calculated was not of consequence.

Also, iround was overkill because we dont need to handle
negative tick rates or frac seconds, or bounds checking.
  • Loading branch information
guruofquality committed Jan 31, 2012
1 parent e30cf4e commit 5b06adb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions host/lib/types/time_spec.cpp
Expand Up @@ -16,7 +16,6 @@
//

#include <uhd/types/time_spec.hpp>
#include <boost/math/special_functions/round.hpp>

using namespace uhd;

Expand Down Expand Up @@ -109,7 +108,7 @@ time_spec_t::time_spec_t(time_t full_secs, long tick_count, double tick_rate){
* Time spec accessors
**********************************************************************/
long time_spec_t::get_tick_count(double tick_rate) const{
return boost::math::iround(this->get_frac_secs()*tick_rate);
return long(this->get_frac_secs()*tick_rate + 0.5);
}

double time_spec_t::get_real_secs(void) const{
Expand Down

0 comments on commit 5b06adb

Please sign in to comment.