You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
8.7 KiB

  1. --- a/boost/math/special_functions/detail/bernoulli_details.hpp
  2. +++ b/boost/math/special_functions/detail/bernoulli_details.hpp
  3. @@ -360,7 +360,7 @@ public:
  4. return out;
  5. }
  6. - #ifndef BOOST_HAS_THREADS
  7. + #if !defined(BOOST_HAS_THREADS) || defined(BOOST_MATH_BERNOULLI_UNTHREADED)
  8. //
  9. // Single threaded code, very simple:
  10. //
  11. @@ -382,6 +382,8 @@ public:
  12. *out = (i >= m_overflow_limit) ? policies::raise_overflow_error<T>("boost::math::bernoulli_b2n<%1%>(std::size_t)", 0, T(i), pol) : bn[i];
  13. ++out;
  14. }
  15. + #elif defined(BOOST_MATH_NO_ATOMIC_INT)
  16. + 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.");
  17. #else
  18. //
  19. // Double-checked locking pattern, lets us access cached already cached values
  20. @@ -464,7 +466,7 @@ public:
  21. return out;
  22. }
  23. - #ifndef BOOST_HAS_THREADS
  24. + #if !defined(BOOST_HAS_THREADS) || defined(BOOST_MATH_BERNOULLI_UNTHREADED)
  25. //
  26. // Single threaded code, very simple:
  27. //
  28. @@ -494,6 +496,8 @@ public:
  29. }
  30. ++out;
  31. }
  32. + #elif defined(BOOST_MATH_NO_ATOMIC_INT)
  33. + 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.");
  34. #else
  35. //
  36. // Double-checked locking pattern, lets us access cached already cached values
  37. @@ -555,7 +559,7 @@ private:
  38. // The value at which we know overflow has already occurred for the Bn:
  39. std::size_t m_overflow_limit;
  40. - #ifdef BOOST_HAS_THREADS
  41. + #if defined(BOOST_HAS_THREADS) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  42. std::mutex m_mutex;
  43. atomic_counter_type m_counter, m_current_precision;
  44. #else
  45. --- a/boost/math/tools/atomic.hpp
  46. +++ b/boost/math/tools/atomic.hpp
  47. @@ -16,27 +16,27 @@
  48. namespace boost {
  49. namespace math {
  50. namespace detail {
  51. -#if ATOMIC_INT_LOCK_FREE == 2
  52. +#if (ATOMIC_INT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  53. typedef std::atomic<int> atomic_counter_type;
  54. typedef std::atomic<unsigned> atomic_unsigned_type;
  55. typedef int atomic_integer_type;
  56. typedef unsigned atomic_unsigned_integer_type;
  57. -#elif ATOMIC_SHORT_LOCK_FREE == 2
  58. +#elif (ATOMIC_SHORT_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  59. typedef std::atomic<short> atomic_counter_type;
  60. typedef std::atomic<unsigned short> atomic_unsigned_type;
  61. typedef short atomic_integer_type;
  62. typedef unsigned short atomic_unsigned_type;
  63. -#elif ATOMIC_LONG_LOCK_FREE == 2
  64. +#elif (ATOMIC_LONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  65. typedef std::atomic<long> atomic_unsigned_integer_type;
  66. typedef std::atomic<unsigned long> atomic_unsigned_type;
  67. typedef unsigned long atomic_unsigned_type;
  68. typedef long atomic_integer_type;
  69. -#elif ATOMIC_LLONG_LOCK_FREE == 2
  70. +#elif (ATOMIC_LLONG_LOCK_FREE == 2) && !defined(BOOST_MATH_NO_ATOMIC_INT)
  71. typedef std::atomic<long long> atomic_unsigned_integer_type;
  72. typedef std::atomic<unsigned long long> atomic_unsigned_type;
  73. typedef long long atomic_integer_type;
  74. typedef unsigned long long atomic_unsigned_integer_type;
  75. -#else
  76. +#elif !defined(BOOST_MATH_NO_ATOMIC_INT)
  77. # define BOOST_MATH_NO_ATOMIC_INT
  78. #endif
  79. } // Namespace detail
  80. --- a/libs/math/test/Jamfile.v2
  81. +++ b/libs/math/test/Jamfile.v2
  82. @@ -121,6 +121,13 @@ test-suite special_fun :
  83. [ run hypot_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
  84. [ run pow_test.cpp ../../test/build//boost_unit_test_framework ]
  85. + [ run ccmath_sqrt_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
  86. + [ run ccmath_isinf_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
  87. + [ run ccmath_isnan_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
  88. + [ run ccmath_abs_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
  89. + [ run ccmath_isfinite_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
  90. + [ run ccmath_isnormal_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
  91. + [ run ccmath_fpclassify_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
  92. [ run log1p_expm1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
  93. [ run powm1_sqrtp1m1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
  94. [ run special_functions_test.cpp ../../test/build//boost_unit_test_framework ]
  95. @@ -870,6 +877,7 @@ test-suite mp :
  96. ;
  97. test-suite misc :
  98. + [ run header_deprecated_test.cpp ]
  99. [ run threading_sanity_check.cpp ]
  100. [ run test_tr1.cpp
  101. ../build//boost_math_tr1
  102. @@ -1137,6 +1145,9 @@ test-suite misc :
  103. # [ run __temporary_test.cpp test_instances//test_instances : : : <test-info>always_show_run_output <pch>off ]
  104. [ compile test_no_long_double_policy.cpp ]
  105. + [ compile bernoulli_no_atomic_d.cpp ]
  106. + [ compile bernoulli_no_atomic_mp.cpp ]
  107. + [ compile-fail bernoulli_no_atomic_fail.cpp ]
  108. ;
  109. test-suite interpolators :
  110. @@ -1163,6 +1174,7 @@ test-suite interpolators :
  111. [ 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 ] ]
  112. [ 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 ] ]
  113. [ run bilinear_uniform_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] ]
  114. + [ 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 ] ]
  115. [ 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 ]
  116. [ 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 ]
  117. [ 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 ]
  118. --- /dev/null
  119. +++ b/libs/math/test/bernoulli_no_atomic_d.cpp
  120. @@ -0,0 +1,14 @@
  121. +// (C) Copyright John Maddock 2021.
  122. +// Use, modification and distribution are subject to the
  123. +// Boost Software License, Version 1.0. (See accompanying file
  124. +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  125. +
  126. +#define BOOST_MATH_NO_ATOMIC_INT
  127. +
  128. +#include <boost/math/special_functions/bernoulli.hpp>
  129. +#include "compile_test/test_compile_result.hpp"
  130. +
  131. +void compile_and_link_test()
  132. +{
  133. + check_result<double>(boost::math::bernoulli_b2n<double>(4));
  134. +}
  135. --- /dev/null
  136. +++ b/libs/math/test/bernoulli_no_atomic_fail.cpp
  137. @@ -0,0 +1,15 @@
  138. +// (C) Copyright John Maddock 2021.
  139. +// Use, modification and distribution are subject to the
  140. +// Boost Software License, Version 1.0. (See accompanying file
  141. +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  142. +
  143. +#define BOOST_MATH_NO_ATOMIC_INT
  144. +
  145. +#include <boost/math/special_functions/bernoulli.hpp>
  146. +#include <boost/multiprecision/cpp_bin_float.hpp>
  147. +#include "compile_test/test_compile_result.hpp"
  148. +
  149. +void compile_and_link_test()
  150. +{
  151. + check_result<boost::multiprecision::cpp_bin_float_50>(boost::math::bernoulli_b2n<boost::multiprecision::cpp_bin_float_50>(4));
  152. +}
  153. --- /dev/null
  154. +++ b/libs/math/test/bernoulli_no_atomic_mp.cpp
  155. @@ -0,0 +1,16 @@
  156. +// (C) Copyright John Maddock 2021.
  157. +// Use, modification and distribution are subject to the
  158. +// Boost Software License, Version 1.0. (See accompanying file
  159. +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  160. +
  161. +#define BOOST_MATH_NO_ATOMIC_INT
  162. +#define BOOST_MATH_BERNOULLI_UNTHREADED
  163. +
  164. +#include <boost/math/special_functions/bernoulli.hpp>
  165. +#include <boost/multiprecision/cpp_bin_float.hpp>
  166. +#include "compile_test/test_compile_result.hpp"
  167. +
  168. +void compile_and_link_test()
  169. +{
  170. + check_result<boost::multiprecision::cpp_bin_float_50>(boost::math::bernoulli_b2n<boost::multiprecision::cpp_bin_float_50>(4));
  171. +}