mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Remove boost.predef dependency
This commit is contained in:
@@ -25,8 +25,28 @@ With these techniques, the code could be simplified.
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <boost/math/tools/assert.hpp>
|
||||
|
||||
// Determine endinaness
|
||||
#ifndef BOOST_MATH_STANDALONE
|
||||
|
||||
#include <boost/predef/other/endian.h>
|
||||
#include <boost/math/tools/assert.hpp>
|
||||
#define BOOST_MATH_ENDIAN_BIG_BYTE BOOST_ENDIAN_BIG_BYTE
|
||||
#define BOOST_MATH_ENDIAN_LITTLE_BYTE BOOST_ENDIAN_LITTLE_BYTE
|
||||
|
||||
#else // Using standalone mode
|
||||
#if (__cplusplus > 202000L || _MSVC_LANG > 202000L) && __has_include(<bit>)
|
||||
|
||||
#include <bit>
|
||||
#define BOOST_MATH_ENDIAN_BIG_BYTE (std::endian::native == std::endian::big)
|
||||
#define BOOST_MATH_ENDIAN_LITTLE_BYTE (std::endian::native == std::endian::little)
|
||||
|
||||
#else // Does not have compliant C++20
|
||||
|
||||
#define BOOST_MATH_ENDIAN_BIG_BYTE (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
#define BOOST_MATH_ENDIAN_LITTLE_BYTE (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
|
||||
#endif // Standalone mode
|
||||
#endif // Endian
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std{ using ::memcpy; }
|
||||
@@ -178,10 +198,10 @@ template<> struct fp_traits_non_native<float, single_precision>
|
||||
{
|
||||
typedef ieee_copy_all_bits_tag method;
|
||||
|
||||
BOOST_STATIC_CONSTANT(uint32_t, sign = 0x80000000u);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, exponent = 0x7f800000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, flag = 0x00000000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, significand = 0x007fffff);
|
||||
static constexpr uint32_t sign = 0x80000000u;
|
||||
static constexpr uint32_t exponent = 0x7f800000;
|
||||
static constexpr uint32_t flag = 0x00000000;
|
||||
static constexpr uint32_t significand = 0x007fffff;
|
||||
|
||||
typedef uint32_t bits;
|
||||
static void get_bits(float x, uint32_t& a) { std::memcpy(&a, &x, 4); }
|
||||
@@ -197,10 +217,10 @@ template<> struct fp_traits_non_native<double, double_precision>
|
||||
{
|
||||
typedef ieee_copy_leading_bits_tag method;
|
||||
|
||||
BOOST_STATIC_CONSTANT(uint32_t, sign = 0x80000000u);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, exponent = 0x7ff00000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, flag = 0);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, significand = 0x000fffff);
|
||||
static constexpr uint32_t sign = 0x80000000u;
|
||||
static constexpr uint32_t exponent = 0x7ff00000;
|
||||
static constexpr uint32_t flag = 0;
|
||||
static constexpr uint32_t significand = 0x000fffff;
|
||||
|
||||
typedef uint32_t bits;
|
||||
|
||||
@@ -216,10 +236,10 @@ template<> struct fp_traits_non_native<double, double_precision>
|
||||
|
||||
private:
|
||||
|
||||
#if BOOST_ENDIAN_BIG_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 0);
|
||||
#elif BOOST_ENDIAN_LITTLE_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 4);
|
||||
#if BOOST_MATH_ENDIAN_BIG_BYTE
|
||||
static constexpr int offset_ = 0;
|
||||
#elif BOOST_MATH_ENDIAN_LITTLE_BYTE
|
||||
static constexpr int offset_ = 4;
|
||||
#else
|
||||
static_assert(false, "Endian type could not be identified");
|
||||
#endif
|
||||
@@ -233,10 +253,10 @@ template<> struct fp_traits_non_native<double, double_precision>
|
||||
{
|
||||
typedef ieee_copy_all_bits_tag method;
|
||||
|
||||
static const uint64_t sign = ((uint64_t)0x80000000u) << 32;
|
||||
static const uint64_t exponent = ((uint64_t)0x7ff00000) << 32;
|
||||
static const uint64_t flag = 0;
|
||||
static const uint64_t significand
|
||||
static constexpr uint64_t sign = ((uint64_t)0x80000000u) << 32;
|
||||
static constexpr uint64_t exponent = ((uint64_t)0x7ff00000) << 32;
|
||||
static constexpr uint64_t flag = 0;
|
||||
static constexpr uint64_t significand
|
||||
= (((uint64_t)0x000fffff) << 32) + ((uint64_t)0xffffffffu);
|
||||
|
||||
typedef uint64_t bits;
|
||||
@@ -257,10 +277,10 @@ template<> struct fp_traits_non_native<long double, double_precision>
|
||||
{
|
||||
typedef ieee_copy_leading_bits_tag method;
|
||||
|
||||
BOOST_STATIC_CONSTANT(uint32_t, sign = 0x80000000u);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, exponent = 0x7ff00000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, flag = 0);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, significand = 0x000fffff);
|
||||
static constexpr uint32_t sign = 0x80000000u;
|
||||
static constexpr uint32_t exponent = 0x7ff00000;
|
||||
static constexpr uint32_t flag = 0;
|
||||
static constexpr uint32_t significand = 0x000fffff;
|
||||
|
||||
typedef uint32_t bits;
|
||||
|
||||
@@ -276,10 +296,10 @@ template<> struct fp_traits_non_native<long double, double_precision>
|
||||
|
||||
private:
|
||||
|
||||
#if BOOST_ENDIAN_BIG_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 0);
|
||||
#elif BOOST_ENDIAN_LITTLE_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 4);
|
||||
#if BOOST_MATH_ENDIAN_BIG_BYTE
|
||||
static constexpr int offset_ = 0;
|
||||
#elif BOOST_MATH_ENDIAN_LITTLE_BYTE
|
||||
static constexpr int offset_ = 4;
|
||||
#else
|
||||
static_assert(false, "Endian type could not be identified");
|
||||
#endif
|
||||
@@ -320,10 +340,10 @@ struct fp_traits_non_native<long double, extended_double_precision>
|
||||
{
|
||||
typedef ieee_copy_leading_bits_tag method;
|
||||
|
||||
BOOST_STATIC_CONSTANT(uint32_t, sign = 0x80000000u);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, exponent = 0x7fff0000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, flag = 0x00008000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, significand = 0x00007fff);
|
||||
static constexpr uint32_t sign = 0x80000000u;
|
||||
static constexpr uint32_t exponent = 0x7fff0000;
|
||||
static constexpr uint32_t flag = 0x00008000;
|
||||
static constexpr uint32_t significand = 0x00007fff;
|
||||
|
||||
typedef uint32_t bits;
|
||||
|
||||
@@ -371,10 +391,10 @@ struct fp_traits_non_native<long double, extended_double_precision>
|
||||
{
|
||||
typedef ieee_copy_leading_bits_tag method;
|
||||
|
||||
BOOST_STATIC_CONSTANT(uint32_t, sign = 0x80000000u);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, exponent = 0x7ff00000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, flag = 0x00000000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, significand = 0x000fffff);
|
||||
static constexpr uint32_t sign = 0x80000000u;
|
||||
static constexpr uint32_t exponent = 0x7ff00000;
|
||||
static constexpr uint32_t flag = 0x00000000;
|
||||
static constexpr uint32_t significand = 0x000fffff;
|
||||
|
||||
typedef uint32_t bits;
|
||||
|
||||
@@ -390,10 +410,10 @@ struct fp_traits_non_native<long double, extended_double_precision>
|
||||
|
||||
private:
|
||||
|
||||
#if BOOST_ENDIAN_BIG_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 0);
|
||||
#elif BOOST_ENDIAN_LITTLE_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 12);
|
||||
#if BOOST_MATH_ENDIAN_BIG_BYTE
|
||||
static constexpr int offset_ = 0;
|
||||
#elif BOOST_MATH_ENDIAN_LITTLE_BYTE
|
||||
static constexpr int offset_ = 12;
|
||||
#else
|
||||
static_assert(false, "Endian type could not be identified");
|
||||
#endif
|
||||
@@ -416,10 +436,10 @@ struct fp_traits_non_native<long double, extended_double_precision>
|
||||
{
|
||||
typedef ieee_copy_leading_bits_tag method;
|
||||
|
||||
BOOST_STATIC_CONSTANT(uint32_t, sign = 0x80000000u);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, exponent = 0x7fff0000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, flag = 0x00008000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, significand = 0x00007fff);
|
||||
static constexpr uint32_t sign = 0x80000000u;
|
||||
static constexpr uint32_t exponent = 0x7fff0000;
|
||||
static constexpr uint32_t flag = 0x00008000;
|
||||
static constexpr uint32_t significand = 0x00007fff;
|
||||
|
||||
// copy 1st, 2nd, 5th and 6th byte. 3rd and 4th byte are padding.
|
||||
|
||||
@@ -452,10 +472,10 @@ struct fp_traits_non_native<long double, extended_double_precision>
|
||||
{
|
||||
typedef ieee_copy_leading_bits_tag method;
|
||||
|
||||
BOOST_STATIC_CONSTANT(uint32_t, sign = 0x80000000u);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, exponent = 0x7fff0000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, flag = 0x00000000);
|
||||
BOOST_STATIC_CONSTANT(uint32_t, significand = 0x0000ffff);
|
||||
static constexpr uint32_t sign = 0x80000000u;
|
||||
static constexpr uint32_t exponent = 0x7fff0000;
|
||||
static constexpr uint32_t flag = 0x00000000;
|
||||
static constexpr uint32_t significand = 0x0000ffff;
|
||||
|
||||
typedef uint32_t bits;
|
||||
|
||||
@@ -471,10 +491,10 @@ struct fp_traits_non_native<long double, extended_double_precision>
|
||||
|
||||
private:
|
||||
|
||||
#if BOOST_ENDIAN_BIG_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 0);
|
||||
#elif BOOST_ENDIAN_LITTLE_BYTE
|
||||
BOOST_STATIC_CONSTANT(int, offset_ = 12);
|
||||
#if BOOST_MATH_ENDIAN_BIG_BYTE
|
||||
static constexpr int offset_ = 0;
|
||||
#elif BOOST_MATH_ENDIAN_LITTLE_BYTE
|
||||
static constexpr int offset_ = 12;
|
||||
#else
|
||||
static_assert(false, "Endian type could not be identified");
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/predef/architecture/x86.h>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <algorithm> // for min and max
|
||||
#include <cmath>
|
||||
|
||||
Reference in New Issue
Block a user