aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/types/sid.hpp72
-rw-r--r--host/include/uhd/utils/atomic.hpp70
2 files changed, 38 insertions, 104 deletions
diff --git a/host/include/uhd/types/sid.hpp b/host/include/uhd/types/sid.hpp
index 9ac68f7d0..f1471549e 100644
--- a/host/include/uhd/types/sid.hpp
+++ b/host/include/uhd/types/sid.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2014 Ettus Research LLC
+// Copyright 2014-2016 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -19,9 +19,8 @@
#define INCLUDED_UHD_TYPES_SID_HPP
#include <uhd/config.hpp>
-#include <boost/cstdint.hpp>
-#include <boost/shared_ptr.hpp>
#include <iostream>
+#include <stdint.h>
namespace uhd {
/*!
@@ -82,9 +81,9 @@ namespace uhd {
//! Create an unset SID
sid_t();
//! Create a sid_t object from a 32-Bit SID value
- sid_t(boost::uint32_t sid);
+ sid_t(uint32_t sid);
//! Create a sid_t object from its four components
- sid_t(boost::uint8_t src_addr, boost::uint8_t src_ep, boost::uint8_t dst_addr, boost::uint8_t dst_ep);
+ sid_t(uint8_t src_addr, uint8_t src_ep, uint8_t dst_addr, uint8_t dst_ep);
//! Convert a string representation of a SID into its numerical representation
sid_t(const std::string &);
@@ -99,83 +98,83 @@ namespace uhd {
// Getters
//
//! Alias for get_sid()
- UHD_INLINE boost::uint32_t get() const { return get_sid(); };
+ inline uint32_t get() const { return get_sid(); };
//! Returns a 32-Bit representation of the SID if set, or zero otherwise.
- UHD_INLINE boost::uint32_t get_sid() const { return _set ? _sid : 0; };
+ inline uint32_t get_sid() const { return _set ? _sid : 0; };
//! Return the 16-bit source address of this SID
- UHD_INLINE boost::uint32_t get_src() const {
+ inline uint32_t get_src() const {
return (_sid >> 16) & 0xFFFF;
}
//! Return the 16-bit destination address of this SID
- UHD_INLINE boost::uint32_t get_dst() const {
+ inline uint32_t get_dst() const {
return _sid & 0xFFFF;
}
//! Return 8-bit address of the source
- UHD_INLINE boost::uint32_t get_src_addr() const {
+ inline uint32_t get_src_addr() const {
return (get_src() >> 8) & 0xFF;
}
//! Return endpoint of the source
- UHD_INLINE boost::uint32_t get_src_endpoint() const {
+ inline uint32_t get_src_endpoint() const {
return get_src() & 0xFF;
}
//! Return crossbar port of the source
- UHD_INLINE boost::uint32_t get_src_xbarport() const {
+ inline uint32_t get_src_xbarport() const {
return (get_src_endpoint() >> 4) & 0xF;
}
//! Return block port of the source
- UHD_INLINE boost::uint32_t get_src_blockport() const {
+ inline uint32_t get_src_blockport() const {
return (get_src_endpoint()) & 0xF;
}
//! Return 8-bit address of the destination
- UHD_INLINE boost::uint32_t get_dst_addr() const {
+ inline uint32_t get_dst_addr() const {
return (get_dst() >> 8) & 0xFF;
}
//! Return endpoint of the destination
- UHD_INLINE boost::uint32_t get_dst_endpoint() const {
+ inline uint32_t get_dst_endpoint() const {
return get_dst() & 0xFF;
}
//! Return crossbar port of the source
- UHD_INLINE boost::uint32_t get_dst_xbarport() const {
+ inline uint32_t get_dst_xbarport() const {
return (get_dst_endpoint() >> 4) & 0xF;
}
//! Return block port of the source
- UHD_INLINE boost::uint32_t get_dst_blockport() const {
+ inline uint32_t get_dst_blockport() const {
return (get_dst_endpoint()) & 0xF;
}
// Setters
//! Alias for set_sid()
- void set(boost::uint32_t new_sid) { set_sid(new_sid); };
+ void set(uint32_t new_sid) { set_sid(new_sid); };
//! Convert a string representation of a SID into a numerical one
// Throws uhd::value_error if the string is not a valid SID
// representation.
void set_from_str(const std::string &);
- void set_sid(boost::uint32_t new_sid);
+ void set_sid(uint32_t new_sid);
//! Set the source address of this SID
// (the first 16 Bits)
- void set_src(boost::uint32_t new_addr);
+ void set_src(uint32_t new_addr);
//! Set the destination address of this SID
// (the last 16 Bits)
- void set_dst(boost::uint32_t new_addr);
- void set_src_addr(boost::uint32_t new_addr);
- void set_src_endpoint(boost::uint32_t new_addr);
- void set_dst_addr(boost::uint32_t new_addr);
- void set_dst_endpoint(boost::uint32_t new_addr);
- void set_dst_xbarport(boost::uint32_t new_xbarport);
- void set_dst_blockport(boost::uint32_t new_blockport);
+ void set_dst(uint32_t new_addr);
+ void set_src_addr(uint32_t new_addr);
+ void set_src_endpoint(uint32_t new_addr);
+ void set_dst_addr(uint32_t new_addr);
+ void set_dst_endpoint(uint32_t new_addr);
+ void set_dst_xbarport(uint32_t new_xbarport);
+ void set_dst_blockport(uint32_t new_blockport);
// Manipulators
//! Swaps dst and src address and returns the new SID.
- sid_t reversed();
+ sid_t reversed() const;
- //! Swaps dst and src in-place.
+ //! Swaps dst and src in-place. This modifies the current SID.
void reverse();
// Overloaded operators
- sid_t operator = (boost::uint32_t new_sid) {
+ sid_t operator = (const uint32_t new_sid) {
set_sid(new_sid);
return *this;
}
@@ -185,6 +184,11 @@ namespace uhd {
return *this;
}
+ sid_t operator = (const sid_t &sid) {
+ set_sid(sid.get_sid());
+ return *this;
+ }
+
sid_t operator = (const std::string &sid_str) {
set_from_str(sid_str);
return *this;
@@ -194,7 +198,7 @@ namespace uhd {
return (not _set and not sid.is_set()) or (_sid == sid.get_sid());
}
- bool operator == (boost::uint32_t sid) const {
+ bool operator == (uint32_t sid) const {
return _set and _sid == sid;
}
@@ -208,7 +212,7 @@ namespace uhd {
//! If the SID is not set, always returns zero.
// Use is_set() to check if the return value is valid.
- operator boost::uint32_t() const {
+ operator uint32_t() const {
return get();
}
@@ -217,12 +221,12 @@ namespace uhd {
}
private:
- boost::uint32_t _sid;
+ uint32_t _sid;
bool _set;
};
//! Stream output operator. Honors std::ios::hex.
- UHD_INLINE std::ostream& operator<< (std::ostream& out, const sid_t &sid) {
+ inline std::ostream& operator<< (std::ostream& out, const sid_t &sid) {
std::ios_base::fmtflags ff = out.flags();
if (ff & std::ios::hex) {
out << sid.to_pp_string_hex();
diff --git a/host/include/uhd/utils/atomic.hpp b/host/include/uhd/utils/atomic.hpp
index 8c5e6a5da..8da71b359 100644
--- a/host/include/uhd/utils/atomic.hpp
+++ b/host/include/uhd/utils/atomic.hpp
@@ -68,76 +68,6 @@ namespace uhd{
};
/*!
- * A reusable barrier to sync multiple threads.
- * All threads spin on wait() until count is reset.
- */
- class UHD_API reusable_barrier{
- public:
-
- reusable_barrier():_size (0) {}
-
- reusable_barrier(const size_t size):_size(size) {}
-
- //! Resize the barrier for N threads
- void resize(const size_t size){
- _size = size;
- }
-
- /*!
- * Force the barrier wait to throw a boost::thread_interrupted
- * The threads were not getting the interruption_point on windows.
- */
- void interrupt(void)
- {
- _done.inc();
- }
-
- //! Wait on the barrier condition
- UHD_INLINE void wait(void)
- {
- if (_size == 1) return;
-
- //entry barrier with condition variable
- _entry_counter.inc();
- _entry_counter.cas(0, _size);
- boost::mutex::scoped_lock lock(_mutex);
- while (_entry_counter.read() != 0)
- {
- this->check_interrupt();
- _cond.timed_wait(lock, boost::posix_time::milliseconds(1));
- }
- lock.unlock(); //unlock before notify
- _cond.notify_one();
-
- //exit barrier to ensure known condition of entry count
- _exit_counter.inc();
- _exit_counter.cas(0, _size);
- while (_exit_counter.read() != 0) this->check_interrupt();
- }
-
- //! Wait on the barrier condition
- UHD_INLINE void wait_others(void)
- {
- while (_entry_counter.read() != (_size-1)) this->check_interrupt();
- }
-
- private:
- size_t _size;
- atomic_uint32_t _entry_counter;
- atomic_uint32_t _exit_counter;
- atomic_uint32_t _done;
- boost::mutex _mutex;
- boost::condition_variable _cond;
-
- UHD_INLINE void check_interrupt(void)
- {
- if (_done.read() != 0) throw boost::thread_interrupted();
- boost::this_thread::interruption_point();
- boost::this_thread::yield();
- }
- };
-
- /*!
* Spin-wait on a condition with a timeout.
* \param cond an atomic variable to compare
* \param value compare to atomic for true/false