From 7fab6b807ef5b86c97577170b7b5fdc667e3fa20 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 15 Jan 2019 15:04:03 -0800 Subject: math: Replace boost::*::{lcm,gcd}() with portable versions Boost changed the lcm() and gcd() functions in Boost 1.67. This creates portable UHD versions to be used instead. They use various Boost versions under the hood conditionally. --- host/include/uhd/utils/math.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'host/include') diff --git a/host/include/uhd/utils/math.hpp b/host/include/uhd/utils/math.hpp index 8606923fa..944e9a951 100644 --- a/host/include/uhd/utils/math.hpp +++ b/host/include/uhd/utils/math.hpp @@ -12,6 +12,15 @@ #include #include #include +#if BOOST_VERSION >= 106700 +# include +// "bmint" for "boost math integer" +namespace _bmint = boost::integer; +#else +# include +namespace _bmint = boost::math; +#endif + namespace uhd { @@ -223,6 +232,20 @@ UHD_INLINE bool frequencies_are_equal(double lhs, double rhs) == fp_compare::fp_compare_delta(rhs, FREQ_COMPARISON_DELTA_HZ)); } +//! Portable version of lcm() across Boost versions +template inline IntegerType lcm(IntegerType x, IntegerType y) +{ + // Note: _bmint is defined conditionally at the top of the file + return _bmint::lcm(x, y); +} + +//! Portable version of gcd() across Boost versions +template inline IntegerType gcd(IntegerType x, IntegerType y) +{ + // Note: _bmint is defined conditionally at the top of the file + return _bmint::gcd(x, y); +} + } // namespace math } // namespace uhd -- cgit v1.2.3