From fd76798927ef50bba8f98e49387d8b36b13109e1 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Tue, 29 Oct 2013 09:21:12 -0700 Subject: Removed GCC-specific attribute for unused parameters * This broke MSVC builds due to incompatibility * Added new UHD_UNUSED(x) macro in --- host/examples/test_messages.cpp | 5 +++-- host/include/uhd/config.hpp | 3 +++ host/lib/usrp/b200/b200_iface.cpp | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'host') diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index 0815d0b1c..4240e830b 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2011 Ettus Research LLC +// Copyright 2010-2013 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 @@ -15,6 +15,7 @@ // along with this program. If not, see . // +#include #include #include #include @@ -84,7 +85,7 @@ bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streame * Issue a stream command with num samps and more. * We expect to get an inline broken chain message. */ -bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp __attribute__ ((unused)), uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ +bool test_broken_chain_message(UHD_UNUSED(uhd::usrp::multi_usrp::sptr usrp), uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ std::cout << "Test broken chain message... " << std::flush; uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE); diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 6fd2932cf..619bd0787 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -55,18 +55,21 @@ typedef ptrdiff_t ssize_t; #define UHD_INLINE __forceinline #define UHD_DEPRECATED __declspec(deprecated) #define UHD_ALIGNED(x) __declspec(align(x)) + #define UHD_UNUSED(x) x #elif defined(__GNUG__) && __GNUG__ >= 4 #define UHD_EXPORT __attribute__((visibility("default"))) #define UHD_IMPORT __attribute__((visibility("default"))) #define UHD_INLINE inline __attribute__((always_inline)) #define UHD_DEPRECATED __attribute__((deprecated)) #define UHD_ALIGNED(x) __attribute__((aligned(x))) + #define UHD_UNUSED(x) x __attribute__((unused)) #else #define UHD_EXPORT #define UHD_IMPORT #define UHD_INLINE inline #define UHD_DEPRECATED #define UHD_ALIGNED(x) + #define UHD_UNUSED(x) x #endif // Define API declaration macro diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 457b380b6..d440b105a 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -17,6 +17,7 @@ #include "b200_iface.hpp" +#include #include #include #include @@ -217,13 +218,13 @@ public: } - void write_i2c(boost::uint16_t addr __attribute__ ((unused)), const byte_vector_t &bytes __attribute__ ((unused))) + void write_i2c(UHD_UNUSED(boost::uint16_t addr), UHD_UNUSED(const byte_vector_t &bytes)) { throw uhd::not_implemented_error("b200 write i2c"); } - byte_vector_t read_i2c(boost::uint16_t addr __attribute__ ((unused)), size_t num_bytes __attribute__ ((unused))) + byte_vector_t read_i2c(UHD_UNUSED(boost::uint16_t addr), UHD_UNUSED(size_t num_bytes)) { throw uhd::not_implemented_error("b200 read i2c"); } @@ -296,7 +297,7 @@ public: } - void load_firmware(const std::string filestring, bool force __attribute__ ((unused)) = false) + void load_firmware(const std::string filestring, UHD_UNUSED(bool force) = false) { const char *filename = filestring.c_str(); -- cgit v1.2.3 From ac987d48a1f7f264ca6560b38dc75a5dc1d2ce5e Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:22:09 -0700 Subject: Renamed condition variable and moved it into the class to scope it and guarantee only one thread would be waiting on the notification. --- host/examples/network_relay.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'host') diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index a12c38ff8..fc1ebd91d 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -33,9 +33,6 @@ typedef boost::shared_ptr socket_type; static const size_t insane_mtu = 9000; -boost::mutex spawn_mutex; -boost::condition_variable thread_spawned; - #if defined(UHD_PLATFORM_MACOS) //limit buffer resize on macos or it will error const size_t rx_dsp_buff_size = size_t(1e6); @@ -101,11 +98,11 @@ public: } std::cout << "spawning relay threads... " << _port << std::endl; - boost::unique_lock lock(spawn_mutex); + boost::unique_lock lock(spawn_mutex); // lock in preparation to wait for threads to spawn _thread_group.create_thread(boost::bind(&udp_relay_type::server_thread, this)); - thread_spawned.wait(lock); + wait_for_thread.wait(lock); // wait for thread to spin up _thread_group.create_thread(boost::bind(&udp_relay_type::client_thread, this)); - thread_spawned.wait(lock); + wait_for_thread.wait(lock); // wait for thread to spin up std::cout << " done!" << std::endl << std::endl; } @@ -126,7 +123,7 @@ private: void server_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering server_thread..." << std::endl; - thread_spawned.notify_one(); + wait_for_thread.notify_one(); // notify constructor that this thread has started std::vector buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_server_socket->native())){ @@ -152,7 +149,7 @@ private: void client_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering client_thread..." << std::endl; - thread_spawned.notify_one(); + wait_for_thread.notify_one(); // notify constructor that this thread has started std::vector buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_client_socket->native())){ @@ -170,6 +167,8 @@ private: asio::ip::udp::endpoint _endpoint; boost::mutex _endpoint_mutex; socket_type _server_socket, _client_socket; + boost::mutex spawn_mutex; + boost::condition_variable wait_for_thread; }; -- cgit v1.2.3 From c3557962287aaf87090020113dc1de73d12fcfbe Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:23:00 -0700 Subject: Removed unnecessary check. --- host/examples/test_dboard_coercion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'host') diff --git a/host/examples/test_dboard_coercion.cpp b/host/examples/test_dboard_coercion.cpp index bbe6f70dd..86c59d9d7 100644 --- a/host/examples/test_dboard_coercion.cpp +++ b/host/examples/test_dboard_coercion.cpp @@ -121,7 +121,7 @@ std::string tx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != gains.back()) gains.push_back(gain_end); + gains.push_back(gain_end); } @@ -313,7 +313,7 @@ std::string rx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != gains.back()) gains.push_back(gain_end); + gains.push_back(gain_end); } -- cgit v1.2.3 From 39acb1ef1701671f47f8712320af351aa16050e3 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:27:02 -0700 Subject: Changed reusable_barrier default size to 0 to make default behavior provide protection for multiple threads. Changed member initialization of other constructor. --- host/include/uhd/utils/atomic.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'host') diff --git a/host/include/uhd/utils/atomic.hpp b/host/include/uhd/utils/atomic.hpp index 5f0a056d2..55769d2fd 100644 --- a/host/include/uhd/utils/atomic.hpp +++ b/host/include/uhd/utils/atomic.hpp @@ -78,11 +78,9 @@ namespace uhd{ class UHD_API reusable_barrier{ public: - reusable_barrier():_size (1) {} + reusable_barrier():_size (0) {} - reusable_barrier(const size_t size) { - _size = size; - } + reusable_barrier(const size_t size):_size(size) {} //! Resize the barrier for N threads void resize(const size_t size){ -- cgit v1.2.3 From e48622be4eb994571e107ed9536f7d8658098396 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:28:17 -0700 Subject: Readability improvements and typo fix. --- host/lib/usrp/b200/b200_iface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index d440b105a..bff075536 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -159,7 +159,7 @@ bool parse_record(std::string *record, boost::uint16_t &len, \ std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; - if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + if (len > (2 * (record->length() - 9))) // sanity check to prevent buffer overrun return false; for (i = 0; i < len; i++) { @@ -327,7 +327,7 @@ public: std::string record; file >> record; - if (!record.length() > 0) + if (!(record.length() > 0)) continue; /* Check for valid Intel HEX record. */ @@ -427,7 +427,7 @@ public: UHD_THROW_INVALID_CODE_PATH(); // Below is dead code as long as UHD_THROW_INVALID_CODE_PATH(); is declared above. - // It is preservered here in a comment in case it is needed later: + // It is preserved here in a comment in case it is needed later: // fx3_control_write(B200_VREQ_FPGA_RESET, 0x00, 0x00, data, 4); } -- cgit v1.2.3 From fddcf720a16e7caccb132d8c66814c2e7e627dfe Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:28:49 -0700 Subject: Readability improvements. --- host/lib/usrp/common/fx2_ctrl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp index 1cacc45cf..d68bf6058 100644 --- a/host/lib/usrp/common/fx2_ctrl.cpp +++ b/host/lib/usrp/common/fx2_ctrl.cpp @@ -119,7 +119,7 @@ bool parse_record(std::string *record, unsigned int &len, std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; - if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + if (len > (2 * (record->length() - 9))) // sanity check to prevent buffer overrun return false; for (i = 0; i < len; i++) { @@ -184,7 +184,7 @@ public: std::string record; file >> record; - if (!record.length() > 0) + if (!(record.length() > 0)) continue; //check for valid record -- cgit v1.2.3 From 709db30d12a664b23b7f3695433a7b2d45c2a533 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:29:18 -0700 Subject: Readability improvements. --- host/lib/usrp/usrp1/usrp1_iface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index 7c64714b7..6eff9d3ad 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -141,8 +141,10 @@ public: if (readback) { unsigned char buff[4] = { - (unsigned char)((bits >> 0) & 0xff), (unsigned char)((bits >> 8) & 0xff), - (unsigned char)((bits >> 16) & 0xff), (unsigned char)((bits >> 24) & 0xff) + (unsigned char)(bits & 0xff), + (unsigned char)((bits >> 8) & 0xff), + (unsigned char)((bits >> 16) & 0xff), + (unsigned char)((bits >> 24) & 0xff) }; //conditions where there are two header bytes if (num_bytes >= 3 and buff[num_bytes-1] != 0 and buff[num_bytes-2] != 0 and buff[num_bytes-3] == 0){ -- cgit v1.2.3 From 901434f58941985fe3e00d7dd53ff4538b542244 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:29:44 -0700 Subject: Readability improvements. --- host/lib/usrp/usrp2/usrp2_clk_regs.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'host') diff --git a/host/lib/usrp/usrp2/usrp2_clk_regs.hpp b/host/lib/usrp/usrp2/usrp2_clk_regs.hpp index 45c0859d8..d5e506d8d 100644 --- a/host/lib/usrp/usrp2/usrp2_clk_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_clk_regs.hpp @@ -22,7 +22,16 @@ class usrp2_clk_regs_t { public: - usrp2_clk_regs_t(void):test(0),fpga(0),adc(0),dac(0),serdes(0),exp(0),tx_db(0),rx_db(0) { ; } + usrp2_clk_regs_t(void): + test(0), + fpga(0), + adc(0), + dac(0), + serdes(0), + exp(0), + tx_db(0), + rx_db(0) {} + usrp2_clk_regs_t(usrp2_iface::rev_type rev) { fpga = adc = serdes = exp = tx_db = 0; test = 0; -- cgit v1.2.3 From 57ceb52cc60d9f7da8a40547798d4e1df26e3334 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:30:20 -0700 Subject: Readability improvements. --- host/utils/b2xx_fx3_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'host') diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index 3664ecbbf..abc75d248 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -168,7 +168,7 @@ bool parse_record(std::string *record, boost::uint16_t &len, boost::uint16_t &ad std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; - if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + if (len > (2 * (record->length() - 9))) // sanity check to prevent buffer overrun return false; for (i = 0; i < len; i++) { @@ -412,7 +412,7 @@ boost::int32_t fx3_load_firmware(libusb_device_handle *dev_handle, \ std::string record; file >> record; - if (!record.length() > 0) + if (!(record.length() > 0)) continue; /* Check for valid Intel HEX record. */ -- cgit v1.2.3 From 265e94473130ffefc95d4eb67e8d46ce50982be4 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 17:15:05 -0700 Subject: Restored use of accessor to initialize value in the constructor. --- host/lib/usrp/cores/tx_dsp_core_3000.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'host') diff --git a/host/lib/usrp/cores/tx_dsp_core_3000.cpp b/host/lib/usrp/cores/tx_dsp_core_3000.cpp index 6fde70c5f..93c8702bc 100644 --- a/host/lib/usrp/cores/tx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_3000.cpp @@ -51,7 +51,7 @@ public: //init to something so update method has reasonable defaults _scaling_adjustment = 1.0; _dsp_extra_scaling = 1.0; - _tick_rate = 1.0; + this->set_tick_rate(1.0); } void set_tick_rate(const double rate){ -- cgit v1.2.3