aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2022-01-04 17:42:35 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2022-01-12 15:07:54 -0600
commit2d9a83374760d3b2c36184710e103098566ec3ad (patch)
tree960df052e33b1f2671604a4858bfae5edfb3cc55
parent85e61c7d8f520202d2de94e60ca47ed3d6948155 (diff)
downloaduhd-2d9a83374760d3b2c36184710e103098566ec3ad.tar.gz
uhd-2d9a83374760d3b2c36184710e103098566ec3ad.tar.bz2
uhd-2d9a83374760d3b2c36184710e103098566ec3ad.zip
uhd: Fix non-standard function name macros
Throughout UHD, we are using a random mix of __FUNCTION__, __func__, __PRETTY_FUNCTION__, and BOOST_CURRENT_FUNCTION. Note that the first two macros are non-standard (although many compilers understand them), and the last requires Boost. __func__ is available since C++11, but is not the best choice because the C++ standard doesn't require it to be of any specific value. We thus define UHD_FUNCTION and UHD_PRETTY_FUNCTION as portable macros. The former simply contains the undecorated function name, the latter the expanded function with full signature. As it happens, our currently supported compilers didn't have any issues using non-standard macros, so the main fix here is the removal of the Boost macros and the harmonization of the other macros.
-rw-r--r--host/include/uhd/config.hpp10
-rw-r--r--host/include/uhd/exception.hpp9
-rw-r--r--host/include/uhd/utils/log.hpp3
-rw-r--r--host/lib/include/uhdlib/usrp/dboard/debug_dboard.hpp7
-rw-r--r--host/lib/transport/libusb1_base.cpp3
-rw-r--r--host/lib/usrp/gps_ctrl.cpp4
-rw-r--r--host/lib/usrp/multi_usrp.cpp2
7 files changed, 24 insertions, 14 deletions
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 8504e0c18..c2b3f7f45 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -56,6 +56,8 @@ typedef SSIZE_T ssize_t;
# define UHD_ALIGNED(x) __declspec(align(x))
# define UHD_UNUSED(x) x
# define UHD_FALLTHROUGH
+# define UHD_FUNCTION __FUNCTION__
+# define UHD_PRETTY_FUNCTION __FUNCSIG__
#elif defined(__MINGW32__)
# define UHD_EXPORT __declspec(dllexport)
# define UHD_IMPORT __declspec(dllimport)
@@ -65,6 +67,8 @@ typedef SSIZE_T ssize_t;
# define UHD_ALIGNED(x) __declspec(align(x))
# define UHD_UNUSED(x) x __attribute__((unused))
# define UHD_FALLTHROUGH
+# define UHD_FUNCTION __func__
+# define UHD_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif defined(__GNUG__) && __GNUG__ >= 4
# define UHD_EXPORT __attribute__((visibility("default")))
# define UHD_IMPORT __attribute__((visibility("default")))
@@ -78,6 +82,8 @@ typedef SSIZE_T ssize_t;
# else
# define UHD_FALLTHROUGH
# endif
+# define UHD_FUNCTION __func__
+# define UHD_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif defined(__clang__)
# define UHD_EXPORT __attribute__((visibility("default")))
# define UHD_IMPORT __attribute__((visibility("default")))
@@ -91,6 +97,8 @@ typedef SSIZE_T ssize_t;
# else
# define UHD_FALLTHROUGH
# endif
+# define UHD_FUNCTION __func__
+# define UHD_PRETTY_FUNCTION __PRETTY_FUNCTION__
#else
# define UHD_EXPORT
# define UHD_IMPORT
@@ -100,6 +108,8 @@ typedef SSIZE_T ssize_t;
# define UHD_ALIGNED(x)
# define UHD_UNUSED(x) x
# define UHD_FALLTHROUGH
+# define UHD_FUNCTION __func__
+# define UHD_PRETTY_FUNCTION __func__
#endif
// Define API declaration macro
diff --git a/host/include/uhd/exception.hpp b/host/include/uhd/exception.hpp
index f48f97ba3..d0f886a18 100644
--- a/host/include/uhd/exception.hpp
+++ b/host/include/uhd/exception.hpp
@@ -8,7 +8,6 @@
#pragma once
#include <uhd/config.hpp>
-#include <boost/current_function.hpp>
#include <stdexcept>
#include <string>
@@ -302,10 +301,10 @@ struct UHD_API routing_error : rfnoc_error
* \param what the std::exception message
* \return the formatted exception message
*/
-#define UHD_THROW_SITE_INFO(what) \
- std::string(std::string(what) + "\n" + " in " + std::string(BOOST_CURRENT_FUNCTION) \
- + "\n" + " at " + std::string(__FILE__) + ":" \
- + BOOST_STRINGIZE(__LINE__) + "\n")
+#define UHD_THROW_SITE_INFO(what) \
+ std::string(std::string(what) + "\n" + " in " + std::string(UHD_FUNCTION) + "\n" \
+ + " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) \
+ + "\n")
/*!
* Throws an invalid code path exception with throw-site information.
diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp
index f333f9594..7b76ec075 100644
--- a/host/include/uhd/utils/log.hpp
+++ b/host/include/uhd/utils/log.hpp
@@ -8,7 +8,6 @@
#pragma once
#include <uhd/config.hpp>
-#include <boost/current_function.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <iomanip>
#include <iostream>
@@ -264,7 +263,7 @@ UHD_API void set_logger_level(const std::string& logger, uhd::log::severity_leve
//! Helpful debug tool to print site info
# define UHD_HERE() \
UHD_LOGGER_DEBUG("DEBUG") \
- << __FILE__ << ":" << __LINE__ << " (" << __PRETTY_FUNCTION__ << ")";
+ << __FILE__ << ":" << __LINE__ << " (" << UHD_PRETTY_FUNCTION << ")";
#else
//! Helpful debug tool to print site info
# define UHD_HERE() UHD_LOGGER_DEBUG("DEBUG") << __FILE__ << ":" << __LINE__;
diff --git a/host/lib/include/uhdlib/usrp/dboard/debug_dboard.hpp b/host/lib/include/uhdlib/usrp/dboard/debug_dboard.hpp
index 0c22831b5..953a4c928 100644
--- a/host/lib/include/uhdlib/usrp/dboard/debug_dboard.hpp
+++ b/host/lib/include/uhdlib/usrp/dboard/debug_dboard.hpp
@@ -7,6 +7,7 @@
#pragma once
#include "x400_dboard_iface.hpp"
+#include <uhd/config.hpp>
#include <uhd/exception.hpp>
#include <uhd/property_tree.hpp>
#include <uhd/types/eeprom.hpp>
@@ -16,7 +17,7 @@
#define UHD_LOG_SKIP_CFG() \
UHD_LOG_TRACE( \
- "RFNOC::DEBUG_DB", "Skipping unsupported debug db config for " << __FUNCTION__);
+ "RFNOC::DEBUG_DB", "Skipping unsupported debug db config for " << UHD_FUNCTION);
namespace uhd { namespace rfnoc {
@@ -397,7 +398,7 @@ public:
, _mb_control(mb_controller)
, _tree(tree)
{
- RFNOC_LOG_TRACE("Entering " << __FUNCTION__);
+ RFNOC_LOG_TRACE("Entering " << UHD_FUNCTION);
RFNOC_LOG_TRACE("DB ID: " << _db_idx);
UHD_ASSERT_THROW(_mb_control);
_rpcc = _mb_control->get_rpc_client();
@@ -407,7 +408,7 @@ public:
~if_test_dboard_impl()
{
- RFNOC_LOG_TRACE(__FUNCTION__);
+ RFNOC_LOG_TRACE(UHD_FUNCTION);
}
// The IF Test dboard muxes a single SMA port (for each of RX and TX) like so:
diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp
index 6808a3e0d..3cb190a6e 100644
--- a/host/lib/transport/libusb1_base.cpp
+++ b/host/lib/transport/libusb1_base.cpp
@@ -6,6 +6,7 @@
//
#include "libusb1_base.hpp"
+#include <uhd/config.hpp>
#include <uhd/exception.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/types/serial.hpp>
@@ -77,7 +78,7 @@ private:
throw uhd::io_error(libusb_strerror(LIBUSB_ERROR_NO_DEVICE));
default:
UHD_LOGGER_ERROR("USB")
- << __FUNCTION__ << ": " << libusb_strerror((libusb_error)ret);
+ << UHD_FUNCTION << ": " << libusb_strerror((libusb_error)ret);
break;
}
}
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp
index cafc2f662..8026b32a2 100644
--- a/host/lib/usrp/gps_ctrl.cpp
+++ b/host/lib/usrp/gps_ctrl.cpp
@@ -154,7 +154,7 @@ private:
if (msg.length() < 6) {
UHD_LOGGER_WARNING("GPS")
- << __FUNCTION__ << ": Short GPSDO string: " << msg;
+ << UHD_FUNCTION << "(): Short GPSDO string: " << msg;
continue;
}
@@ -166,7 +166,7 @@ private:
msgs[msg.substr(1, 5)] = msg;
} else {
UHD_LOGGER_WARNING("GPS")
- << __FUNCTION__ << ": Malformed GPSDO string: " << msg;
+ << UHD_FUNCTION << "(): Malformed GPSDO string: " << msg;
}
}
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 89c4cbc26..0427a4941 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -64,7 +64,7 @@ UHD_INLINE std::string string_vector_to_string(
throw uhd::exception::runtime_error( \
(boost::format( \
"%s: gain \"%s\" not found for channel %d.\nAvailable gains: %s\n") \
- % __FUNCTION__ % name % chan \
+ % UHD_FUNCTION % name % chan \
% string_vector_to_string(get_##dir##_gain_names(chan))) \
.str());