config.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  3. // Copyright (c) 2022 Alan de Freitas ([email protected])
  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. // String token parameters
  69. #ifndef BOOST_URL_STRTOK_TPARAM
  70. #define BOOST_URL_STRTOK_TPARAM class StringToken = string_token::return_string
  71. #endif
  72. #ifndef BOOST_URL_STRTOK_RETURN
  73. #define BOOST_URL_STRTOK_RETURN typename StringToken::result_type
  74. #endif
  75. #ifndef BOOST_URL_STRTOK_ARG
  76. #define BOOST_URL_STRTOK_ARG(name) StringToken&& token = {}
  77. #endif
  78. // Move
  79. #if BOOST_WORKAROUND( BOOST_GCC_VERSION, < 80000 ) || \
  80. BOOST_WORKAROUND( BOOST_CLANG_VERSION, < 30900 )
  81. #define BOOST_URL_RETURN(x) return std::move((x))
  82. #else
  83. #define BOOST_URL_RETURN(x) return (x)
  84. #endif
  85. // Limit tests
  86. #ifndef BOOST_URL_MAX_SIZE
  87. // we leave room for a null,
  88. // and still fit in size_t
  89. #define BOOST_URL_MAX_SIZE ((std::size_t(-1))-1)
  90. #endif
  91. // noinline attribute
  92. #ifdef BOOST_GCC
  93. #define BOOST_URL_NO_INLINE [[gnu::noinline]]
  94. #else
  95. #define BOOST_URL_NO_INLINE
  96. #endif
  97. // libstdcxx copy-on-write strings
  98. #ifndef BOOST_URL_COW_STRINGS
  99. #if defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 60000 || (defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0))
  100. #define BOOST_URL_COW_STRINGS
  101. #endif
  102. #endif
  103. // detect 32/64 bit
  104. #if UINTPTR_MAX == UINT64_MAX
  105. # define BOOST_URL_ARCH 64
  106. #elif UINTPTR_MAX == UINT32_MAX
  107. # define BOOST_URL_ARCH 32
  108. #else
  109. # error Unknown or unsupported architecture, please open an issue
  110. #endif
  111. // deprecated attribute
  112. #if defined(BOOST_MSVC) || defined(BOOST_URL_DOCS)
  113. #define BOOST_URL_DEPRECATED(msg)
  114. #else
  115. #define BOOST_URL_DEPRECATED(msg) BOOST_DEPRECATED(msg)
  116. #endif
  117. // avoid Boost.TypeTraits for these traits
  118. namespace boost {
  119. namespace urls {
  120. template<class...> struct make_void { typedef void type; };
  121. template<class... Ts> using void_t = typename make_void<Ts...>::type;
  122. } // urls
  123. } // boost
  124. #endif