config.hpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. // Copyright (c) 2006-7 John Maddock
  2. // Copyright (c) 2021 Matt Borland
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_MATH_TOOLS_CONFIG_HPP
  7. #define BOOST_MATH_TOOLS_CONFIG_HPP
  8. #ifdef _MSC_VER
  9. #pragma once
  10. #endif
  11. #include <boost/math/tools/is_standalone.hpp>
  12. // Minimum language standard transition
  13. #ifdef _MSVC_LANG
  14. # if _MSVC_LANG < 201402L
  15. # pragma message("Boost.Math requires C++14");
  16. # endif
  17. # if _MSC_VER == 1900
  18. # pragma message("MSVC 14.0 has broken C++14 constexpr support. Support for this compiler will be removed in Boost 1.86")
  19. # endif
  20. #else
  21. # if __cplusplus < 201402L
  22. # warning "Boost.Math requires C++14"
  23. # endif
  24. #endif
  25. #ifndef BOOST_MATH_STANDALONE
  26. #include <boost/config.hpp>
  27. // The following are all defined as standalone macros as well
  28. // If Boost.Config is available just use those definitions because they are more fine-grained
  29. // Could be defined in TR1
  30. #ifndef BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
  31. # define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION BOOST_PREVENT_MACRO_SUBSTITUTION
  32. #endif
  33. #define BOOST_MATH_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
  34. #ifdef BOOST_NO_CXX14_CONSTEXPR
  35. # define BOOST_MATH_NO_CXX14_CONSTEXPR
  36. #endif
  37. #define BOOST_MATH_IF_CONSTEXPR BOOST_IF_CONSTEXPR
  38. #ifdef BOOST_NO_CXX17_IF_CONSTEXPR
  39. # define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
  40. #endif
  41. #ifdef BOOST_NO_CXX17_HDR_EXECUTION
  42. # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
  43. #endif
  44. #ifdef BOOST_HAS_THREADS
  45. # define BOOST_MATH_HAS_THREADS
  46. #endif
  47. #ifdef BOOST_DISABLE_THREADS
  48. # define BOOST_MATH_DISABLE_THREADS
  49. #endif
  50. #ifdef BOOST_NO_CXX11_THREAD_LOCAL
  51. # define BOOST_MATH_NO_CXX11_THREAD_LOCAL
  52. #endif
  53. #ifdef BOOST_NO_EXCEPTIONS
  54. # define BOOST_MATH_NO_EXCEPTIONS
  55. #endif
  56. #ifdef BOOST_NO_TYPEID
  57. # define BOOST_MATH_NO_TYPEID
  58. #endif
  59. #ifdef BOOST_NO_RTTI
  60. # define BOOST_MATH_NO_RTTI
  61. #endif
  62. #define BOOST_MATH_NOINLINE BOOST_NOINLINE
  63. #define BOOST_MATH_FORCEINLINE BOOST_FORCEINLINE
  64. #define BOOST_MATH_JOIN(X, Y) BOOST_JOIN(X, Y)
  65. #define BOOST_MATH_STRINGIZE(X) BOOST_STRINGIZE(X)
  66. #else // Things from boost/config that are required, and easy to replicate
  67. #define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
  68. #define BOOST_MATH_NO_REAL_CONCEPT_TESTS
  69. #define BOOST_MATH_NO_DISTRIBUTION_CONCEPT_TESTS
  70. #define BOOST_MATH_NO_LEXICAL_CAST
  71. // Since Boost.Multiprecision is in active development some tests do not fully cooperate yet.
  72. #define BOOST_MATH_NO_MP_TESTS
  73. #if (__cplusplus > 201400L || _MSVC_LANG > 201400L)
  74. #define BOOST_MATH_CXX14_CONSTEXPR constexpr
  75. #else
  76. #define BOOST_MATH_CXX14_CONSTEXPR
  77. #define BOOST_MATH_NO_CXX14_CONSTEXPR
  78. #endif // BOOST_MATH_CXX14_CONSTEXPR
  79. #if (__cplusplus > 201700L || _MSVC_LANG > 201700L)
  80. #define BOOST_MATH_IF_CONSTEXPR if constexpr
  81. // Clang on mac provides the execution header with none of the functionality. TODO: Check back on this
  82. // https://en.cppreference.com/w/cpp/compiler_support "Standardization of Parallelism TS"
  83. # if !__has_include(<execution>) || (defined(__APPLE__) && defined(__clang__))
  84. # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
  85. # endif
  86. #else
  87. # define BOOST_MATH_IF_CONSTEXPR if
  88. # define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
  89. # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
  90. #endif
  91. #if __cpp_lib_gcd_lcm >= 201606L
  92. #define BOOST_MATH_HAS_CXX17_NUMERIC
  93. #endif
  94. #define BOOST_MATH_JOIN(X, Y) BOOST_MATH_DO_JOIN(X, Y)
  95. #define BOOST_MATH_DO_JOIN(X, Y) BOOST_MATH_DO_JOIN2(X,Y)
  96. #define BOOST_MATH_DO_JOIN2(X, Y) X##Y
  97. #define BOOST_MATH_STRINGIZE(X) BOOST_MATH_DO_STRINGIZE(X)
  98. #define BOOST_MATH_DO_STRINGIZE(X) #X
  99. #ifdef BOOST_MATH_DISABLE_THREADS // No threads, do nothing
  100. // Detect thread support via STL implementation
  101. #elif defined(__has_include)
  102. # if !__has_include(<thread>) || !__has_include(<mutex>) || !__has_include(<future>) || !__has_include(<atomic>)
  103. # define BOOST_MATH_DISABLE_THREADS
  104. # else
  105. # define BOOST_MATH_HAS_THREADS
  106. # endif
  107. #else
  108. # define BOOST_MATH_HAS_THREADS // The default assumption is that the machine has threads
  109. #endif // Thread Support
  110. #ifdef BOOST_MATH_DISABLE_THREADS
  111. # define BOOST_MATH_NO_CXX11_THREAD_LOCAL
  112. #endif // BOOST_MATH_DISABLE_THREADS
  113. #ifdef __GNUC__
  114. # if !defined(__EXCEPTIONS) && !defined(BOOST_MATH_NO_EXCEPTIONS)
  115. # define BOOST_MATH_NO_EXCEPTIONS
  116. # endif
  117. //
  118. // Make sure we have some std lib headers included so we can detect __GXX_RTTI:
  119. //
  120. # include <algorithm> // for min and max
  121. # include <limits>
  122. # ifndef __GXX_RTTI
  123. # ifndef BOOST_MATH_NO_TYPEID
  124. # define BOOST_MATH_NO_TYPEID
  125. # endif
  126. # ifndef BOOST_MATH_NO_RTTI
  127. # define BOOST_MATH_NO_RTTI
  128. # endif
  129. # endif
  130. #endif
  131. #if !defined(BOOST_MATH_NOINLINE)
  132. # if defined(_MSC_VER)
  133. # define BOOST_MATH_NOINLINE __declspec(noinline)
  134. # elif defined(__GNUC__) && __GNUC__ > 3
  135. // Clang also defines __GNUC__ (as 4)
  136. # if defined(__CUDACC__)
  137. // nvcc doesn't always parse __noinline__,
  138. // see: https://svn.boost.org/trac/boost/ticket/9392
  139. # define BOOST_MATH_NOINLINE __attribute__ ((noinline))
  140. # elif defined(__HIP__)
  141. // See https://github.com/boostorg/config/issues/392
  142. # define BOOST_MATH_NOINLINE __attribute__ ((noinline))
  143. # else
  144. # define BOOST_MATH_NOINLINE __attribute__ ((__noinline__))
  145. # endif
  146. # else
  147. # define BOOST_MATH_NOINLINE
  148. # endif
  149. #endif
  150. #if !defined(BOOST_MATH_FORCEINLINE)
  151. # if defined(_MSC_VER)
  152. # define BOOST_MATH_FORCEINLINE __forceinline
  153. # elif defined(__GNUC__) && __GNUC__ > 3
  154. // Clang also defines __GNUC__ (as 4)
  155. # define BOOST_MATH_FORCEINLINE inline __attribute__ ((__always_inline__))
  156. # else
  157. # define BOOST_MATH_FORCEINLINE inline
  158. # endif
  159. #endif
  160. #endif // BOOST_MATH_STANDALONE
  161. // Support compilers with P0024R2 implemented without linking TBB
  162. // https://en.cppreference.com/w/cpp/compiler_support
  163. #if !defined(BOOST_MATH_NO_CXX17_HDR_EXECUTION) && defined(BOOST_MATH_HAS_THREADS)
  164. # define BOOST_MATH_EXEC_COMPATIBLE
  165. #endif
  166. // C++23
  167. #if __cplusplus > 202002L || (defined(_MSVC_LANG) &&_MSVC_LANG > 202002L)
  168. # if __GNUC__ >= 13
  169. // libstdc++3 only defines to/from_chars for std::float128_t when one of these defines are set
  170. // otherwise we're right out of luck...
  171. # if defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) || defined(_GLIBCXX_HAVE_FLOAT128_MATH)
  172. # include <cstring> // std::strlen is used with from_chars
  173. # include <charconv>
  174. # include <stdfloat>
  175. # define BOOST_MATH_USE_CHARCONV_FOR_CONVERSION
  176. # endif
  177. # endif
  178. #endif
  179. #include <algorithm> // for min and max
  180. #include <limits>
  181. #include <cmath>
  182. #include <climits>
  183. #include <cfloat>
  184. #include <boost/math/tools/user.hpp>
  185. #if (defined(__NetBSD__) || defined(__EMSCRIPTEN__)\
  186. || (defined(__hppa) && !defined(__OpenBSD__)) || (defined(__NO_LONG_DOUBLE_MATH) && (DBL_MANT_DIG != LDBL_MANT_DIG))) \
  187. && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  188. //# define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  189. #endif
  190. #ifdef __IBMCPP__
  191. //
  192. // For reasons I don't understand, the tests with IMB's compiler all
  193. // pass at long double precision, but fail with real_concept, those tests
  194. // are disabled for now. (JM 2012).
  195. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  196. # define BOOST_MATH_NO_REAL_CONCEPT_TESTS
  197. #endif // BOOST_MATH_NO_REAL_CONCEPT_TESTS
  198. #endif
  199. #ifdef sun
  200. // Any use of __float128 in program startup code causes a segfault (tested JM 2015, Solaris 11).
  201. # define BOOST_MATH_DISABLE_FLOAT128
  202. #endif
  203. #ifdef __HAIKU__
  204. //
  205. // Not sure what's up with the math detection on Haiku, but linking fails with
  206. // float128 code enabled, and we don't have an implementation of __expl, so
  207. // disabling long double functions for now as well.
  208. # define BOOST_MATH_DISABLE_FLOAT128
  209. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  210. #endif
  211. #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  212. //
  213. // Darwin's rather strange "double double" is rather hard to
  214. // support, it should be possible given enough effort though...
  215. //
  216. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  217. #endif
  218. #if !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) && (LDBL_MANT_DIG == 106) && (LDBL_MIN_EXP > DBL_MIN_EXP)
  219. //
  220. // Generic catch all case for gcc's "double-double" long double type.
  221. // We do not support this as it's not even remotely IEEE conforming:
  222. //
  223. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  224. #endif
  225. #if defined(unix) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER <= 1000) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  226. //
  227. // Intel compiler prior to version 10 has sporadic problems
  228. // calling the long double overloads of the std lib math functions:
  229. // calling ::powl is OK, but std::pow(long double, long double)
  230. // may segfault depending upon the value of the arguments passed
  231. // and the specific Linux distribution.
  232. //
  233. // We'll be conservative and disable long double support for this compiler.
  234. //
  235. // Comment out this #define and try building the tests to determine whether
  236. // your Intel compiler version has this issue or not.
  237. //
  238. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  239. #endif
  240. #if defined(unix) && defined(__INTEL_COMPILER)
  241. //
  242. // Intel compiler has sporadic issues compiling std::fpclassify depending on
  243. // the exact OS version used. Use our own code for this as we know it works
  244. // well on Intel processors:
  245. //
  246. #define BOOST_MATH_DISABLE_STD_FPCLASSIFY
  247. #endif
  248. #if defined(_MSC_VER) && !defined(_WIN32_WCE)
  249. // Better safe than sorry, our tests don't support hardware exceptions:
  250. # define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
  251. #endif
  252. #ifdef __IBMCPP__
  253. # define BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS
  254. #endif
  255. #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901))
  256. # define BOOST_MATH_USE_C99
  257. #endif
  258. #if (defined(__hpux) && !defined(__hppa))
  259. # define BOOST_MATH_USE_C99
  260. #endif
  261. #if defined(__GNUC__) && defined(_GLIBCXX_USE_C99)
  262. # define BOOST_MATH_USE_C99
  263. #endif
  264. #if defined(_LIBCPP_VERSION) && !defined(_MSC_VER)
  265. # define BOOST_MATH_USE_C99
  266. #endif
  267. #if defined(__CYGWIN__) || defined(__HP_aCC) || defined(__INTEL_COMPILER) \
  268. || defined(BOOST_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY) \
  269. || (defined(__GNUC__) && !defined(BOOST_MATH_USE_C99))\
  270. || defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  271. # define BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY
  272. #endif
  273. #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x590)
  274. namespace boost { namespace math { namespace tools { namespace detail {
  275. template <typename T>
  276. struct type {};
  277. template <typename T, T n>
  278. struct non_type {};
  279. }}}} // Namespace boost, math tools, detail
  280. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t) boost::math::tools::detail::type<t>* = 0
  281. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::math::tools::detail::type<t>*
  282. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::math::tools::detail::non_type<t, v>* = 0
  283. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::math::tools::detail::non_type<t, v>*
  284. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \
  285. , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
  286. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \
  287. , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
  288. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \
  289. , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
  290. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \
  291. , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
  292. #else
  293. // no workaround needed: expand to nothing
  294. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
  295. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
  296. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
  297. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
  298. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
  299. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
  300. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
  301. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
  302. #endif // __SUNPRO_CC
  303. #if (defined(__SUNPRO_CC) || defined(__hppa) || defined(__GNUC__)) && !defined(BOOST_MATH_SMALL_CONSTANT)
  304. // Sun's compiler emits a hard error if a constant underflows,
  305. // as does aCC on PA-RISC, while gcc issues a large number of warnings:
  306. # define BOOST_MATH_SMALL_CONSTANT(x) 0.0
  307. #else
  308. # define BOOST_MATH_SMALL_CONSTANT(x) x
  309. #endif
  310. //
  311. // Tune performance options for specific compilers:
  312. //
  313. #ifdef _MSC_VER
  314. # define BOOST_MATH_POLY_METHOD 2
  315. #if _MSC_VER <= 1900
  316. # define BOOST_MATH_RATIONAL_METHOD 1
  317. #else
  318. # define BOOST_MATH_RATIONAL_METHOD 2
  319. #endif
  320. #if _MSC_VER > 1900
  321. # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
  322. # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
  323. #endif
  324. #elif defined(__INTEL_COMPILER)
  325. # define BOOST_MATH_POLY_METHOD 2
  326. # define BOOST_MATH_RATIONAL_METHOD 1
  327. #elif defined(__GNUC__)
  328. #if __GNUC__ < 4
  329. # define BOOST_MATH_POLY_METHOD 3
  330. # define BOOST_MATH_RATIONAL_METHOD 3
  331. # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
  332. # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
  333. #else
  334. # define BOOST_MATH_POLY_METHOD 3
  335. # define BOOST_MATH_RATIONAL_METHOD 3
  336. #endif
  337. #elif defined(__clang__)
  338. #if __clang__ > 6
  339. # define BOOST_MATH_POLY_METHOD 3
  340. # define BOOST_MATH_RATIONAL_METHOD 3
  341. # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
  342. # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
  343. #endif
  344. #endif
  345. //
  346. // noexcept support:
  347. //
  348. #include <type_traits>
  349. #define BOOST_MATH_NOEXCEPT(T) noexcept(std::is_floating_point<T>::value)
  350. #define BOOST_MATH_IS_FLOAT(T) (std::is_floating_point<T>::value)
  351. //
  352. // The maximum order of polynomial that will be evaluated
  353. // via an unrolled specialisation:
  354. //
  355. #ifndef BOOST_MATH_MAX_POLY_ORDER
  356. # define BOOST_MATH_MAX_POLY_ORDER 20
  357. #endif
  358. //
  359. // Set the method used to evaluate polynomials and rationals:
  360. //
  361. #ifndef BOOST_MATH_POLY_METHOD
  362. # define BOOST_MATH_POLY_METHOD 2
  363. #endif
  364. #ifndef BOOST_MATH_RATIONAL_METHOD
  365. # define BOOST_MATH_RATIONAL_METHOD 1
  366. #endif
  367. //
  368. // decide whether to store constants as integers or reals:
  369. //
  370. #ifndef BOOST_MATH_INT_TABLE_TYPE
  371. # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
  372. #endif
  373. #ifndef BOOST_MATH_INT_VALUE_SUFFIX
  374. # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF
  375. #endif
  376. //
  377. // And then the actual configuration:
  378. //
  379. #if defined(BOOST_MATH_STANDALONE) && defined(_GLIBCXX_USE_FLOAT128) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && !defined(__STRICT_ANSI__) \
  380. && !defined(BOOST_MATH_DISABLE_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128)
  381. # define BOOST_MATH_USE_FLOAT128
  382. #elif defined(BOOST_HAS_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128)
  383. # define BOOST_MATH_USE_FLOAT128
  384. #endif
  385. #ifdef BOOST_MATH_USE_FLOAT128
  386. //
  387. // Only enable this when the compiler really is GCC as clang and probably
  388. // intel too don't support __float128 yet :-(
  389. //
  390. # if defined(__INTEL_COMPILER) && defined(__GNUC__)
  391. # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
  392. # define BOOST_MATH_FLOAT128_TYPE __float128
  393. # endif
  394. # elif defined(__GNUC__)
  395. # define BOOST_MATH_FLOAT128_TYPE __float128
  396. # endif
  397. # ifndef BOOST_MATH_FLOAT128_TYPE
  398. # define BOOST_MATH_FLOAT128_TYPE _Quad
  399. # endif
  400. #endif
  401. //
  402. // Check for WinCE with no iostream support:
  403. //
  404. #if defined(_WIN32_WCE) && !defined(__SGI_STL_PORT)
  405. # define BOOST_MATH_NO_LEXICAL_CAST
  406. #endif
  407. //
  408. // Helper macro for controlling the FP behaviour:
  409. //
  410. #ifndef BOOST_MATH_CONTROL_FP
  411. # define BOOST_MATH_CONTROL_FP
  412. #endif
  413. //
  414. // Helper macro for using statements:
  415. //
  416. #define BOOST_MATH_STD_USING_CORE \
  417. using std::abs;\
  418. using std::acos;\
  419. using std::cos;\
  420. using std::fmod;\
  421. using std::modf;\
  422. using std::tan;\
  423. using std::asin;\
  424. using std::cosh;\
  425. using std::frexp;\
  426. using std::pow;\
  427. using std::tanh;\
  428. using std::atan;\
  429. using std::exp;\
  430. using std::ldexp;\
  431. using std::sin;\
  432. using std::atan2;\
  433. using std::fabs;\
  434. using std::log;\
  435. using std::sinh;\
  436. using std::ceil;\
  437. using std::floor;\
  438. using std::log10;\
  439. using std::sqrt;
  440. #define BOOST_MATH_STD_USING BOOST_MATH_STD_USING_CORE
  441. namespace boost{ namespace math{
  442. namespace tools
  443. {
  444. template <class T>
  445. inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c) BOOST_MATH_NOEXCEPT(T)
  446. {
  447. return (std::max)((std::max)(a, b), c);
  448. }
  449. template <class T>
  450. inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) BOOST_MATH_NOEXCEPT(T)
  451. {
  452. return (std::max)((std::max)(a, b), (std::max)(c, d));
  453. }
  454. } // namespace tools
  455. template <class T>
  456. void suppress_unused_variable_warning(const T&) BOOST_MATH_NOEXCEPT(T)
  457. {
  458. }
  459. namespace detail{
  460. template <class T>
  461. struct is_integer_for_rounding
  462. {
  463. static constexpr bool value = std::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer);
  464. };
  465. }
  466. }} // namespace boost namespace math
  467. #ifdef __GLIBC_PREREQ
  468. # if __GLIBC_PREREQ(2,14)
  469. # define BOOST_MATH_HAVE_FIXED_GLIBC
  470. # endif
  471. #endif
  472. #if ((defined(__linux__) && !defined(__UCLIBC__) && !defined(BOOST_MATH_HAVE_FIXED_GLIBC)) || defined(__QNX__) || defined(__IBMCPP__))
  473. //
  474. // This code was introduced in response to this glibc bug: http://sourceware.org/bugzilla/show_bug.cgi?id=2445
  475. // Basically powl and expl can return garbage when the result is small and certain exception flags are set
  476. // on entrance to these functions. This appears to have been fixed in Glibc 2.14 (May 2011).
  477. // Much more information in this message thread: https://groups.google.com/forum/#!topic/boost-list/ZT99wtIFlb4
  478. //
  479. #include <cfenv>
  480. # ifdef FE_ALL_EXCEPT
  481. namespace boost{ namespace math{
  482. namespace detail
  483. {
  484. struct fpu_guard
  485. {
  486. fpu_guard()
  487. {
  488. fegetexceptflag(&m_flags, FE_ALL_EXCEPT);
  489. feclearexcept(FE_ALL_EXCEPT);
  490. }
  491. ~fpu_guard()
  492. {
  493. fesetexceptflag(&m_flags, FE_ALL_EXCEPT);
  494. }
  495. private:
  496. fexcept_t m_flags;
  497. };
  498. } // namespace detail
  499. }} // namespaces
  500. # define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
  501. # define BOOST_MATH_INSTRUMENT_FPU do{ fexcept_t cpu_flags; fegetexceptflag(&cpu_flags, FE_ALL_EXCEPT); BOOST_MATH_INSTRUMENT_VARIABLE(cpu_flags); } while(0);
  502. # else
  503. # define BOOST_FPU_EXCEPTION_GUARD
  504. # define BOOST_MATH_INSTRUMENT_FPU
  505. # endif
  506. #else // All other platforms.
  507. # define BOOST_FPU_EXCEPTION_GUARD
  508. # define BOOST_MATH_INSTRUMENT_FPU
  509. #endif
  510. #ifdef BOOST_MATH_INSTRUMENT
  511. # include <iostream>
  512. # include <iomanip>
  513. # include <typeinfo>
  514. # define BOOST_MATH_INSTRUMENT_CODE(x) \
  515. std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl;
  516. # define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(#name << " = " << name)
  517. #else
  518. # define BOOST_MATH_INSTRUMENT_CODE(x)
  519. # define BOOST_MATH_INSTRUMENT_VARIABLE(name)
  520. #endif
  521. //
  522. // Thread local storage:
  523. //
  524. #ifndef BOOST_MATH_DISABLE_THREADS
  525. # define BOOST_MATH_THREAD_LOCAL thread_local
  526. #else
  527. # define BOOST_MATH_THREAD_LOCAL
  528. #endif
  529. //
  530. // Some mingw flavours have issues with thread_local and types with non-trivial destructors
  531. // See https://sourceforge.net/p/mingw-w64/bugs/527/
  532. //
  533. #if (defined(__MINGW32__) && (__GNUC__ < 9) && !defined(__clang__))
  534. # define BOOST_MATH_NO_THREAD_LOCAL_WITH_NON_TRIVIAL_TYPES
  535. #endif
  536. //
  537. // Can we have constexpr tables?
  538. //
  539. #if (!defined(BOOST_MATH_NO_CXX14_CONSTEXPR)) || (defined(_MSC_VER) && _MSC_VER >= 1910)
  540. #define BOOST_MATH_HAVE_CONSTEXPR_TABLES
  541. #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION constexpr
  542. #else
  543. #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION
  544. #endif
  545. #endif // BOOST_MATH_TOOLS_CONFIG_HPP