aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-01-15 14:42:05 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-18 09:37:12 -0800
commit11c7e561fc29b56ade8ae6ec549b21c533540e8a (patch)
treea346b7bd7e561efbb8d61de59c4ac2dec4c18d0b
parenteb1f8f160b803bae60c2af7be35e42ece3b8a62b (diff)
downloaduhd-11c7e561fc29b56ade8ae6ec549b21c533540e8a.tar.gz
uhd-11c7e561fc29b56ade8ae6ec549b21c533540e8a.tar.bz2
uhd-11c7e561fc29b56ade8ae6ec549b21c533540e8a.zip
math: Remove uhd::math::log2, replace with std::log2
Now that we're C++11, we can assume the existence of said symbol and need no more portability hacks.
-rw-r--r--host/cmake/Modules/UHDGlobalDefs.cmake3
-rw-r--r--host/include/uhd/utils/math.hpp9
-rw-r--r--host/lib/usrp/common/ad936x_manager.cpp3
-rw-r--r--host/tests/math_test.cpp9
4 files changed, 5 insertions, 19 deletions
diff --git a/host/cmake/Modules/UHDGlobalDefs.cmake b/host/cmake/Modules/UHDGlobalDefs.cmake
index 47bb83511..385679258 100644
--- a/host/cmake/Modules/UHDGlobalDefs.cmake
+++ b/host/cmake/Modules/UHDGlobalDefs.cmake
@@ -9,9 +9,6 @@
include(CheckCXXSymbolExistsCopy)
-## Check for std::log2
-CHECK_CXX_SYMBOL_EXISTS(log2 cmath HAVE_LOG2)
-
## Macros for the version number
if(UHD_VERSION_DEVEL)
math(EXPR UHD_VERSION_ADDED "1000000 * ${UHD_VERSION_MAJOR} + 10000 * ${UHD_VERSION_API} + 100 * ${UHD_VERSION_ABI} + 99")
diff --git a/host/include/uhd/utils/math.hpp b/host/include/uhd/utils/math.hpp
index e9f8efb57..8606923fa 100644
--- a/host/include/uhd/utils/math.hpp
+++ b/host/include/uhd/utils/math.hpp
@@ -223,15 +223,6 @@ UHD_INLINE bool frequencies_are_equal(double lhs, double rhs)
== fp_compare::fp_compare_delta<double>(rhs, FREQ_COMPARISON_DELTA_HZ));
}
-//! Portable log2()
-template <typename float_t> UHD_INLINE float_t log2(float_t x)
-{
- // C++11 defines std::log2(), when that's universally supported
- // we can switch over.
- return std::log(x) / std::log(float_t(2));
-}
-
-
} // namespace math
} // namespace uhd
diff --git a/host/lib/usrp/common/ad936x_manager.cpp b/host/lib/usrp/common/ad936x_manager.cpp
index 87521e834..5c4cb51ae 100644
--- a/host/lib/usrp/common/ad936x_manager.cpp
+++ b/host/lib/usrp/common/ad936x_manager.cpp
@@ -10,6 +10,7 @@
#include <boost/functional/hash.hpp>
#include <boost/make_shared.hpp>
#include <chrono>
+#include <cmath>
#include <thread>
using namespace uhd;
@@ -167,7 +168,7 @@ public:
// We use shifts here instead of 2^x because exp2() is not available in all
// compilers, also this guarantees no rounding issues. The type cast to int32_t
// serves as floor():
- int32_t multiplier = (1 << int32_t(uhd::math::log2(max_tick_rate / lcm_rate)));
+ int32_t multiplier = (1 << int32_t(std::log2(max_tick_rate / lcm_rate)));
if (multiplier == 2 and lcm_rate >= min_tick_rate) {
// Don't bother (see above)
multiplier = 1;
diff --git a/host/tests/math_test.cpp b/host/tests/math_test.cpp
index ffdcbb086..575cfe071 100644
--- a/host/tests/math_test.cpp
+++ b/host/tests/math_test.cpp
@@ -9,11 +9,8 @@
#include <stdint.h>
#include <boost/test/unit_test.hpp>
-// NOTE: This is not the only math test case, see e.g. special tests
-// for fp comparison.
-
-BOOST_AUTO_TEST_CASE(test_log2)
+// We need an empty test
+BOOST_AUTO_TEST_CASE(test_)
{
- double y = uhd::math::log2(16.0);
- BOOST_CHECK_EQUAL(y, 4.0);
+ BOOST_CHECK_EQUAL(true, true);
}