boost: Fixes Boost.Math build for arm_xscale

This commit adds a new patch which fixes build issue with Boost.Math.
Issue is described in upstream PR boostorg/math#684 [1]

[1]: https://github.com/boostorg/math/pull/684

Signed-off-by: Carlos Miguel Ferreira <carlosmf.pt@gmail.com>
This commit is contained in:
Carlos Miguel Ferreira 2021-09-08 22:25:37 +01:00 committed by Rosen Penev
parent 21e5a1e7d3
commit f2280ae82e
1 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,178 @@
--- a/boost/math/special_functions/detail/bernoulli_details.hpp
+++ b/boost/math/special_functions/detail/bernoulli_details.hpp
@@ -360,7 +360,7 @@ public:
return out;
}
- #ifndef BOOST_HAS_THREADS
+ #if !defined(BOOST_HAS_THREADS) || defined(BOOST_MATH_BERNOULLI_UNTHREADED)
//
// Single threaded code, very simple:
//
@@ -382,6 +382,8 @@ public:
*out = (i >= m_overflow_limit) ? policies::raise_overflow_error<T>("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol) : bn[i];
++out;
}
+ #elif defined(BOOST_MATH_NO_ATOMIC_INT)
+ static_assert(sizeof(T) == 1, "Unsupported configuration: your platform appears to have no atomic integers. If you are happy with thread-unsafe code, then you may define BOOST_MATH_BERNOULLI_UNTHREADED to suppress this error.");
#else
//
// Double-checked locking pattern, lets us access cached already cached values
@@ -464,7 +466,7 @@ public:
return out;
}
- #ifndef BOOST_HAS_THREADS
+ #if !defined(BOOST_HAS_THREADS) || defined(BOOST_MATH_BERNOULLI_UNTHREADED)
//
// Single threaded code, very simple:
//
@@ -494,6 +496,8 @@ public:
}
++out;
}
+ #elif defined(BOOST_MATH_NO_ATOMIC_INT)
+ static_assert(sizeof(T) == 1, "Unsupported configuration: your platform appears to have no atomic integers. If you are happy with thread-unsafe code, then you may define BOOST_MATH_BERNOULLI_UNTHREADED to suppress this error.");
#else
//
// Double-checked locking pattern, lets us access cached already cached values
@@ -555,7 +559,7 @@ private:
// The value at which we know overflow has already occurred for the Bn:
std::size_t m_overflow_limit;
- #ifdef BOOST_HAS_THREADS
+ #if defined(BOOST_HAS_THREADS) && !defined(BOOST_MATH_NO_ATOMIC_INT)
std::mutex m_mutex;
atomic_counter_type m_counter, m_current_precision;
#else
--- a/boost/math/tools/atomic.hpp
+++ b/boost/math/tools/atomic.hpp
@@ -16,27 +16,27 @@
namespace boost {
namespace math {
namespace detail {
-#if ATOMIC_INT_LOCK_FREE == 2
+#if (ATOMIC_INT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
typedef std::atomic<int> atomic_counter_type;
typedef std::atomic<unsigned> atomic_unsigned_type;
typedef int atomic_integer_type;
typedef unsigned atomic_unsigned_integer_type;
-#elif ATOMIC_SHORT_LOCK_FREE == 2
+#elif (ATOMIC_SHORT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
typedef std::atomic<short> atomic_counter_type;
typedef std::atomic<unsigned short> atomic_unsigned_type;
typedef short atomic_integer_type;
typedef unsigned short atomic_unsigned_type;
-#elif ATOMIC_LONG_LOCK_FREE == 2
+#elif (ATOMIC_LONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
typedef std::atomic<long> atomic_unsigned_integer_type;
typedef std::atomic<unsigned long> atomic_unsigned_type;
typedef unsigned long atomic_unsigned_type;
typedef long atomic_integer_type;
-#elif ATOMIC_LLONG_LOCK_FREE == 2
+#elif (ATOMIC_LLONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
typedef std::atomic<long long> atomic_unsigned_integer_type;
typedef std::atomic<unsigned long long> atomic_unsigned_type;
typedef long long atomic_integer_type;
typedef unsigned long long atomic_unsigned_integer_type;
-#else
+#elif !defined(BOOST_MATH_NO_ATOMIC_INT)
# define BOOST_MATH_NO_ATOMIC_INT
#endif
} // Namespace detail
--- a/libs/math/test/Jamfile.v2
+++ b/libs/math/test/Jamfile.v2
@@ -121,6 +121,13 @@ test-suite special_fun :
[ run hypot_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run pow_test.cpp ../../test/build//boost_unit_test_framework ]
+ [ run ccmath_sqrt_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
+ [ run ccmath_isinf_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
+ [ run ccmath_isnan_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
+ [ run ccmath_abs_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
+ [ run ccmath_isfinite_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
+ [ run ccmath_isnormal_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
+ [ run ccmath_fpclassify_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
[ run log1p_expm1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run powm1_sqrtp1m1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run special_functions_test.cpp ../../test/build//boost_unit_test_framework ]
@@ -870,6 +877,7 @@ test-suite mp :
;
test-suite misc :
+ [ run header_deprecated_test.cpp ]
[ run threading_sanity_check.cpp ]
[ run test_tr1.cpp
../build//boost_math_tr1
@@ -1137,6 +1145,9 @@ test-suite misc :
# [ run __temporary_test.cpp test_instances//test_instances : : : <test-info>always_show_run_output <pch>off ]
[ compile test_no_long_double_policy.cpp ]
+ [ compile bernoulli_no_atomic_d.cpp ]
+ [ compile bernoulli_no_atomic_mp.cpp ]
+ [ compile-fail bernoulli_no_atomic_fail.cpp ]
;
test-suite interpolators :
@@ -1163,6 +1174,7 @@ test-suite interpolators :
[ run quintic_hermite_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : <linkflags>-lquadmath ] ]
[ run cubic_hermite_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : <linkflags>-lquadmath ] ]
[ run bilinear_uniform_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ]
+ [ run bezier_polynomial_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : <linkflags>-lquadmath ] ]
[ run catmull_rom_test.cpp ../../test/build//boost_unit_test_framework : : : <define>TEST=1 [ requires cxx11_hdr_array cxx11_hdr_initializer_list ] : catmull_rom_test_1 ]
[ run catmull_rom_test.cpp ../../test/build//boost_unit_test_framework : : : <define>TEST=2 [ requires cxx11_hdr_array cxx11_hdr_initializer_list ] : catmull_rom_test_2 ]
[ run catmull_rom_test.cpp ../../test/build//boost_unit_test_framework : : : <define>TEST=3 [ requires cxx11_hdr_array cxx11_hdr_initializer_list ] : catmull_rom_test_3 ]
--- /dev/null
+++ b/libs/math/test/bernoulli_no_atomic_d.cpp
@@ -0,0 +1,14 @@
+// (C) Copyright John Maddock 2021.
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_MATH_NO_ATOMIC_INT
+
+#include <boost/math/special_functions/bernoulli.hpp>
+#include "compile_test/test_compile_result.hpp"
+
+void compile_and_link_test()
+{
+ check_result<double>(boost::math::bernoulli_b2n<double>(4));
+}
--- /dev/null
+++ b/libs/math/test/bernoulli_no_atomic_fail.cpp
@@ -0,0 +1,15 @@
+// (C) Copyright John Maddock 2021.
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_MATH_NO_ATOMIC_INT
+
+#include <boost/math/special_functions/bernoulli.hpp>
+#include <boost/multiprecision/cpp_bin_float.hpp>
+#include "compile_test/test_compile_result.hpp"
+
+void compile_and_link_test()
+{
+ check_result<boost::multiprecision::cpp_bin_float_50>(boost::math::bernoulli_b2n<boost::multiprecision::cpp_bin_float_50>(4));
+}
--- /dev/null
+++ b/libs/math/test/bernoulli_no_atomic_mp.cpp
@@ -0,0 +1,16 @@
+// (C) Copyright John Maddock 2021.
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_MATH_NO_ATOMIC_INT
+#define BOOST_MATH_BERNOULLI_UNTHREADED
+
+#include <boost/math/special_functions/bernoulli.hpp>
+#include <boost/multiprecision/cpp_bin_float.hpp>
+#include "compile_test/test_compile_result.hpp"
+
+void compile_and_link_test()
+{
+ check_result<boost::multiprecision::cpp_bin_float_50>(boost::math::bernoulli_b2n<boost::multiprecision::cpp_bin_float_50>(4));
+}