From 11c7e561fc29b56ade8ae6ec549b21c533540e8a Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 15 Jan 2019 14:42:05 -0800 Subject: 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. --- host/cmake/Modules/UHDGlobalDefs.cmake | 3 --- host/include/uhd/utils/math.hpp | 9 --------- host/lib/usrp/common/ad936x_manager.cpp | 3 ++- host/tests/math_test.cpp | 9 +++------ 4 files changed, 5 insertions(+), 19 deletions(-) (limited to 'host') 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(rhs, FREQ_COMPARISON_DELTA_HZ)); } -//! Portable log2() -template 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 #include #include +#include #include 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 #include -// 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); } -- cgit v1.2.3