From d4eaee390db2fefd4564b6054d8d066c437d8cff Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 6 Apr 2018 11:36:04 -0700 Subject: lib: move atomic.hpp and system_time.hpp to uhdlib --- host/lib/include/uhd/utils/atomic.hpp | 74 ---------------------- host/lib/include/uhd/utils/system_time.hpp | 18 ------ .../usrp/common/recv_packet_demuxer_3000.hpp | 2 +- host/lib/include/uhdlib/utils/atomic.hpp | 74 ++++++++++++++++++++++ host/lib/include/uhdlib/utils/system_time.hpp | 18 ++++++ host/lib/transport/nirio_zero_copy.cpp | 2 +- host/lib/transport/tcp_zero_copy.cpp | 2 +- host/lib/transport/udp_zero_copy.cpp | 2 +- host/lib/usrp/b100/usb_zero_copy_wrapper.cpp | 2 +- host/lib/usrp/e300/e300_fifo_config.cpp | 4 +- host/lib/usrp/usrp1/soft_time_ctrl.cpp | 2 +- host/lib/usrp/x300/x300_dac_ctrl.cpp | 2 +- host/lib/utils/system_time.cpp | 2 +- 13 files changed, 102 insertions(+), 102 deletions(-) delete mode 100644 host/lib/include/uhd/utils/atomic.hpp delete mode 100644 host/lib/include/uhd/utils/system_time.hpp create mode 100644 host/lib/include/uhdlib/utils/atomic.hpp create mode 100644 host/lib/include/uhdlib/utils/system_time.hpp (limited to 'host/lib') diff --git a/host/lib/include/uhd/utils/atomic.hpp b/host/lib/include/uhd/utils/atomic.hpp deleted file mode 100644 index 86b1dddda..000000000 --- a/host/lib/include/uhd/utils/atomic.hpp +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright 2012-2013,2016-2017 Ettus Research LLC -// Copyright 2018 Ettus Research, a National Instruments Company -// -// SPDX-License-Identifier: GPL-3.0-or-later -// - -#ifndef INCLUDED_UHD_UTILS_ATOMIC_HPP -#define INCLUDED_UHD_UTILS_ATOMIC_HPP - -#include -#include -#include -#include -#include - -namespace uhd{ - - /*! DEPRECATED -- Will be removed in coming versions of UHD. - * - * Spin-wait on a condition with a timeout. - * \param cond an atomic variable to compare - * \param value compare to atomic for true/false - * \param timeout the timeout in seconds - * \return true for cond == value, false for timeout - */ - template - UHD_INLINE bool spin_wait_with_timeout( - std::atomic &cond, - const T value, - const double timeout - ){ - if (cond == value) return true; - const time_spec_t exit_time = uhd::get_system_time() + time_spec_t(timeout); - while (cond != value) { - if (uhd::get_system_time() > exit_time) { - return false; - } - boost::this_thread::interruption_point(); - boost::this_thread::yield(); - } - return true; - } - - /*! DEPRECATED -- Will be removed in coming versions of UHD. - * - * Claimer class to provide synchronization for multi-thread access. - * Claiming enables buffer classes to be used with a buffer queue. - */ - class simple_claimer{ - public: - simple_claimer(void){ - this->release(); - } - - UHD_INLINE void release(void){ - _locked = false; - } - - UHD_INLINE bool claim_with_wait(const double timeout){ - if (spin_wait_with_timeout(_locked, false, timeout)){ - _locked = true; - return true; - } - return false; - } - - private: - std::atomic _locked; - }; - -} //namespace uhd - -#endif /* INCLUDED_UHD_UTILS_ATOMIC_HPP */ diff --git a/host/lib/include/uhd/utils/system_time.hpp b/host/lib/include/uhd/utils/system_time.hpp deleted file mode 100644 index 30cd5a673..000000000 --- a/host/lib/include/uhd/utils/system_time.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// -// Copyright 2017 Ettus Research (National Instruments Corp.) -// -// SPDX-License-Identifier: GPL-3.0+ -// - -#include - -namespace uhd { - - /*! - * Get the system time in time_spec_t format. - * Uses the highest precision clock available. - * \return the system time as a time_spec_t - */ - time_spec_t get_system_time(void); - -}; /* namespace uhd */ diff --git a/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp b/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp index 74807741f..3a17b864e 100644 --- a/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp +++ b/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp @@ -8,7 +8,7 @@ #ifndef INCLUDED_LIBUHD_USRP_COMMON_RECV_PACKET_DEMUXER_3000_HPP #define INCLUDED_LIBUHD_USRP_COMMON_RECV_PACKET_DEMUXER_3000_HPP -#include +#include #include #include #include diff --git a/host/lib/include/uhdlib/utils/atomic.hpp b/host/lib/include/uhdlib/utils/atomic.hpp new file mode 100644 index 000000000..5436eea81 --- /dev/null +++ b/host/lib/include/uhdlib/utils/atomic.hpp @@ -0,0 +1,74 @@ +// +// Copyright 2012-2013,2016-2017 Ettus Research LLC +// Copyright 2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_UHD_UTILS_ATOMIC_HPP +#define INCLUDED_UHD_UTILS_ATOMIC_HPP + +#include +#include +#include +#include +#include + +namespace uhd{ + + /*! DEPRECATED -- Will be removed in coming versions of UHD. + * + * Spin-wait on a condition with a timeout. + * \param cond an atomic variable to compare + * \param value compare to atomic for true/false + * \param timeout the timeout in seconds + * \return true for cond == value, false for timeout + */ + template + UHD_INLINE bool spin_wait_with_timeout( + std::atomic &cond, + const T value, + const double timeout + ){ + if (cond == value) return true; + const time_spec_t exit_time = uhd::get_system_time() + time_spec_t(timeout); + while (cond != value) { + if (uhd::get_system_time() > exit_time) { + return false; + } + boost::this_thread::interruption_point(); + boost::this_thread::yield(); + } + return true; + } + + /*! DEPRECATED -- Will be removed in coming versions of UHD. + * + * Claimer class to provide synchronization for multi-thread access. + * Claiming enables buffer classes to be used with a buffer queue. + */ + class simple_claimer{ + public: + simple_claimer(void){ + this->release(); + } + + UHD_INLINE void release(void){ + _locked = false; + } + + UHD_INLINE bool claim_with_wait(const double timeout){ + if (spin_wait_with_timeout(_locked, false, timeout)){ + _locked = true; + return true; + } + return false; + } + + private: + std::atomic _locked; + }; + +} //namespace uhd + +#endif /* INCLUDED_UHD_UTILS_ATOMIC_HPP */ diff --git a/host/lib/include/uhdlib/utils/system_time.hpp b/host/lib/include/uhdlib/utils/system_time.hpp new file mode 100644 index 000000000..30cd5a673 --- /dev/null +++ b/host/lib/include/uhdlib/utils/system_time.hpp @@ -0,0 +1,18 @@ +// +// Copyright 2017 Ettus Research (National Instruments Corp.) +// +// SPDX-License-Identifier: GPL-3.0+ +// + +#include + +namespace uhd { + + /*! + * Get the system time in time_spec_t format. + * Uses the highest precision clock available. + * \return the system time as a time_spec_t + */ + time_spec_t get_system_time(void); + +}; /* namespace uhd */ diff --git a/host/lib/transport/nirio_zero_copy.cpp b/host/lib/transport/nirio_zero_copy.cpp index 6ef83ee83..418e78d09 100644 --- a/host/lib/transport/nirio_zero_copy.cpp +++ b/host/lib/transport/nirio_zero_copy.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/host/lib/transport/tcp_zero_copy.cpp b/host/lib/transport/tcp_zero_copy.cpp index 5a5937c13..ddbc6b786 100644 --- a/host/lib/transport/tcp_zero_copy.cpp +++ b/host/lib/transport/tcp_zero_copy.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include //sleep diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp index de1405a38..dc87d7e4c 100644 --- a/host/lib/transport/udp_zero_copy.cpp +++ b/host/lib/transport/udp_zero_copy.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include //sleep diff --git a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp index 7efd061c0..54c367077 100644 --- a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp +++ b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/usrp/e300/e300_fifo_config.cpp b/host/lib/usrp/e300/e300_fifo_config.cpp index c02c943dd..044ce01ee 100644 --- a/host/lib/usrp/e300/e300_fifo_config.cpp +++ b/host/lib/usrp/e300/e300_fifo_config.cpp @@ -7,7 +7,7 @@ #ifdef E300_NATIVE -#include +#include #include #include #include @@ -78,7 +78,7 @@ static UHD_INLINE size_t ZF_STREAM_OFF(const size_t which) #include //sleep #include //timeout #include -#include +#include //locking stuff for shared irq #include diff --git a/host/lib/usrp/usrp1/soft_time_ctrl.cpp b/host/lib/usrp/usrp1/soft_time_ctrl.cpp index 061075e32..851f0f507 100644 --- a/host/lib/usrp/usrp1/soft_time_ctrl.cpp +++ b/host/lib/usrp/usrp1/soft_time_ctrl.cpp @@ -6,7 +6,7 @@ // #include "soft_time_ctrl.hpp" -#include +#include #include #include #include diff --git a/host/lib/usrp/x300/x300_dac_ctrl.cpp b/host/lib/usrp/x300/x300_dac_ctrl.cpp index 400e48282..c200a696a 100644 --- a/host/lib/usrp/x300/x300_dac_ctrl.cpp +++ b/host/lib/usrp/x300/x300_dac_ctrl.cpp @@ -7,7 +7,7 @@ #include "x300_dac_ctrl.hpp" #include "x300_regs.hpp" -#include +#include #include #include #include diff --git a/host/lib/utils/system_time.cpp b/host/lib/utils/system_time.cpp index d371756bc..2434eb949 100644 --- a/host/lib/utils/system_time.cpp +++ b/host/lib/utils/system_time.cpp @@ -4,7 +4,7 @@ // SPDX-License-Identifier: GPL-3.0+ // -#include +#include using namespace uhd; -- cgit v1.2.3