config.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. // Determine if compiling as a dynamic library
  20. #if (defined(BOOST_URL_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_URL_STATIC_LINK)
  21. # define BOOST_URL_BUILD_DLL
  22. #endif
  23. // Set visibility flags
  24. #if !defined(BOOST_URL_BUILD_DLL)
  25. # define BOOST_URL_DECL /* static library */
  26. #elif defined(BOOST_URL_SOURCE)
  27. # define BOOST_URL_DECL BOOST_SYMBOL_EXPORT /* source: dllexport/visibility */
  28. #else
  29. # define BOOST_URL_DECL BOOST_SYMBOL_IMPORT /* header: dllimport */
  30. #endif
  31. // Set up auto-linker
  32. # if !defined(BOOST_URL_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_URL_NO_LIB)
  33. # define BOOST_LIB_NAME boost_url
  34. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_URL_DYN_LINK)
  35. # define BOOST_DYN_LINK
  36. # endif
  37. # include <boost/config/auto_link.hpp>
  38. # endif
  39. // Set up SSE2
  40. #if ! defined(BOOST_URL_NO_SSE2) && \
  41. ! defined(BOOST_URL_USE_SSE2)
  42. # if (defined(_M_IX86) && _M_IX86_FP == 2) || \
  43. defined(_M_X64) || defined(__SSE2__)
  44. # define BOOST_URL_USE_SSE2
  45. # endif
  46. #endif
  47. // constexpr
  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. #if !defined(BOOST_NO_CXX20_HDR_CONCEPTS) && defined(__cpp_lib_concepts)
  69. #define BOOST_URL_HAS_CONCEPTS
  70. #endif
  71. #ifdef BOOST_URL_HAS_CONCEPTS
  72. #define BOOST_URL_CONSTRAINT(C) C
  73. #else
  74. #define BOOST_URL_CONSTRAINT(C) class
  75. #endif
  76. // String token parameters
  77. #ifndef BOOST_URL_STRTOK_TPARAM
  78. #define BOOST_URL_STRTOK_TPARAM BOOST_URL_CONSTRAINT(string_token::StringToken) StringToken = string_token::return_string
  79. #endif
  80. #ifndef BOOST_URL_STRTOK_RETURN
  81. #define BOOST_URL_STRTOK_RETURN typename StringToken::result_type
  82. #endif
  83. #ifndef BOOST_URL_STRTOK_ARG
  84. #define BOOST_URL_STRTOK_ARG(name) StringToken&& token = {}
  85. #endif
  86. // Move
  87. #if BOOST_WORKAROUND( BOOST_GCC_VERSION, < 80000 ) || \
  88. BOOST_WORKAROUND( BOOST_CLANG_VERSION, < 30900 )
  89. #define BOOST_URL_RETURN(x) return std::move((x))
  90. #else
  91. #define BOOST_URL_RETURN(x) return (x)
  92. #endif
  93. // Limit tests
  94. #ifndef BOOST_URL_MAX_SIZE
  95. // we leave room for a null,
  96. // and still fit in size_t
  97. #define BOOST_URL_MAX_SIZE ((std::size_t(-1))-1)
  98. #endif
  99. // noinline attribute
  100. #ifdef BOOST_GCC
  101. #define BOOST_URL_NO_INLINE [[gnu::noinline]]
  102. #else
  103. #define BOOST_URL_NO_INLINE
  104. #endif
  105. // libstdcxx copy-on-write strings
  106. #ifndef BOOST_URL_COW_STRINGS
  107. #if defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 60000 || (defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0))
  108. #define BOOST_URL_COW_STRINGS
  109. #endif
  110. #endif
  111. // detect 32/64 bit
  112. #if UINTPTR_MAX == UINT64_MAX
  113. # define BOOST_URL_ARCH 64
  114. #elif UINTPTR_MAX == UINT32_MAX
  115. # define BOOST_URL_ARCH 32
  116. #else
  117. # error Unknown or unsupported architecture, please open an issue
  118. #endif
  119. // deprecated attribute
  120. #if defined(BOOST_MSVC)
  121. #define BOOST_URL_DEPRECATED(msg)
  122. #else
  123. #define BOOST_URL_DEPRECATED(msg) BOOST_DEPRECATED(msg)
  124. #endif
  125. // Implementation defined type for Doxygen while Clang
  126. // can still parse the comments into the AST
  127. #ifndef BOOST_URL_DOCS
  128. #define BOOST_URL_IMPLEMENTATION_DEFINED(Type) Type
  129. #else
  130. #define BOOST_URL_IMPLEMENTATION_DEFINED(Type) __implementation_defined__
  131. #endif
  132. #ifndef BOOST_URL_DOCS
  133. #define BOOST_URL_SEE_BELOW(Type) Type
  134. #else
  135. #define BOOST_URL_SEE_BELOW(Type) __see_below__
  136. #endif
  137. #ifdef __cpp_lib_array_constexpr
  138. #define BOOST_URL_LIB_ARRAY_CONSTEXPR constexpr
  139. #else
  140. #define BOOST_URL_LIB_ARRAY_CONSTEXPR
  141. #endif
  142. // avoid Boost.TypeTraits for these traits
  143. namespace boost {
  144. namespace urls {
  145. template<class...> struct make_void { typedef void type; };
  146. template<class... Ts> using void_t = typename make_void<Ts...>::type;
  147. } // urls
  148. } // boost
  149. #endif