aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-02-13 19:22:26 -0800
committerJosh Blum <josh@joshknows.com>2012-02-13 19:22:26 -0800
commitdf946523010929944cab487669defec2059951d4 (patch)
tree4df93be018f4c0c10bbdb264df1a6529e891ef45 /host
parent4a27f6e4bdad5e4de743e77f0a998dbe1e852cf0 (diff)
downloaduhd-df946523010929944cab487669defec2059951d4.tar.gz
uhd-df946523010929944cab487669defec2059951d4.tar.bz2
uhd-df946523010929944cab487669defec2059951d4.zip
uhd: inline time spec accessors for minor improvement
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/types/time_spec.hpp8
-rw-r--r--host/lib/types/time_spec.cpp25
2 files changed, 18 insertions, 15 deletions
diff --git a/host/include/uhd/types/time_spec.hpp b/host/include/uhd/types/time_spec.hpp
index cf8588c5b..e7d7d5ab4 100644
--- a/host/include/uhd/types/time_spec.hpp
+++ b/host/include/uhd/types/time_spec.hpp
@@ -128,6 +128,14 @@ namespace uhd{
//! Implement less_than_comparable interface
UHD_API bool operator<(const time_spec_t &, const time_spec_t &);
+ UHD_INLINE time_t time_spec_t::get_full_secs(void) const{
+ return this->_full_secs;
+ }
+
+ UHD_INLINE double time_spec_t::get_frac_secs(void) const{
+ return this->_frac_secs;
+ }
+
} //namespace uhd
#endif /* INCLUDED_UHD_TYPES_TIME_SPEC_HPP */
diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp
index 0c3a3dbea..14b9c988a 100644
--- a/host/lib/types/time_spec.cpp
+++ b/host/lib/types/time_spec.cpp
@@ -72,8 +72,11 @@ time_spec_t time_spec_t::get_system_time(void){
* Time spec constructors
**********************************************************************/
#define time_spec_init(full, frac) { \
- _full_secs = full + time_t(frac); \
- _frac_secs = frac - time_t(frac); \
+ const time_t _full = time_t(full); \
+ const double _frac = double(frac); \
+ const int _frac_int = int(_frac); \
+ _full_secs = _full + _frac_int; \
+ _frac_secs = _frac - _frac_int; \
if (_frac_secs < 0) {\
_full_secs -= 1; \
_frac_secs += 1; \
@@ -115,15 +118,7 @@ long long time_spec_t::to_ticks(double tick_rate) const{
}
double time_spec_t::get_real_secs(void) const{
- return this->_full_secs + this->_frac_secs;
-}
-
-time_t time_spec_t::get_full_secs(void) const{
- return this->_full_secs;
-}
-
-double time_spec_t::get_frac_secs(void) const{
- return this->_frac_secs;
+ return this->get_full_secs() + this->get_frac_secs();
}
/***********************************************************************
@@ -131,16 +126,16 @@ double time_spec_t::get_frac_secs(void) const{
**********************************************************************/
time_spec_t &time_spec_t::operator+=(const time_spec_t &rhs){
time_spec_init(
- this->_full_secs + rhs.get_full_secs(),
- this->_frac_secs + rhs.get_frac_secs()
+ this->get_full_secs() + rhs.get_full_secs(),
+ this->get_frac_secs() + rhs.get_frac_secs()
);
return *this;
}
time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){
time_spec_init(
- this->_full_secs - rhs.get_full_secs(),
- this->_frac_secs - rhs.get_frac_secs()
+ this->get_full_secs() - rhs.get_full_secs(),
+ this->get_frac_secs() - rhs.get_frac_secs()
);
return *this;
}