aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/types.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-24 18:55:08 -0700
committerJosh Blum <josh@joshknows.com>2010-06-24 18:55:08 -0700
commitfadd3a44a84e061412accd35c1c97db820190df8 (patch)
tree3bae768f567858b6dc61f24cd643819c9c9c2380 /host/lib/types.cpp
parente74356ec5956d10d399969851fefd4a1f308ad7c (diff)
downloaduhd-fadd3a44a84e061412accd35c1c97db820190df8.tar.gz
uhd-fadd3a44a84e061412accd35c1c97db820190df8.tar.bz2
uhd-fadd3a44a84e061412accd35c1c97db820190df8.zip
uhd: created benchmark rx example app
Made mods to time spec to support math operators.
Diffstat (limited to 'host/lib/types.cpp')
-rw-r--r--host/lib/types.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
index daf3be7f7..78a3d22ce 100644
--- a/host/lib/types.cpp
+++ b/host/lib/types.cpp
@@ -120,6 +120,11 @@ tx_metadata_t::tx_metadata_t(void):
/***********************************************************************
* time spec
**********************************************************************/
+static inline void time_spec_normalize(time_spec_t &time_spec){
+ time_spec.secs += boost::uint32_t(std::ceil(time_spec.nsecs/1e9));
+ time_spec.nsecs = std::fmod(time_spec.nsecs, 1e9);
+}
+
time_spec_t::time_spec_t(boost::uint32_t secs, double nsecs):
secs(secs),
nsecs(nsecs)
@@ -127,6 +132,13 @@ time_spec_t::time_spec_t(boost::uint32_t secs, double nsecs):
/* NOP */
}
+time_spec_t::time_spec_t(boost::uint32_t secs, boost::uint32_t ticks, double tick_rate):
+ secs(secs),
+ nsecs(double(ticks)*1e9/tick_rate)
+{
+ /* NOP */
+}
+
boost::uint32_t time_spec_t::get_ticks(double tick_rate) const{
return boost::math::iround(nsecs*tick_rate*1e-9);
}
@@ -135,6 +147,22 @@ void time_spec_t::set_ticks(boost::uint32_t ticks, double tick_rate){
nsecs = double(ticks)*1e9/tick_rate;
}
+time_spec_t &time_spec_t::operator+=(const time_spec_t &rhs){
+ this->secs += rhs.secs;
+ this->nsecs += rhs.nsecs;
+ return *this;
+}
+
+time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){
+ this->secs -= rhs.secs;
+ this->nsecs -= rhs.nsecs;
+ return *this;
+}
+
+bool uhd::operator==(const time_spec_t &lhs, const time_spec_t &rhs){
+ return lhs.secs == rhs.secs and lhs.nsecs == rhs.nsecs;
+}
+
/***********************************************************************
* device addr
**********************************************************************/