| 1 | // (C) Copyright John Maddock 2021. |
| 2 | // Use, modification and distribution are subject to the |
| 3 | // Boost Software License, Version 1.0. (See accompanying file |
| 4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | // |
| 6 | // We deliberately use assert in here: |
| 7 | // |
| 8 | |
| 9 | #ifndef BOOST_MP_DETAIL_FLOAT128_FUNCTIONS_HPP |
| 10 | #define BOOST_MP_DETAIL_FLOAT128_FUNCTIONS_HPP |
| 11 | |
| 12 | #include <boost/multiprecision/detail/standalone_config.hpp> |
| 13 | |
| 14 | #ifndef BOOST_MP_STANDALONE |
| 15 | #include <boost/cstdfloat.hpp> |
| 16 | #if defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT) |
| 17 | # define BOOST_MP_HAVE_CSTDFLOAT |
| 18 | #endif |
| 19 | #endif |
| 20 | |
| 21 | #if defined(BOOST_HAS_FLOAT128) |
| 22 | |
| 23 | namespace boost |
| 24 | { |
| 25 | namespace multiprecision |
| 26 | { |
| 27 | namespace float128_procs |
| 28 | { |
| 29 | extern "C" __float128 ldexpq(__float128, int) throw(); |
| 30 | extern "C" __float128 frexpq(__float128, int*) throw(); |
| 31 | extern "C" __float128 floorq(__float128) throw(); |
| 32 | extern "C" __float128 nextafterq(__float128, __float128) throw(); |
| 33 | extern "C" int isinfq(__float128) throw(); |
| 34 | extern "C" int isnanq(__float128) throw(); |
| 35 | extern "C" __float128 strtoflt128(const char*, char**) throw(); |
| 36 | |
| 37 | #ifdef BOOST_MP_HAVE_CSTDFLOAT |
| 38 | using std::ldexp; |
| 39 | using std::frexp; |
| 40 | using std::floor; |
| 41 | using std::nextafter; |
| 42 | #else |
| 43 | inline __float128 ldexp(__float128 f, int i) throw() { return ldexpq(f, i); } |
| 44 | inline __float128 frexp(__float128 f, int* p) throw() { return frexpq(f, p); } |
| 45 | inline __float128 floor(__float128 f) throw() { return floorq(f); } |
| 46 | inline __float128 nextafter(__float128 a, __float128 b) throw() { return nextafterq(a, b); } |
| 47 | #endif |
| 48 | } |
| 49 | |
| 50 | namespace detail { |
| 51 | |
| 52 | template <class T> |
| 53 | struct is_float128 : public std::is_same<__float128, T> |
| 54 | {}; |
| 55 | |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | namespace boost { |
| 61 | namespace math { |
| 62 | |
| 63 | inline __float128 float_next(const __float128& f) |
| 64 | { |
| 65 | return boost::multiprecision::float128_procs::nextafterq(f, 2 * f); |
| 66 | } |
| 67 | inline int (isinf)(const __float128& f) |
| 68 | { |
| 69 | return boost::multiprecision::float128_procs::isinfq(f); |
| 70 | } |
| 71 | inline int (isnan)(const __float128& f) |
| 72 | { |
| 73 | return boost::multiprecision::float128_procs::isnanq(f); |
| 74 | } |
| 75 | |
| 76 | }} |
| 77 | |
| 78 | #define BOOST_MP_FLOAT128_USING using boost::multiprecision::float128_procs::ldexp; using boost::multiprecision::float128_procs::frexp; using boost::multiprecision::float128_procs::floor; using boost::multiprecision::float128_procs::nextafter; using boost::math::isinf; using boost::math::isnan; |
| 79 | |
| 80 | #else |
| 81 | #define BOOST_MP_FLOAT128_USING |
| 82 | |
| 83 | namespace boost { |
| 84 | namespace multiprecision { |
| 85 | namespace detail { |
| 86 | |
| 87 | template <class T> |
| 88 | struct is_float128 : public std::false_type |
| 89 | {}; |
| 90 | |
| 91 | }}} // namespace boost::multiprecision::detail |
| 92 | |
| 93 | #endif |
| 94 | |
| 95 | #endif // BOOST_MP_DETAIL_FLOAT128_FUNCTIONS_HPP |
| 96 | |