config.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2023 Matt Borland
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // https://www.boost.org/LICENSE_1_0.txt
  4. #ifndef BOOST_JSON_DETAIL_CHARCONV_DETAIL_CONFIG_HPP
  5. #define BOOST_JSON_DETAIL_CHARCONV_DETAIL_CONFIG_HPP
  6. #include <boost/config.hpp>
  7. #include <type_traits>
  8. #include <cfloat>
  9. // Use 128 bit integers and supress warnings for using extensions
  10. #if defined(BOOST_HAS_INT128)
  11. # define BOOST_JSON_INT128_MAX (boost::int128_type)(((boost::uint128_type) 1 << 127) - 1)
  12. # define BOOST_JSON_UINT128_MAX ((2 * (boost::uint128_type) BOOST_JSON_INT128_MAX) + 1)
  13. #endif
  14. #ifndef BOOST_NO_CXX14_CONSTEXPR
  15. # define BOOST_JSON_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
  16. # define BOOST_JSON_CXX14_CONSTEXPR_NO_INLINE BOOST_CXX14_CONSTEXPR
  17. #else
  18. # define BOOST_JSON_CXX14_CONSTEXPR inline
  19. # define BOOST_JSON_CXX14_CONSTEXPR_NO_INLINE
  20. #endif
  21. #if defined(__GNUC__) && __GNUC__ == 5
  22. # define BOOST_JSON_GCC5_CONSTEXPR inline
  23. #else
  24. # define BOOST_JSON_GCC5_CONSTEXPR BOOST_JSON_CXX14_CONSTEXPR
  25. #endif
  26. // Inclue intrinsics if available
  27. #if defined(BOOST_MSVC)
  28. # include <intrin.h>
  29. # if defined(_WIN64)
  30. # define BOOST_JSON_HAS_MSVC_64BIT_INTRINSICS
  31. # else
  32. # define BOOST_JSON_HAS_MSVC_32BIT_INTRINSICS
  33. # endif
  34. #endif
  35. // Suppress additional buffer overrun check.
  36. // I have no idea why MSVC thinks some functions here are vulnerable to the buffer overrun
  37. // attacks. No, they aren't.
  38. #if defined(__GNUC__) || defined(__clang__)
  39. #define BOOST_JSON_SAFEBUFFERS
  40. #elif defined(_MSC_VER)
  41. #define BOOST_JSON_SAFEBUFFERS __declspec(safebuffers)
  42. #else
  43. #define BOOST_JSON_SAFEBUFFERS
  44. #endif
  45. #if defined(__has_builtin)
  46. #define BOOST_JSON_HAS_BUILTIN(x) __has_builtin(x)
  47. #else
  48. #define BOOST_JSON_HAS_BUILTIN(x) false
  49. #endif
  50. #endif // BOOST_JSON_DETAIL_CHARCONV_DETAIL_CONFIG_HPP