1///////////////////////////////////////////////////////////////
2// Copyright 2010 - 2021 Douglas Gregor
3// Copyright 2021 Matt Borland.
4// Distributed under the Boost Software License, Version 1.0.
5// See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
6//
7// Used to support configuration options depending on standalone context
8// by providing either required support or disabling functionality
9
10#ifndef BOOST_MP_STANDALONE_CONFIG_HPP
11#define BOOST_MP_STANDALONE_CONFIG_HPP
12
13#include <climits>
14
15// Boost.Config is dependency free so it is considered a requirement to use Boost.Multiprecision in standalone mode
16#ifdef __has_include
17# if __has_include(<boost/config.hpp>)
18# include <boost/config.hpp>
19# include <boost/config/workaround.hpp>
20# else
21# error "Boost.Config is considered a requirement to use Boost.Multiprecision in standalone mode. A package is provided at https://github.com/boostorg/multiprecision/releases"
22# endif
23#else
24// Provides the less helpful fatal error: 'boost/config.hpp' file not found if not available
25# include <boost/config.hpp>
26# include <boost/config/workaround.hpp>
27#endif
28
29// Minimum language standard transition
30 #ifdef _MSVC_LANG
31 # if _MSVC_LANG < 201402L
32 # pragma warning("The minimum language standard to use Boost.Math will be C++14 starting in July 2023 (Boost 1.82 release)");
33 # endif
34 #else
35 # if __cplusplus < 201402L
36 # warning "The minimum language standard to use Boost.Math will be C++14 starting in July 2023 (Boost 1.82 release)"
37 # endif
38 #endif
39
40// If any of the most frequently used boost headers are missing assume that standalone mode is supposed to be used
41#ifdef __has_include
42#if !__has_include(<boost/assert.hpp>) || !__has_include(<boost/lexical_cast.hpp>) || \
43 !__has_include(<boost/throw_exception.hpp>) || !__has_include(<boost/predef/other/endian.h>)
44# ifndef BOOST_MP_STANDALONE
45# define BOOST_MP_STANDALONE
46# endif
47#endif
48#endif
49
50#ifndef BOOST_MP_STANDALONE
51
52#include <boost/integer.hpp>
53#include <boost/integer_traits.hpp>
54
55// Required typedefs for interoperability with standalone mode
56#if defined(BOOST_HAS_INT128) && defined(__cplusplus)
57namespace boost { namespace multiprecision {
58 using int128_type = boost::int128_type;
59 using uint128_type = boost::uint128_type;
60}}
61#endif
62#if defined(BOOST_HAS_FLOAT128) && defined(__cplusplus)
63namespace boost { namespace multiprecision {
64 using float128_type = boost::float128_type;
65}}
66#endif
67
68// Boost.Math available by default
69#define BOOST_MP_MATH_AVAILABLE
70
71#else // Standalone mode
72
73#ifdef BOOST_MATH_STANDALONE
74# define BOOST_MP_MATH_AVAILABLE
75#endif
76
77#ifndef BOOST_MP_MATH_AVAILABLE
78# define BOOST_MATH_INSTRUMENT_CODE(x)
79#endif
80
81// Prevent Macro sub
82#ifndef BOOST_PREVENT_MACRO_SUBSTITUTION
83# define BOOST_PREVENT_MACRO_SUBSTITUTION
84#endif
85
86#if defined(BOOST_HAS_INT128) && defined(__cplusplus)
87namespace boost { namespace multiprecision {
88# ifdef __GNUC__
89 __extension__ typedef __int128 int128_type;
90 __extension__ typedef unsigned __int128 uint128_type;
91# else
92 typedef __int128 int128_type;
93 typedef unsigned __int128 uint128_type;
94# endif
95}}
96
97#endif
98// same again for __float128:
99#if defined(BOOST_HAS_FLOAT128) && defined(__cplusplus)
100namespace boost { namespace multiprecision {
101# ifdef __GNUC__
102 __extension__ typedef __float128 float128_type;
103# else
104 typedef __float128 float128_type;
105# endif
106}}
107
108#endif
109
110#endif // BOOST_MP_STANDALONE
111
112// Workarounds for numeric limits on old compilers
113#ifdef BOOST_HAS_INT128
114# ifndef INT128_MAX
115# define INT128_MAX static_cast<boost::multiprecision::int128_type>((static_cast<boost::multiprecision::uint128_type>(1) << ((__SIZEOF_INT128__ * __CHAR_BIT__) - 1)) - 1)
116# endif
117# ifndef INT128_MIN
118# define INT128_MIN (-INT128_MAX - 1)
119# endif
120# ifndef UINT128_MAX
121# define UINT128_MAX ((2 * static_cast<boost::multiprecision::uint128_type>(INT128_MAX)) + 1)
122# endif
123#endif
124
125#define BOOST_MP_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
126//
127// Early compiler versions trip over the constexpr code:
128//
129#if defined(__clang__) && (__clang_major__ < 5)
130#undef BOOST_MP_CXX14_CONSTEXPR
131#define BOOST_MP_CXX14_CONSTEXPR
132#endif
133#if defined(__apple_build_version__) && (__clang_major__ < 9)
134#undef BOOST_MP_CXX14_CONSTEXPR
135#define BOOST_MP_CXX14_CONSTEXPR
136#endif
137#if defined(BOOST_GCC) && (__GNUC__ < 6)
138#undef BOOST_MP_CXX14_CONSTEXPR
139#define BOOST_MP_CXX14_CONSTEXPR
140#endif
141#if defined(BOOST_INTEL)
142#undef BOOST_MP_CXX14_CONSTEXPR
143#define BOOST_MP_CXX14_CONSTEXPR
144#define BOOST_MP_NO_CONSTEXPR_DETECTION
145#endif
146
147
148#endif // BOOST_MP_STANDALONE_CONFIG_HPP
149

source code of boost/libs/multiprecision/include/boost/multiprecision/detail/standalone_config.hpp