From 1fe98e8701dd0b790b172762c3629db32956d1fc Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 28 Sep 2019 11:18:57 +0200 Subject: uhd: Replace usage of boost smart pointers with C++11 counterparts This removes the following Boost constructs: - boost::shared_ptr, boost::weak_ptr - boost::enable_shared_from_this - boost::static_pointer_cast, boost::dynamic_pointer_cast The appropriate includes were also removed. All C++11 versions of these require #include . Note that the stdlib and Boost versions have the exact same syntax, they only differ in the namespace (boost vs. std). The modifications were all done using sed, with the exception of boost::scoped_ptr, which was replaced by std::unique_ptr. References to boost::smart_ptr were also removed. boost::intrusive_ptr is not removed in this commit, since it does not have a 1:1 mapping to a C++11 construct. --- host/lib/usrp/b200/b200_cores.hpp | 6 +++--- host/lib/usrp/b200/b200_iface.hpp | 4 ++-- host/lib/usrp/b200/b200_impl.cpp | 11 +++++----- host/lib/usrp/b200/b200_impl.hpp | 22 ++++++++++---------- host/lib/usrp/b200/b200_io_impl.cpp | 40 ++++++++++++++++++------------------- host/lib/usrp/b200/b200_uart.hpp | 4 ++-- 6 files changed, 43 insertions(+), 44 deletions(-) (limited to 'host/lib/usrp/b200') diff --git a/host/lib/usrp/b200/b200_cores.hpp b/host/lib/usrp/b200/b200_cores.hpp index 7dabb66e9..324938a73 100644 --- a/host/lib/usrp/b200/b200_cores.hpp +++ b/host/lib/usrp/b200/b200_cores.hpp @@ -12,13 +12,13 @@ #include #include #include -#include +#include #include class b200_local_spi_core : uhd::noncopyable, public uhd::spi_iface { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; enum perif_t { CODEC, PLL @@ -47,7 +47,7 @@ private: class b200_ref_pll_ctrl : public uhd::usrp::adf4001_ctrl { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; b200_ref_pll_ctrl(b200_local_spi_core::sptr spi); virtual void set_lock_to_ext_ref(bool external); diff --git a/host/lib/usrp/b200/b200_iface.hpp b/host/lib/usrp/b200/b200_iface.hpp index 4389d4eed..a3059bacf 100644 --- a/host/lib/usrp/b200/b200_iface.hpp +++ b/host/lib/usrp/b200/b200_iface.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -79,7 +79,7 @@ static const uhd::dict B2XX_FPGA_FILE_NAME = boost: class UHD_API b200_iface: uhd::noncopyable, public virtual uhd::i2c_iface { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * Make a b200 interface object from a control transport diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 1be8c263b..be21ade63 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -20,8 +20,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -255,7 +254,7 @@ static device::sptr b200_make(const device_addr_t &device_addr) catch (const uhd::usb_error &) { UHD_LOGGER_INFO("B200") << "Detected bad USB state; resetting." ; libusb::device_handle::sptr dev_handle(libusb::device_handle::get_cached_handle( - boost::static_pointer_cast(handle)->get_device() + std::static_pointer_cast(handle)->get_device() )); dev_handle->clear_endpoints(B200_USB_CTRL_RECV_ENDPOINT, B200_USB_CTRL_SEND_ENDPOINT); dev_handle->clear_endpoints(B200_USB_DATA_RECV_ENDPOINT, B200_USB_DATA_SEND_ENDPOINT); @@ -578,7 +577,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// _spi_iface = b200_local_spi_core::make(_local_ctrl); if (not (_product == B200MINI or _product == B205MINI)) { - _adf4001_iface = boost::make_shared(_spi_iface); + _adf4001_iface = std::make_shared(_spi_iface); } //////////////////////////////////////////////////////////////////// @@ -588,9 +587,9 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s reset_codec(); ad9361_params::sptr client_settings; if (_product == B200MINI or _product == B205MINI) { - client_settings = boost::make_shared(); + client_settings = std::make_shared(); } else { - client_settings = boost::make_shared(); + client_settings = std::make_shared(); } _codec_ctrl = ad9361_ctrl::make_spi(client_settings, _spi_iface, AD9361_SLAVENO); diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index 6e777d4d6..bd44aa14f 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -36,8 +36,8 @@ #include #include #include -#include #include +#include static const uint8_t B200_FW_COMPAT_NUM_MAJOR = 8; static const uint8_t B200_FW_COMPAT_NUM_MINOR = 0; @@ -138,7 +138,7 @@ private: uhd::usrp::ad9361_ctrl::sptr _codec_ctrl; uhd::usrp::ad936x_manager::sptr _codec_mgr; b200_local_spi_core::sptr _spi_iface; - boost::shared_ptr _adf4001_iface; + std::shared_ptr _adf4001_iface; uhd::gps_ctrl::sptr _gps; //transports @@ -146,8 +146,8 @@ private: uhd::transport::zero_copy_if::sptr _ctrl_transport; uhd::usrp::recv_packet_demuxer_3000::sptr _demux; - boost::weak_ptr _rx_streamer; - boost::weak_ptr _tx_streamer; + std::weak_ptr _rx_streamer; + std::weak_ptr _tx_streamer; std::mutex _transport_setup_mutex; @@ -156,13 +156,13 @@ private: typedef uhd::transport::bounded_buffer async_md_type; struct AsyncTaskData { - boost::shared_ptr async_md; - boost::weak_ptr local_ctrl; - boost::weak_ptr radio_ctrl[2]; + std::shared_ptr async_md; + std::weak_ptr local_ctrl; + std::weak_ptr radio_ctrl[2]; b200_uart::sptr gpsdo_uart; }; - boost::shared_ptr _async_task_data; - boost::optional handle_async_task(uhd::transport::zero_copy_if::sptr, boost::shared_ptr); + std::shared_ptr _async_task_data; + boost::optional handle_async_task(uhd::transport::zero_copy_if::sptr, std::shared_ptr); void register_loopback_self_test(uhd::wb_iface::sptr iface); void set_mb_eeprom(const uhd::usrp::mboard_eeprom_t &); @@ -191,8 +191,8 @@ private: rx_dsp_core_3000::sptr ddc; tx_vita_core_3000::sptr deframer; tx_dsp_core_3000::sptr duc; - boost::weak_ptr rx_streamer; - boost::weak_ptr tx_streamer; + std::weak_ptr rx_streamer; + std::weak_ptr tx_streamer; user_settings_core_3000::sptr user_settings; bool ant_rx2; }; diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index 5a0de430f..88cde6071 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include using namespace uhd; @@ -37,15 +37,15 @@ size_t b200_impl::max_chan_count(const std::string& direction /* = "" */) for (radio_perifs_t& perif : _radio_perifs) { if ((direction == "RX" or direction.empty()) and not perif.rx_streamer.expired()) { - boost::shared_ptr rx_streamer = - boost::dynamic_pointer_cast( + std::shared_ptr rx_streamer = + std::dynamic_pointer_cast( perif.rx_streamer.lock()); max_count = std::max(max_count, rx_streamer->get_num_channels()); } if ((direction == "TX" or direction.empty()) and not perif.tx_streamer.expired()) { - boost::shared_ptr tx_streamer = - boost::dynamic_pointer_cast( + std::shared_ptr tx_streamer = + std::dynamic_pointer_cast( perif.tx_streamer.lock()); max_count = std::max(max_count, tx_streamer->get_num_channels()); } @@ -142,16 +142,16 @@ void b200_impl::update_tick_rate(const double new_tick_rate) check_tick_rate_with_current_streamers(new_tick_rate); for (radio_perifs_t& perif : _radio_perifs) { - boost::shared_ptr my_streamer = - boost::dynamic_pointer_cast( + std::shared_ptr my_streamer = + std::dynamic_pointer_cast( perif.rx_streamer.lock()); if (my_streamer) my_streamer->set_tick_rate(new_tick_rate); perif.framer->set_tick_rate(new_tick_rate); } for (radio_perifs_t& perif : _radio_perifs) { - boost::shared_ptr my_streamer = - boost::dynamic_pointer_cast( + std::shared_ptr my_streamer = + std::dynamic_pointer_cast( perif.tx_streamer.lock()); if (my_streamer) my_streamer->set_tick_rate(new_tick_rate); @@ -204,8 +204,8 @@ double b200_impl::coerce_rx_samp_rate( void b200_impl::update_rx_samp_rate(const size_t dspno, const double rate) { - boost::shared_ptr my_streamer = - boost::dynamic_pointer_cast( + std::shared_ptr my_streamer = + std::dynamic_pointer_cast( _radio_perifs[dspno].rx_streamer.lock()); if (not my_streamer) return; @@ -231,8 +231,8 @@ double b200_impl::coerce_tx_samp_rate( void b200_impl::update_tx_samp_rate(const size_t dspno, const double rate) { - boost::shared_ptr my_streamer = - boost::dynamic_pointer_cast( + std::shared_ptr my_streamer = + std::dynamic_pointer_cast( _radio_perifs[dspno].tx_streamer.lock()); if (not my_streamer) return; @@ -314,7 +314,7 @@ bool b200_impl::recv_async_msg(async_metadata_t& async_metadata, double timeout) * there. */ boost::optional b200_impl::handle_async_task( - uhd::transport::zero_copy_if::sptr xport, boost::shared_ptr data) + uhd::transport::zero_copy_if::sptr xport, std::shared_ptr data) { managed_recv_buffer::sptr buff = xport->get_recv_buff(); if (not buff or buff->size() < 8) @@ -405,7 +405,7 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t& args_) } check_streamer_args(args, this->get_tick_rate(), "RX"); - boost::shared_ptr my_streamer; + std::shared_ptr my_streamer; for (size_t stream_i = 0; stream_i < args.channels.size(); stream_i++) { const size_t radio_index = _tree->access>("/mboards/0/rx_chan_dsp_mapping") @@ -437,7 +437,7 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t& args_) // make the new streamer given the samples per packet if (not my_streamer) - my_streamer = boost::make_shared(spp); + my_streamer = std::make_shared(spp); my_streamer->resize(args.channels.size()); // init some streamer stuff @@ -480,8 +480,8 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t& args_) void b200_impl::handle_overflow(const size_t radio_index) { - boost::shared_ptr my_streamer = - boost::dynamic_pointer_cast( + std::shared_ptr my_streamer = + std::dynamic_pointer_cast( _radio_perifs[radio_index].rx_streamer.lock()); if (my_streamer->get_num_channels() == 2) // MIMO time { @@ -527,7 +527,7 @@ tx_streamer::sptr b200_impl::get_tx_stream(const uhd::stream_args_t& args_) } check_streamer_args(args, this->get_tick_rate(), "TX"); - boost::shared_ptr my_streamer; + std::shared_ptr my_streamer; for (size_t stream_i = 0; stream_i < args.channels.size(); stream_i++) { const size_t radio_index = _tree->access>("/mboards/0/tx_chan_dsp_mapping") @@ -556,7 +556,7 @@ tx_streamer::sptr b200_impl::get_tx_stream(const uhd::stream_args_t& args_) // make the new streamer given the samples per packet if (not my_streamer) - my_streamer = boost::make_shared(spp); + my_streamer = std::make_shared(spp); my_streamer->resize(args.channels.size()); // init some streamer stuff diff --git a/host/lib/usrp/b200/b200_uart.hpp b/host/lib/usrp/b200/b200_uart.hpp index 25dc1171e..c6de5f844 100644 --- a/host/lib/usrp/b200/b200_uart.hpp +++ b/host/lib/usrp/b200/b200_uart.hpp @@ -12,12 +12,12 @@ #include #include //uart iface #include -#include +#include class b200_uart: uhd::noncopyable, public uhd::uart_iface { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; static sptr make(uhd::transport::zero_copy_if::sptr, const uint32_t sid); virtual void handle_uart_packet(uhd::transport::managed_recv_buffer::sptr buff) = 0; }; -- cgit v1.2.3