From d3a16b702230534f7265613a73204bdb051a458e Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 16 Oct 2019 16:21:19 -0700 Subject: uhd: Replace all occurrences of boost::bind with std::bind Note: Replacing everything with a lambda would be even better, but that can't be easily scripted so we'll do this as a first step to reduce the Boost footprint. This also removes occurences of #include , and makes sure all usages of std::bind have an #include . clang-format wasn't always applied to minimize the changeset in this commit, however, it was applied to the blocks of #includes. Due to conflicts with other Boost libraries, the placeholders _1, _2, etc. could not be directly used, but had to be explicitly called out (as std::placeholders::_1, etc.). This makes the use of std::bind even uglier, which serves as another reminder that using std::bind (and even more so, boost::bind) should be avoided. nirio/rpc/rpc_client.cpp still contains a reference to boost::bind. It was not possible to remove it by simply doing a search and replace, so it will be removed in a separate commit. --- host/lib/usrp/b100/b100_impl.cpp | 99 ++++++++++++++-------------- host/lib/usrp/b100/io_impl.cpp | 24 ++++--- host/lib/usrp/b100/usb_zero_copy_wrapper.cpp | 12 ++-- 3 files changed, 67 insertions(+), 68 deletions(-) (limited to 'host/lib/usrp/b100') diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index cd4319803..3cd166507 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -7,18 +7,19 @@ #include "b100_impl.hpp" #include "b100_regs.hpp" +#include #include -#include #include -#include -#include +#include #include #include +#include #include #include +#include #include +#include #include -#include using namespace uhd; using namespace uhd::usrp; @@ -274,7 +275,7 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tree->create(mb_path / "name").set("B100"); _tree->create(mb_path / "codename").set("B-Hundo"); _tree->create(mb_path / "load_eeprom") - .add_coerced_subscriber(boost::bind(&fx2_ctrl::usrp_load_eeprom, _fx2_ctrl, _1)); + .add_coerced_subscriber(std::bind(&fx2_ctrl::usrp_load_eeprom, _fx2_ctrl, std::placeholders::_1)); //////////////////////////////////////////////////////////////////// // setup the mboard eeprom @@ -282,20 +283,20 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ const mboard_eeprom_t mb_eeprom = this->get_mb_eeprom(_fx2_ctrl); _tree->create(mb_path / "eeprom") .set(mb_eeprom) - .add_coerced_subscriber(boost::bind(&b100_impl::set_mb_eeprom, this, _1)); + .add_coerced_subscriber(std::bind(&b100_impl::set_mb_eeprom, this, std::placeholders::_1)); //////////////////////////////////////////////////////////////////// // create clock control objects //////////////////////////////////////////////////////////////////// //^^^ clock created up top, just reg props here... ^^^ _tree->create(mb_path / "tick_rate") - .set_publisher(boost::bind(&b100_clock_ctrl::get_fpga_clock_rate, _clock_ctrl)) - .add_coerced_subscriber(boost::bind(&fifo_ctrl_excelsior::set_tick_rate, _fifo_ctrl, _1)) - .add_coerced_subscriber(boost::bind(&b100_impl::update_tick_rate, this, _1)); + .set_publisher(std::bind(&b100_clock_ctrl::get_fpga_clock_rate, _clock_ctrl)) + .add_coerced_subscriber(std::bind(&fifo_ctrl_excelsior::set_tick_rate, _fifo_ctrl, std::placeholders::_1)) + .add_coerced_subscriber(std::bind(&b100_impl::update_tick_rate, this, std::placeholders::_1)); //add_coerced_subscriber the command time while we are at it _tree->create(mb_path / "time/cmd") - .add_coerced_subscriber(boost::bind(&fifo_ctrl_excelsior::set_time, _fifo_ctrl, _1)); + .add_coerced_subscriber(std::bind(&fifo_ctrl_excelsior::set_time, _fifo_ctrl, std::placeholders::_1)); //////////////////////////////////////////////////////////////////// // create codec control objects @@ -306,20 +307,20 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tree->create(rx_codec_path / "name").set("ad9522"); _tree->create(rx_codec_path / "gains/pga/range").set(b100_codec_ctrl::rx_pga_gain_range); _tree->create(rx_codec_path / "gains/pga/value") - .set_coercer(boost::bind(&b100_impl::update_rx_codec_gain, this, _1)) + .set_coercer(std::bind(&b100_impl::update_rx_codec_gain, this, std::placeholders::_1)) .set(0.0); _tree->create(tx_codec_path / "name").set("ad9522"); _tree->create(tx_codec_path / "gains/pga/range").set(b100_codec_ctrl::tx_pga_gain_range); _tree->create(tx_codec_path / "gains/pga/value") - .add_coerced_subscriber(boost::bind(&b100_codec_ctrl::set_tx_pga_gain, _codec_ctrl, _1)) - .set_publisher(boost::bind(&b100_codec_ctrl::get_tx_pga_gain, _codec_ctrl)) + .add_coerced_subscriber(std::bind(&b100_codec_ctrl::set_tx_pga_gain, _codec_ctrl, std::placeholders::_1)) + .set_publisher(std::bind(&b100_codec_ctrl::get_tx_pga_gain, _codec_ctrl)) .set(0.0); //////////////////////////////////////////////////////////////////// // and do the misc mboard sensors //////////////////////////////////////////////////////////////////// _tree->create(mb_path / "sensors/ref_locked") - .set_publisher(boost::bind(&b100_impl::get_ref_locked, this)); + .set_publisher(std::bind(&b100_impl::get_ref_locked, this)); //////////////////////////////////////////////////////////////////// // create frontend control objects @@ -328,27 +329,27 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tx_fe = tx_frontend_core_200::make(_fifo_ctrl, TOREG(SR_TX_FE)); _tree->create(mb_path / "rx_subdev_spec") - .add_coerced_subscriber(boost::bind(&b100_impl::update_rx_subdev_spec, this, _1)); + .add_coerced_subscriber(std::bind(&b100_impl::update_rx_subdev_spec, this, std::placeholders::_1)); _tree->create(mb_path / "tx_subdev_spec") - .add_coerced_subscriber(boost::bind(&b100_impl::update_tx_subdev_spec, this, _1)); + .add_coerced_subscriber(std::bind(&b100_impl::update_tx_subdev_spec, this, std::placeholders::_1)); const fs_path rx_fe_path = mb_path / "rx_frontends" / "A"; const fs_path tx_fe_path = mb_path / "tx_frontends" / "A"; _tree->create >(rx_fe_path / "dc_offset" / "value") - .set_coercer(boost::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, _1)) + .set_coercer(std::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, std::placeholders::_1)) .set(std::complex(0.0, 0.0)); _tree->create(rx_fe_path / "dc_offset" / "enable") - .add_coerced_subscriber(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, _1)) + .add_coerced_subscriber(std::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, std::placeholders::_1)) .set(true); _tree->create >(rx_fe_path / "iq_balance" / "value") - .add_coerced_subscriber(boost::bind(&rx_frontend_core_200::set_iq_balance, _rx_fe, _1)) + .add_coerced_subscriber(std::bind(&rx_frontend_core_200::set_iq_balance, _rx_fe, std::placeholders::_1)) .set(std::complex(0.0, 0.0)); _tree->create >(tx_fe_path / "dc_offset" / "value") - .set_coercer(boost::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, _1)) + .set_coercer(std::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, std::placeholders::_1)) .set(std::complex(0.0, 0.0)); _tree->create >(tx_fe_path / "iq_balance" / "value") - .add_coerced_subscriber(boost::bind(&tx_frontend_core_200::set_iq_balance, _tx_fe, _1)) + .add_coerced_subscriber(std::bind(&tx_frontend_core_200::set_iq_balance, _tx_fe, std::placeholders::_1)) .set(std::complex(0.0, 0.0)); //////////////////////////////////////////////////////////////////// @@ -367,20 +368,20 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _rx_dsps[dspno]->set_link_rate(B100_LINK_RATE_BPS); _tree->access(mb_path / "tick_rate") - .add_coerced_subscriber(boost::bind(&rx_dsp_core_200::set_tick_rate, _rx_dsps[dspno], _1)); + .add_coerced_subscriber(std::bind(&rx_dsp_core_200::set_tick_rate, _rx_dsps[dspno], std::placeholders::_1)); fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); _tree->create(rx_dsp_path / "rate/range") - .set_publisher(boost::bind(&rx_dsp_core_200::get_host_rates, _rx_dsps[dspno])); + .set_publisher(std::bind(&rx_dsp_core_200::get_host_rates, _rx_dsps[dspno])); _tree->create(rx_dsp_path / "rate/value") .set(1e6) //some default - .set_coercer(boost::bind(&rx_dsp_core_200::set_host_rate, _rx_dsps[dspno], _1)) - .add_coerced_subscriber(boost::bind(&b100_impl::update_rx_samp_rate, this, dspno, _1)); + .set_coercer(std::bind(&rx_dsp_core_200::set_host_rate, _rx_dsps[dspno], std::placeholders::_1)) + .add_coerced_subscriber(std::bind(&b100_impl::update_rx_samp_rate, this, dspno, std::placeholders::_1)); _tree->create(rx_dsp_path / "freq/value") - .set_coercer(boost::bind(&rx_dsp_core_200::set_freq, _rx_dsps[dspno], _1)); + .set_coercer(std::bind(&rx_dsp_core_200::set_freq, _rx_dsps[dspno], std::placeholders::_1)); _tree->create(rx_dsp_path / "freq/range") - .set_publisher(boost::bind(&rx_dsp_core_200::get_freq_range, _rx_dsps[dspno])); + .set_publisher(std::bind(&rx_dsp_core_200::get_freq_range, _rx_dsps[dspno])); _tree->create(rx_dsp_path / "stream_cmd") - .add_coerced_subscriber(boost::bind(&rx_dsp_core_200::issue_stream_command, _rx_dsps[dspno], _1)); + .add_coerced_subscriber(std::bind(&rx_dsp_core_200::issue_stream_command, _rx_dsps[dspno], std::placeholders::_1)); } //////////////////////////////////////////////////////////////////// @@ -391,17 +392,17 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ ); _tx_dsp->set_link_rate(B100_LINK_RATE_BPS); _tree->access(mb_path / "tick_rate") - .add_coerced_subscriber(boost::bind(&tx_dsp_core_200::set_tick_rate, _tx_dsp, _1)); + .add_coerced_subscriber(std::bind(&tx_dsp_core_200::set_tick_rate, _tx_dsp, std::placeholders::_1)); _tree->create(mb_path / "tx_dsps/0/rate/range") - .set_publisher(boost::bind(&tx_dsp_core_200::get_host_rates, _tx_dsp)); + .set_publisher(std::bind(&tx_dsp_core_200::get_host_rates, _tx_dsp)); _tree->create(mb_path / "tx_dsps/0/rate/value") .set(1e6) //some default - .set_coercer(boost::bind(&tx_dsp_core_200::set_host_rate, _tx_dsp, _1)) - .add_coerced_subscriber(boost::bind(&b100_impl::update_tx_samp_rate, this, 0, _1)); + .set_coercer(std::bind(&tx_dsp_core_200::set_host_rate, _tx_dsp, std::placeholders::_1)) + .add_coerced_subscriber(std::bind(&b100_impl::update_tx_samp_rate, this, 0, std::placeholders::_1)); _tree->create(mb_path / "tx_dsps/0/freq/value") - .set_coercer(boost::bind(&tx_dsp_core_200::set_freq, _tx_dsp, _1)); + .set_coercer(std::bind(&tx_dsp_core_200::set_freq, _tx_dsp, std::placeholders::_1)); _tree->create(mb_path / "tx_dsps/0/freq/range") - .set_publisher(boost::bind(&tx_dsp_core_200::get_freq_range, _tx_dsp)); + .set_publisher(std::bind(&tx_dsp_core_200::get_freq_range, _tx_dsp)); //////////////////////////////////////////////////////////////////// // create time control objects @@ -415,21 +416,21 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _fifo_ctrl, TOREG(SR_TIME64), time64_rb_bases ); _tree->access(mb_path / "tick_rate") - .add_coerced_subscriber(boost::bind(&time64_core_200::set_tick_rate, _time64, _1)); + .add_coerced_subscriber(std::bind(&time64_core_200::set_tick_rate, _time64, std::placeholders::_1)); _tree->create(mb_path / "time/now") - .set_publisher(boost::bind(&time64_core_200::get_time_now, _time64)) - .add_coerced_subscriber(boost::bind(&time64_core_200::set_time_now, _time64, _1)); + .set_publisher(std::bind(&time64_core_200::get_time_now, _time64)) + .add_coerced_subscriber(std::bind(&time64_core_200::set_time_now, _time64, std::placeholders::_1)); _tree->create(mb_path / "time/pps") - .set_publisher(boost::bind(&time64_core_200::get_time_last_pps, _time64)) - .add_coerced_subscriber(boost::bind(&time64_core_200::set_time_next_pps, _time64, _1)); + .set_publisher(std::bind(&time64_core_200::get_time_last_pps, _time64)) + .add_coerced_subscriber(std::bind(&time64_core_200::set_time_next_pps, _time64, std::placeholders::_1)); //setup time source props _tree->create(mb_path / "time_source/value") - .add_coerced_subscriber(boost::bind(&time64_core_200::set_time_source, _time64, _1)); + .add_coerced_subscriber(std::bind(&time64_core_200::set_time_source, _time64, std::placeholders::_1)); _tree->create >(mb_path / "time_source/options") - .set_publisher(boost::bind(&time64_core_200::get_time_sources, _time64)); + .set_publisher(std::bind(&time64_core_200::get_time_sources, _time64)); //setup reference source props _tree->create(mb_path / "clock_source/value") - .add_coerced_subscriber(boost::bind(&b100_impl::update_clock_source, this, _1)); + .add_coerced_subscriber(std::bind(&b100_impl::update_clock_source, this, std::placeholders::_1)); static const std::vector clock_sources = { "internal", "external", "auto" }; @@ -440,7 +441,7 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //////////////////////////////////////////////////////////////////// _user = user_settings_core_200::make(_fifo_ctrl, TOREG(SR_USER_REGS)); _tree->create(mb_path / "user/regs") - .add_coerced_subscriber(boost::bind(&user_settings_core_200::set_reg, _user, _1)); + .add_coerced_subscriber(std::bind(&user_settings_core_200::set_reg, _user, std::placeholders::_1)); //////////////////////////////////////////////////////////////////// // create dboard control objects @@ -458,13 +459,13 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //create the properties and register subscribers _tree->create(mb_path / "dboards/A/rx_eeprom") .set(rx_db_eeprom) - .add_coerced_subscriber(boost::bind(&b100_impl::set_db_eeprom, this, "rx", _1)); + .add_coerced_subscriber(std::bind(&b100_impl::set_db_eeprom, this, "rx", std::placeholders::_1)); _tree->create(mb_path / "dboards/A/tx_eeprom") .set(tx_db_eeprom) - .add_coerced_subscriber(boost::bind(&b100_impl::set_db_eeprom, this, "tx", _1)); + .add_coerced_subscriber(std::bind(&b100_impl::set_db_eeprom, this, "tx", std::placeholders::_1)); _tree->create(mb_path / "dboards/A/gdb_eeprom") .set(gdb_eeprom) - .add_coerced_subscriber(boost::bind(&b100_impl::set_db_eeprom, this, "gdb", _1)); + .add_coerced_subscriber(std::bind(&b100_impl::set_db_eeprom, this, "gdb", std::placeholders::_1)); //create a new dboard interface and manager _dboard_manager = dboard_manager::make( @@ -477,12 +478,12 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ const fs_path db_tx_fe_path = mb_path / "dboards" / "A" / "tx_frontends"; for(const std::string &name: _tree->list(db_tx_fe_path)){ _tree->access(db_tx_fe_path / name / "freq" / "value") - .add_coerced_subscriber(boost::bind(&b100_impl::set_tx_fe_corrections, this, _1)); + .add_coerced_subscriber(std::bind(&b100_impl::set_tx_fe_corrections, this, std::placeholders::_1)); } const fs_path db_rx_fe_path = mb_path / "dboards" / "A" / "rx_frontends"; for(const std::string &name: _tree->list(db_rx_fe_path)){ _tree->access(db_rx_fe_path / name / "freq" / "value") - .add_coerced_subscriber(boost::bind(&b100_impl::set_rx_fe_corrections, this, _1)); + .add_coerced_subscriber(std::bind(&b100_impl::set_rx_fe_corrections, this, std::placeholders::_1)); } //initialize io handling @@ -498,7 +499,7 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ this->update_rates(); _tree->access(mb_path / "tick_rate") //now add_coerced_subscriber the clock rate setter - .add_coerced_subscriber(boost::bind(&b100_clock_ctrl::set_fpga_clock_rate, _clock_ctrl, _1)); + .add_coerced_subscriber(std::bind(&b100_clock_ctrl::set_fpga_clock_rate, _clock_ctrl, std::placeholders::_1)); //reset cordic rates and their properties to zero for(const std::string &name: _tree->list(mb_path / "rx_dsps")){ diff --git a/host/lib/usrp/b100/io_impl.cpp b/host/lib/usrp/b100/io_impl.cpp index d3de1cca1..c50327271 100644 --- a/host/lib/usrp/b100/io_impl.cpp +++ b/host/lib/usrp/b100/io_impl.cpp @@ -5,16 +5,14 @@ // SPDX-License-Identifier: GPL-3.0-or-later // +#include "../../transport/super_recv_packet_handler.hpp" +#include "../../transport/super_send_packet_handler.hpp" #include "b100_impl.hpp" #include #include -#include "../../transport/super_recv_packet_handler.hpp" -#include "../../transport/super_send_packet_handler.hpp" - -#include #include -#include #include +#include #include using namespace uhd; @@ -149,14 +147,14 @@ rx_streamer::sptr b100_impl::get_rx_stream(const uhd::stream_args_t &args_){ _rx_dsps[dsp]->set_nsamps_per_packet(spp); //seems to be a good place to set this _rx_dsps[dsp]->setup(args); _recv_demuxer->realloc_sid(B100_RX_SID_BASE + dsp); - my_streamer->set_xport_chan_get_buff(chan_i, boost::bind( - &recv_packet_demuxer_3000::get_recv_buff, _recv_demuxer, B100_RX_SID_BASE + dsp, _1 + my_streamer->set_xport_chan_get_buff(chan_i, std::bind( + &recv_packet_demuxer_3000::get_recv_buff, _recv_demuxer, B100_RX_SID_BASE + dsp, std::placeholders::_1 ), true /*flush*/); - my_streamer->set_overflow_handler(chan_i, boost::bind( + my_streamer->set_overflow_handler(chan_i, std::bind( &rx_dsp_core_200::handle_overflow, _rx_dsps[dsp] )); - my_streamer->set_issue_stream_cmd(chan_i, boost::bind( - &rx_dsp_core_200::issue_stream_command, _rx_dsps[dsp], _1)); + my_streamer->set_issue_stream_cmd(chan_i, std::bind( + &rx_dsp_core_200::issue_stream_command, _rx_dsps[dsp], std::placeholders::_1)); _rx_streamers[dsp] = my_streamer; //store weak pointer } @@ -207,10 +205,10 @@ tx_streamer::sptr b100_impl::get_tx_stream(const uhd::stream_args_t &args_){ const size_t dsp = args.channels[chan_i]; UHD_ASSERT_THROW(dsp == 0); //always 0 _tx_dsp->setup(args); - my_streamer->set_xport_chan_get_buff(chan_i, boost::bind( - &zero_copy_if::get_send_buff, _data_transport, _1 + my_streamer->set_xport_chan_get_buff(chan_i, std::bind( + &zero_copy_if::get_send_buff, _data_transport, std::placeholders::_1 )); - my_streamer->set_async_receiver(boost::bind(&fifo_ctrl_excelsior::pop_async_msg, _fifo_ctrl, _1, _2)); + my_streamer->set_async_receiver(std::bind(&fifo_ctrl_excelsior::pop_async_msg, _fifo_ctrl, std::placeholders::_1, std::placeholders::_2)); _tx_streamers[dsp] = my_streamer; //store weak pointer } diff --git a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp index 6303c301d..8059c2a0d 100644 --- a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp +++ b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp @@ -5,18 +5,18 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include #include +#include #include #include #include #include -#include -#include #include -#include -#include +#include +#include #include +#include +#include using namespace uhd; using namespace uhd::transport; @@ -75,7 +75,7 @@ public: _internal(internal), _fragmentation_size(fragmentation_size) { _ok_to_auto_flush = false; - _task = uhd::task::make(boost::bind(&usb_zero_copy_wrapper_msb::auto_flush, this)); + _task = uhd::task::make(std::bind(&usb_zero_copy_wrapper_msb::auto_flush, this)); } ~usb_zero_copy_wrapper_msb(void) -- cgit v1.2.3