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