summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/include/gnuradio
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/include/gnuradio')
-rw-r--r--gnuradio-runtime/include/gnuradio/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/include/gnuradio/integer_math.h35
2 files changed, 36 insertions, 0 deletions
diff --git a/gnuradio-runtime/include/gnuradio/CMakeLists.txt b/gnuradio-runtime/include/gnuradio/CMakeLists.txt
index 8d718e87b5..056af5d6f4 100644
--- a/gnuradio-runtime/include/gnuradio/CMakeLists.txt
+++ b/gnuradio-runtime/include/gnuradio/CMakeLists.txt
@@ -31,6 +31,7 @@ install(FILES
gr_complex.h
hier_block2.h
high_res_timer.h
+ integer_math.h
io_signature.h
logger.h
math.h
diff --git a/gnuradio-runtime/include/gnuradio/integer_math.h b/gnuradio-runtime/include/gnuradio/integer_math.h
new file mode 100644
index 0000000000..15141049fa
--- /dev/null
+++ b/gnuradio-runtime/include/gnuradio/integer_math.h
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#ifndef INCLUDED_GR_INTEGER_MATH_H
+#define INCLUDED_GR_INTEGER_MATH_H
+
+#if (__cplusplus >= 201703L)
+
+// Prefer C++17 goodness.
+#include <numeric>
+#define GR_GCD std::gcd
+#define GR_LCM std::lcm
+
+#elif (BOOST_VERSION >= 105800)
+
+// Fallback: newer boost API (introduced in Boost 1.58.0).
+#include <boost/integer/common_factor_rt.hpp>
+#define GR_GCD boost::integer::gcd
+#define GR_LCM boost::integer::lcm
+
+#else
+
+// Last resort: old deprecated boost API.
+#include <boost/math/common_factor_rt.hpp>
+#define GR_GCD boost::math::gcd
+#define GR_LCM boost::math::lcm
+
+#endif /* __cplusplus >= 201703L */
+#endif /* INCLUDED_GR_INTEGER_MATH_H */