1*4882a593SmuzhiyunFrom 2c767bb260a25b415e8c9c4b3ea37280b2127cec Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: japm48 <japm48@users.noreply.github.com> 3*4882a593SmuzhiyunDate: Fri, 10 Apr 2020 23:35:30 +0200 4*4882a593SmuzhiyunSubject: [PATCH] boost: remove deprecated math/common_factor.hpp 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunRemove deprecation warning and prefer using std::{lcm,gcd} to Boost. 7*4882a593SmuzhiyunFixes #2712. 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun[Retrieved from: 10*4882a593Smuzhiyunhttps://github.com/gnuradio/gnuradio/commit/2c767bb260a25b415e8c9c4b3ea37280b2127cec] 11*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 12*4882a593Smuzhiyun--- 13*4882a593Smuzhiyun .../include/gnuradio/CMakeLists.txt | 1 + 14*4882a593Smuzhiyun .../include/gnuradio/integer_math.h | 35 +++++++++++++++++++ 15*4882a593Smuzhiyun gnuradio-runtime/lib/buffer.cc | 19 ++-------- 16*4882a593Smuzhiyun gr-digital/lib/symbol_sync_cc_impl.cc | 4 +-- 17*4882a593Smuzhiyun gr-digital/lib/symbol_sync_ff_impl.cc | 4 +-- 18*4882a593Smuzhiyun 5 files changed, 43 insertions(+), 20 deletions(-) 19*4882a593Smuzhiyun create mode 100644 gnuradio-runtime/include/gnuradio/integer_math.h 20*4882a593Smuzhiyun 21*4882a593Smuzhiyundiff --git a/gnuradio-runtime/include/gnuradio/CMakeLists.txt b/gnuradio-runtime/include/gnuradio/CMakeLists.txt 22*4882a593Smuzhiyunindex 8d718e87b5b..056af5d6f48 100644 23*4882a593Smuzhiyun--- a/gnuradio-runtime/include/gnuradio/CMakeLists.txt 24*4882a593Smuzhiyun+++ b/gnuradio-runtime/include/gnuradio/CMakeLists.txt 25*4882a593Smuzhiyun@@ -31,6 +31,7 @@ install(FILES 26*4882a593Smuzhiyun gr_complex.h 27*4882a593Smuzhiyun hier_block2.h 28*4882a593Smuzhiyun high_res_timer.h 29*4882a593Smuzhiyun+ integer_math.h 30*4882a593Smuzhiyun io_signature.h 31*4882a593Smuzhiyun logger.h 32*4882a593Smuzhiyun math.h 33*4882a593Smuzhiyundiff --git a/gnuradio-runtime/include/gnuradio/integer_math.h b/gnuradio-runtime/include/gnuradio/integer_math.h 34*4882a593Smuzhiyunnew file mode 100644 35*4882a593Smuzhiyunindex 00000000000..15141049fa4 36*4882a593Smuzhiyun--- /dev/null 37*4882a593Smuzhiyun+++ b/gnuradio-runtime/include/gnuradio/integer_math.h 38*4882a593Smuzhiyun@@ -0,0 +1,35 @@ 39*4882a593Smuzhiyun+/* -*- c++ -*- */ 40*4882a593Smuzhiyun+/* 41*4882a593Smuzhiyun+ * Copyright 2020 Free Software Foundation, Inc. 42*4882a593Smuzhiyun+ * 43*4882a593Smuzhiyun+ * This file is part of GNU Radio 44*4882a593Smuzhiyun+ * 45*4882a593Smuzhiyun+ * SPDX-License-Identifier: GPL-3.0-or-later 46*4882a593Smuzhiyun+ * 47*4882a593Smuzhiyun+ */ 48*4882a593Smuzhiyun+#ifndef INCLUDED_GR_INTEGER_MATH_H 49*4882a593Smuzhiyun+#define INCLUDED_GR_INTEGER_MATH_H 50*4882a593Smuzhiyun+ 51*4882a593Smuzhiyun+#if (__cplusplus >= 201703L) 52*4882a593Smuzhiyun+ 53*4882a593Smuzhiyun+// Prefer C++17 goodness. 54*4882a593Smuzhiyun+#include <numeric> 55*4882a593Smuzhiyun+#define GR_GCD std::gcd 56*4882a593Smuzhiyun+#define GR_LCM std::lcm 57*4882a593Smuzhiyun+ 58*4882a593Smuzhiyun+#elif (BOOST_VERSION >= 105800) 59*4882a593Smuzhiyun+ 60*4882a593Smuzhiyun+// Fallback: newer boost API (introduced in Boost 1.58.0). 61*4882a593Smuzhiyun+#include <boost/integer/common_factor_rt.hpp> 62*4882a593Smuzhiyun+#define GR_GCD boost::integer::gcd 63*4882a593Smuzhiyun+#define GR_LCM boost::integer::lcm 64*4882a593Smuzhiyun+ 65*4882a593Smuzhiyun+#else 66*4882a593Smuzhiyun+ 67*4882a593Smuzhiyun+// Last resort: old deprecated boost API. 68*4882a593Smuzhiyun+#include <boost/math/common_factor_rt.hpp> 69*4882a593Smuzhiyun+#define GR_GCD boost::math::gcd 70*4882a593Smuzhiyun+#define GR_LCM boost::math::lcm 71*4882a593Smuzhiyun+ 72*4882a593Smuzhiyun+#endif /* __cplusplus >= 201703L */ 73*4882a593Smuzhiyun+#endif /* INCLUDED_GR_INTEGER_MATH_H */ 74*4882a593Smuzhiyundiff --git a/gnuradio-runtime/lib/buffer.cc b/gnuradio-runtime/lib/buffer.cc 75*4882a593Smuzhiyunindex 720c72c4ee8..46d704542b1 100644 76*4882a593Smuzhiyun--- a/gnuradio-runtime/lib/buffer.cc 77*4882a593Smuzhiyun+++ b/gnuradio-runtime/lib/buffer.cc 78*4882a593Smuzhiyun@@ -13,22 +13,13 @@ 79*4882a593Smuzhiyun #endif 80*4882a593Smuzhiyun #include "vmcircbuf.h" 81*4882a593Smuzhiyun #include <gnuradio/buffer.h> 82*4882a593Smuzhiyun+#include <gnuradio/integer_math.h> 83*4882a593Smuzhiyun #include <gnuradio/math.h> 84*4882a593Smuzhiyun #include <assert.h> 85*4882a593Smuzhiyun #include <algorithm> 86*4882a593Smuzhiyun #include <iostream> 87*4882a593Smuzhiyun #include <stdexcept> 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun-// the following header is deprecated as of Boost 1.66.0, and the 90*4882a593Smuzhiyun-// other API was introduced in Boost 1.58.0. Since we still support 91*4882a593Smuzhiyun-// Boost back to 1.54.0, use the older API if pre-1.5.80 and otherwise 92*4882a593Smuzhiyun-// use the newer API. 93*4882a593Smuzhiyun-#if (BOOST_VERSION < 105800) 94*4882a593Smuzhiyun-#include <boost/math/common_factor_rt.hpp> 95*4882a593Smuzhiyun-#else 96*4882a593Smuzhiyun-#include <boost/integer/common_factor_rt.hpp> 97*4882a593Smuzhiyun-#endif 98*4882a593Smuzhiyun- 99*4882a593Smuzhiyun namespace gr { 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun static long s_buffer_count = 0; // counts for debugging storage mgmt 102*4882a593Smuzhiyun@@ -68,13 +59,9 @@ static long s_buffer_reader_count = 0; 103*4882a593Smuzhiyun * 104*4882a593Smuzhiyun * type_size * nitems == k * page_size 105*4882a593Smuzhiyun */ 106*4882a593Smuzhiyun-static long minimum_buffer_items(long type_size, long page_size) 107*4882a593Smuzhiyun+static inline long minimum_buffer_items(long type_size, long page_size) 108*4882a593Smuzhiyun { 109*4882a593Smuzhiyun-#if (BOOST_VERSION < 105800) 110*4882a593Smuzhiyun- return page_size / boost::math::gcd(type_size, page_size); 111*4882a593Smuzhiyun-#else 112*4882a593Smuzhiyun- return page_size / boost::integer::gcd(type_size, page_size); 113*4882a593Smuzhiyun-#endif 114*4882a593Smuzhiyun+ return page_size / GR_GCD(type_size, page_size); 115*4882a593Smuzhiyun } 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun 118*4882a593Smuzhiyundiff --git a/gr-digital/lib/symbol_sync_cc_impl.cc b/gr-digital/lib/symbol_sync_cc_impl.cc 119*4882a593Smuzhiyunindex 55f85e7c6a7..55f162dc727 100644 120*4882a593Smuzhiyun--- a/gr-digital/lib/symbol_sync_cc_impl.cc 121*4882a593Smuzhiyun+++ b/gr-digital/lib/symbol_sync_cc_impl.cc 122*4882a593Smuzhiyun@@ -13,9 +13,9 @@ 123*4882a593Smuzhiyun #endif 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun #include "symbol_sync_cc_impl.h" 126*4882a593Smuzhiyun+#include <gnuradio/integer_math.h> 127*4882a593Smuzhiyun #include <gnuradio/io_signature.h> 128*4882a593Smuzhiyun #include <gnuradio/math.h> 129*4882a593Smuzhiyun-#include <boost/math/common_factor.hpp> 130*4882a593Smuzhiyun #include <stdexcept> 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun namespace gr { 133*4882a593Smuzhiyun@@ -95,7 +95,7 @@ symbol_sync_cc_impl::symbol_sync_cc_impl(enum ted_type detector_type, 134*4882a593Smuzhiyun throw std::runtime_error("unable to create interpolating_resampler_ccf"); 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun // Block Internal Clocks 137*4882a593Smuzhiyun- d_interps_per_symbol_n = boost::math::lcm(d_ted->inputs_per_symbol(), d_osps_n); 138*4882a593Smuzhiyun+ d_interps_per_symbol_n = GR_LCM(d_ted->inputs_per_symbol(), d_osps_n); 139*4882a593Smuzhiyun d_interps_per_ted_input_n = d_interps_per_symbol_n / d_ted->inputs_per_symbol(); 140*4882a593Smuzhiyun d_interps_per_output_sample_n = d_interps_per_symbol_n / d_osps_n; 141*4882a593Smuzhiyun 142*4882a593Smuzhiyundiff --git a/gr-digital/lib/symbol_sync_ff_impl.cc b/gr-digital/lib/symbol_sync_ff_impl.cc 143*4882a593Smuzhiyunindex d0ec32ab192..1172c1b4f8a 100644 144*4882a593Smuzhiyun--- a/gr-digital/lib/symbol_sync_ff_impl.cc 145*4882a593Smuzhiyun+++ b/gr-digital/lib/symbol_sync_ff_impl.cc 146*4882a593Smuzhiyun@@ -13,9 +13,9 @@ 147*4882a593Smuzhiyun #endif 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun #include "symbol_sync_ff_impl.h" 150*4882a593Smuzhiyun+#include <gnuradio/integer_math.h> 151*4882a593Smuzhiyun #include <gnuradio/io_signature.h> 152*4882a593Smuzhiyun #include <gnuradio/math.h> 153*4882a593Smuzhiyun-#include <boost/math/common_factor.hpp> 154*4882a593Smuzhiyun #include <stdexcept> 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun namespace gr { 157*4882a593Smuzhiyun@@ -97,7 +97,7 @@ symbol_sync_ff_impl::symbol_sync_ff_impl(enum ted_type detector_type, 158*4882a593Smuzhiyun throw std::runtime_error("unable to create interpolating_resampler_fff"); 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun // Block Internal Clocks 161*4882a593Smuzhiyun- d_interps_per_symbol_n = boost::math::lcm(d_ted->inputs_per_symbol(), d_osps_n); 162*4882a593Smuzhiyun+ d_interps_per_symbol_n = GR_LCM(d_ted->inputs_per_symbol(), d_osps_n); 163*4882a593Smuzhiyun d_interps_per_ted_input_n = d_interps_per_symbol_n / d_ted->inputs_per_symbol(); 164*4882a593Smuzhiyun d_interps_per_output_sample_n = d_interps_per_symbol_n / d_osps_n; 165*4882a593Smuzhiyun 166