config.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // Official repository: https://github.com/boostorg/url
  9. //
  10. #ifndef BOOST_URL_DETAIL_CONFIG_HPP
  11. #define BOOST_URL_DETAIL_CONFIG_HPP
  12. #include <boost/config.hpp>
  13. #include <boost/config/workaround.hpp>
  14. #include <limits.h>
  15. #include <stdint.h>
  16. #if CHAR_BIT != 8
  17. # error unsupported platform
  18. #endif
  19. #if defined(BOOST_URL_DOCS)
  20. # define BOOST_URL_DECL
  21. #else
  22. # if (defined(BOOST_URL_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_URL_STATIC_LINK)
  23. # if defined(BOOST_URL_SOURCE)
  24. # define BOOST_URL_DECL BOOST_SYMBOL_EXPORT
  25. # define BOOST_URL_BUILD_DLL
  26. # else
  27. # define BOOST_URL_DECL BOOST_SYMBOL_IMPORT
  28. # endif
  29. # endif // shared lib
  30. # ifndef BOOST_URL_DECL
  31. # define BOOST_URL_DECL
  32. # endif
  33. # if !defined(BOOST_URL_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_URL_NO_LIB)
  34. # define BOOST_LIB_NAME boost_url
  35. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URL_DYN_LINK)
  36. # define BOOST_DYN_LINK
  37. # endif
  38. # include <boost/config/auto_link.hpp>
  39. # endif
  40. #endif
  41. #if ! defined(BOOST_URL_NO_SSE2) && \
  42. ! defined(BOOST_URL_USE_SSE2)
  43. # if (defined(_M_IX86) && _M_IX86_FP == 2) || \
  44. defined(_M_X64) || defined(__SSE2__)
  45. # define BOOST_URL_USE_SSE2
  46. # endif
  47. #endif
  48. #if BOOST_WORKAROUND( BOOST_GCC_VERSION, <= 72000 ) || \
  49. BOOST_WORKAROUND( BOOST_CLANG_VERSION, <= 35000 )
  50. # define BOOST_URL_CONSTEXPR
  51. #else
  52. # define BOOST_URL_CONSTEXPR constexpr
  53. #endif
  54. // Add source location to error codes
  55. #ifdef BOOST_URL_NO_SOURCE_LOCATION
  56. # define BOOST_URL_ERR(ev) (::boost::system::error_code(ev))
  57. # define BOOST_URL_RETURN_EC(ev) return (ev)
  58. # define BOOST_URL_POS ::boost::source_location()
  59. #else
  60. # define BOOST_URL_ERR(ev) (::boost::system::error_code( (ev), [] { \
  61. static constexpr auto loc((BOOST_CURRENT_LOCATION)); \
  62. return &loc; }()))
  63. # define BOOST_URL_RETURN_EC(ev) \
  64. static constexpr auto loc ## __LINE__((BOOST_CURRENT_LOCATION)); \
  65. return ::boost::system::error_code((ev), &loc ## __LINE__)
  66. # define BOOST_URL_POS (BOOST_CURRENT_LOCATION)
  67. #endif
  68. #ifndef BOOST_URL_STRTOK_TPARAM
  69. #define BOOST_URL_STRTOK_TPARAM class StringToken = string_token::return_string
  70. #endif
  71. #ifndef BOOST_URL_STRTOK_RETURN
  72. #define BOOST_URL_STRTOK_RETURN typename StringToken::result_type
  73. #endif
  74. #ifndef BOOST_URL_STRTOK_ARG
  75. #define BOOST_URL_STRTOK_ARG(name) StringToken&& token = {}
  76. #endif
  77. #if BOOST_WORKAROUND( BOOST_GCC_VERSION, < 80000 ) || \
  78. BOOST_WORKAROUND( BOOST_CLANG_VERSION, < 30900 )
  79. #define BOOST_URL_RETURN(x) return std::move((x))
  80. #else
  81. #define BOOST_URL_RETURN(x) return (x)
  82. #endif
  83. #ifndef BOOST_URL_MAX_SIZE
  84. // we leave room for a null,
  85. // and still fit in size_t
  86. #define BOOST_URL_MAX_SIZE ((std::size_t(-1))-1)
  87. #endif
  88. #ifdef BOOST_GCC
  89. #define BOOST_URL_NO_INLINE [[gnu::noinline]]
  90. #else
  91. #define BOOST_URL_NO_INLINE
  92. #endif
  93. #ifndef BOOST_URL_COW_STRINGS
  94. #if defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 60000 || (defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0))
  95. #define BOOST_URL_COW_STRINGS
  96. #endif
  97. #endif
  98. // detect 32/64 bit
  99. #if UINTPTR_MAX == UINT64_MAX
  100. # define BOOST_URL_ARCH 64
  101. #elif UINTPTR_MAX == UINT32_MAX
  102. # define BOOST_URL_ARCH 32
  103. #else
  104. # error Unknown or unsupported architecture, please open an issue
  105. #endif
  106. namespace boost {
  107. namespace urls {
  108. // avoid some of Boost.TypeTraits for just this
  109. template<class...> struct make_void { typedef void type; };
  110. template<class... Ts> using void_t = typename make_void<Ts...>::type;
  111. } // urls
  112. } // boost
  113. #endif