config.hpp 4.4 KB

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