From 6c213ecd0927d10a98ba6ec64fbc9338516edee2 Mon Sep 17 00:00:00 2001 From: Steven Koo Date: Thu, 6 Aug 2020 21:18:17 -0500 Subject: rfnoc: Remove M_PI usage to fix Windows builds M_PI may not exist if _USE_MATH_DEFINES isn't defined before the first include of math.h or cmath on Windows. This changes avoids the issue all together by defining our own PI. --- host/tests/rfnoc_block_tests/siggen_block_test.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'host/tests') diff --git a/host/tests/rfnoc_block_tests/siggen_block_test.cpp b/host/tests/rfnoc_block_tests/siggen_block_test.cpp index d495e7a19..6fdcb903b 100644 --- a/host/tests/rfnoc_block_tests/siggen_block_test.cpp +++ b/host/tests/rfnoc_block_tests/siggen_block_test.cpp @@ -4,8 +4,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#define _USE_MATH_DEFINES - #include "../rfnoc_graph_mock_nodes.hpp" #include #include @@ -13,11 +11,11 @@ #include #include #include +#include #include #include #include #include -#include #include using namespace uhd::rfnoc; @@ -125,7 +123,7 @@ public: static uint32_t phase_increment_to_register(double phase_inc) { const int16_t phase_inc_scaled_rads_fp = - clamp((phase_inc / M_PI) * 8192.0); + clamp((phase_inc / uhd::math::PI) * 8192.0); return static_cast(phase_inc_scaled_rads_fp) & 0xffff; } @@ -248,7 +246,7 @@ BOOST_FIXTURE_TEST_CASE(siggen_test_api, siggen_block_fixture) BOOST_CHECK_EQUAL(reg_iface->constants.at(port), siggen_mock_reg_iface_t::constant_to_register(constant)); BOOST_CHECK_EQUAL(test_siggen->get_constant(port), constant); - const double phase_inc = (port * M_PI / 16.0); + const double phase_inc = (port * uhd::math::PI / 16.0); test_siggen->set_sine_phase_increment(phase_inc, port); BOOST_CHECK_EQUAL(reg_iface->phase_increments.at(port), siggen_mock_reg_iface_t::phase_increment_to_register(phase_inc)); BOOST_CHECK_EQUAL(test_siggen->get_sine_phase_increment(port), phase_inc); @@ -256,7 +254,7 @@ BOOST_FIXTURE_TEST_CASE(siggen_test_api, siggen_block_fixture) const double freq = 1000 + (100 * port); const double samp_rate = 1e6; test_siggen->set_sine_frequency(freq, samp_rate, port); - const double calculated_phase_inc = freq / samp_rate * 2.0 * M_PI; + const double calculated_phase_inc = freq / samp_rate * 2.0 * uhd::math::PI; BOOST_CHECK_EQUAL(reg_iface->phase_increments.at(port), siggen_mock_reg_iface_t::phase_increment_to_register(calculated_phase_inc)); BOOST_CHECK_EQUAL( @@ -294,7 +292,7 @@ BOOST_FIXTURE_TEST_CASE(siggen_test_ranges, siggen_block_fixture) BOOST_CHECK_THROW(test_siggen->set_constant(bad_constant_q, port), uhd::value_error); BOOST_CHECK_THROW(test_siggen->set_constant(-bad_constant_q, port), uhd::value_error); - const double bad_phase_inc = 5 * M_PI; + const double bad_phase_inc = 5 * uhd::math::PI; BOOST_CHECK_THROW( test_siggen->set_sine_phase_increment(bad_phase_inc, port), uhd::value_error); BOOST_CHECK_THROW(test_siggen->set_sine_phase_increment(-bad_phase_inc, port), -- cgit v1.2.3