config.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // Copyright Oliver Kowalke 2014.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_CONTEXT_DETAIL_CONFIG_H
  6. #define BOOST_CONTEXT_DETAIL_CONFIG_H
  7. // required for SD-6 compile-time integer sequences
  8. #include <utility>
  9. #include <boost/config.hpp>
  10. #include <boost/detail/workaround.hpp>
  11. #ifdef BOOST_CONTEXT_DECL
  12. # undef BOOST_CONTEXT_DECL
  13. #endif
  14. #if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTEXT_DYN_LINK) ) && ! defined(BOOST_CONTEXT_STATIC_LINK)
  15. # if defined(BOOST_CONTEXT_SOURCE)
  16. # define BOOST_CONTEXT_DECL BOOST_SYMBOL_EXPORT
  17. # define BOOST_CONTEXT_BUILD_DLL
  18. # else
  19. # define BOOST_CONTEXT_DECL BOOST_SYMBOL_IMPORT
  20. # endif
  21. #endif
  22. #if ! defined(BOOST_CONTEXT_DECL)
  23. # define BOOST_CONTEXT_DECL
  24. #endif
  25. #if ! defined(BOOST_CONTEXT_SOURCE) && ! defined(BOOST_ALL_NO_LIB) && ! defined(BOOST_CONTEXT_NO_LIB)
  26. # define BOOST_LIB_NAME boost_context
  27. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTEXT_DYN_LINK)
  28. # define BOOST_DYN_LINK
  29. # endif
  30. # include <boost/config/auto_link.hpp>
  31. #endif
  32. #undef BOOST_CONTEXT_CALLDECL
  33. #if (defined(i386) || defined(__i386__) || defined(__i386) \
  34. || defined(__i486__) || defined(__i586__) || defined(__i686__) \
  35. || defined(__X86__) || defined(_X86_) || defined(__THW_INTEL__) \
  36. || defined(__I86__) || defined(__INTEL__) || defined(__IA32__) \
  37. || defined(_M_IX86) || defined(_I86_)) && defined(BOOST_WINDOWS)
  38. # define BOOST_CONTEXT_CALLDECL __cdecl
  39. #else
  40. # define BOOST_CONTEXT_CALLDECL
  41. #endif
  42. #if defined(BOOST_USE_SEGMENTED_STACKS)
  43. # if ! ( (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) ) ) || \
  44. (defined(__clang__) && (__clang_major__ > 2 || ( __clang_major__ == 2 && __clang_minor__ > 3) ) ) )
  45. # error "compiler does not support segmented_stack stacks"
  46. # endif
  47. # define BOOST_CONTEXT_SEGMENTS 10
  48. #endif
  49. #define BOOST_CONTEXT_NO_CXX14_INTEGER_SEQUENCE
  50. // use rd6 macros for std::integer_sequence
  51. #if defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304
  52. # undef BOOST_CONTEXT_NO_CXX14_INTEGER_SEQUENCE
  53. #endif
  54. // workaroud: MSVC 14 does not provide macros to test for compile-time integer sequence
  55. #if _MSC_VER > 1800 // _MSC_VER == 1800 -> MS Visual Studio 2013
  56. # undef BOOST_CONTEXT_NO_INDEX_SEQUENCE
  57. #endif
  58. // workaround: Xcode clang feature detection
  59. #if ! defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304
  60. # if _LIBCPP_STD_VER > 11
  61. # undef BOOST_CONTEXT_NO_CXX14_INTEGER_SEQUENCE
  62. # endif
  63. #endif
  64. // workaroud: MSVC 14 does support constexpr
  65. #if _MSC_VER > 1800 // _MSC_VER == 1800 -> MS Visual Studio 2013
  66. # undef BOOST_NO_CXX11_CONSTEXPR
  67. #endif
  68. #undef BOOST_CONTEXT_NO_CXX11
  69. #if defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) || \
  70. defined(BOOST_NO_CXX11_CONSTEXPR) || \
  71. defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
  72. defined(BOOST_NO_CXX11_FINAL) || \
  73. defined(BOOST_NO_CXX11_HDR_TUPLE) || \
  74. defined(BOOST_NO_CXX11_NOEXCEPT) || \
  75. defined(BOOST_NO_CXX11_NULLPTR) || \
  76. defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
  77. defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) || \
  78. defined(BOOST_NO_CXX11_UNIFIED_INITIALISATION_SYNTAX) || \
  79. defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \
  80. defined(BOOST_NO_HDR_ATOMIC) || \
  81. defined(BOOST_NO_HDR_TUPLE)
  82. # define BOOST_CONTEXT_NO_CXX11
  83. #endif
  84. #if ! defined(BOOST_EXECUTION_CONTEXT)
  85. # if defined(BOOST_USE_SEGMENTED_STACKS)
  86. # define BOOST_EXECUTION_CONTEXT 1
  87. # else
  88. # define BOOST_EXECUTION_CONTEXT 2
  89. # endif
  90. #endif
  91. #if ! defined(BOOST_NO_CXX11_CONSTEXPR)
  92. // modern architectures have cachelines with 64byte length
  93. // ARM Cortex-A15 32/64byte, Cortex-A9 16/32/64bytes
  94. // MIPS 74K: 32byte, 4KEc: 16byte
  95. // ist should be safe to use 64byte for all
  96. static constexpr std::size_t cache_alignment{ 64 };
  97. static constexpr std::size_t cacheline_length{ 64 };
  98. // lookahead size for prefetching
  99. static constexpr std::size_t prefetch_stride{ 4 * cacheline_length };
  100. #endif
  101. #if defined(__GLIBCPP__) || defined(__GLIBCXX__)
  102. // GNU libstdc++ 3
  103. # define BOOST_CONTEXT_HAS_CXXABI_H
  104. #endif
  105. #if defined( BOOST_CONTEXT_HAS_CXXABI_H )
  106. # include <cxxabi.h>
  107. #endif
  108. #if defined(__OpenBSD__)
  109. // stacks need mmap(2) with MAP_STACK
  110. # define BOOST_CONTEXT_USE_MAP_STACK
  111. #endif
  112. #endif // BOOST_CONTEXT_DETAIL_CONFIG_H