1 // Copyright (C) 2001-2003
3 // Copyright (C) 2011-2013 Vicente J. Botet Escriba
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)
8 #ifndef BOOST_THREAD_CONFIG_WEK01032003_HPP
9 #define BOOST_THREAD_CONFIG_WEK01032003_HPP
11 #include <boost/config.hpp>
12 #include <boost/detail/workaround.hpp>
13 #include <boost/thread/detail/platform.hpp>
15 //#define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC
16 //#define BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
17 // ATTRIBUTE_MAY_ALIAS
19 //#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
20 #if !defined(BOOST_NO_MAY_ALIAS)
22 // GCC since 3.3 and some other compilers have may_alias attribute that helps
23 // to alleviate optimizer issues with regard to violation of the strict aliasing rules.
25 #define BOOST_THREAD_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
27 #if defined(BOOST_MAY_ALIAS)
28 #define BOOST_THREAD_ATTRIBUTE_MAY_ALIAS BOOST_MAY_ALIAS
30 #define BOOST_THREAD_ATTRIBUTE_MAY_ALIAS
33 #if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
34 #define BOOST_THREAD_ASSERT_PRECONDITION(EXPR, EX) \
35 if (EXPR) {} else boost::throw_exception(EX)
36 #define BOOST_THREAD_VERIFY_PRECONDITION(EXPR, EX) \
37 if (EXPR) {} else boost::throw_exception(EX)
38 #define BOOST_THREAD_THROW_ELSE_RETURN(EX, RET) \
39 boost::throw_exception(EX)
41 #define BOOST_THREAD_ASSERT_PRECONDITION(EXPR, EX)
42 #define BOOST_THREAD_VERIFY_PRECONDITION(EXPR, EX) \
44 #define BOOST_THREAD_THROW_ELSE_RETURN(EX, RET) \
48 // This compiler doesn't support Boost.Chrono
49 #if defined __IBMCPP__ && (__IBMCPP__ < 1100) \
50 && ! defined BOOST_THREAD_DONT_USE_CHRONO
51 #define BOOST_THREAD_DONT_USE_CHRONO
52 #if ! defined BOOST_THREAD_USES_DATETIME
53 #define BOOST_THREAD_USES_DATETIME
57 // This compiler doesn't support Boost.Move
58 #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) \
59 && ! defined BOOST_THREAD_DONT_USE_MOVE
60 #define BOOST_THREAD_DONT_USE_MOVE
63 // This compiler doesn't support Boost.Container Allocators files
64 #if defined __SUNPRO_CC \
65 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
66 #define BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
69 #if defined _WIN32_WCE && _WIN32_WCE==0x501 \
70 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
71 #define BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
75 #if defined BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX || defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST
76 #define BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST
77 #define BOOST_THREAD_NO_MAKE_LOCK_GUARD
78 #define BOOST_THREAD_NO_MAKE_STRICT_LOCK
79 #define BOOST_THREAD_NO_MAKE_NESTED_STRICT_LOCK
82 #if defined(BOOST_NO_CXX11_HDR_TUPLE) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
83 #define BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS
84 #define BOOST_THREAD_NO_SYNCHRONIZE
85 #elif defined _MSC_VER && _MSC_VER <= 1600
86 // C++ features supported by VC++ 10 (aka 2010)
87 #define BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS
88 #define BOOST_THREAD_NO_SYNCHRONIZE
92 #if ! defined BOOST_THREAD_DONT_PROVIDE_BASIC_THREAD_ID \
93 && ! defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
94 #define BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
97 /// RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
98 //#if defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC
99 #define BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
103 #if !defined BOOST_THREAD_VERSION
104 #define BOOST_THREAD_VERSION 2
106 #if BOOST_THREAD_VERSION!=2 && BOOST_THREAD_VERSION!=3 && BOOST_THREAD_VERSION!=4 && BOOST_THREAD_VERSION!=5
107 #error "BOOST_THREAD_VERSION must be 2, 3, 4 or 5"
112 // Uses Boost.Chrono by default if not stated the opposite defining BOOST_THREAD_DONT_USE_CHRONO
113 #if ! defined BOOST_THREAD_DONT_USE_CHRONO \
114 && ! defined BOOST_THREAD_USES_CHRONO
115 #define BOOST_THREAD_USES_CHRONO
118 #if ! defined BOOST_THREAD_DONT_USE_ATOMIC \
119 && ! defined BOOST_THREAD_USES_ATOMIC
120 #define BOOST_THREAD_USES_ATOMIC
121 //#define BOOST_THREAD_DONT_USE_ATOMIC
124 #if defined BOOST_THREAD_USES_ATOMIC
126 #define BOOST_THREAD_ONCE_ATOMIC
128 //#elif ! defined BOOST_NO_CXX11_THREAD_LOCAL && ! defined BOOST_NO_THREAD_LOCAL && ! defined BOOST_THREAD_NO_UINT32_PSEUDO_ATOMIC
129 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2444.html#Appendix
130 #define BOOST_THREAD_ONCE_FAST_EPOCH
132 #if BOOST_THREAD_VERSION==2
134 // PROVIDE_PROMISE_LAZY
135 #if ! defined BOOST_THREAD_DONT_PROVIDE_PROMISE_LAZY \
136 && ! defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
137 #define BOOST_THREAD_PROVIDES_PROMISE_LAZY
141 #if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_EQ \
142 && ! defined BOOST_THREAD_PROVIDES_THREAD_EQ
143 #define BOOST_THREAD_PROVIDES_THREAD_EQ
148 #if BOOST_THREAD_VERSION>=3
151 // fixme BOOST_THREAD_PROVIDES_ONCE_CXX11 doesn't works when thread.cpp is compiled BOOST_THREAD_VERSION 3
152 #if ! defined BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11 \
153 && ! defined BOOST_THREAD_PROVIDES_ONCE_CXX11
154 #define BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11
157 // THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
158 #if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE \
159 && ! defined BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
160 #define BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
163 // THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
164 #if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE \
165 && ! defined BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
166 #define BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
170 #if ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE \
171 && ! defined BOOST_THREAD_PROVIDES_FUTURE
172 #define BOOST_THREAD_PROVIDES_FUTURE
175 // FUTURE_CTOR_ALLOCATORS
176 #if ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS \
177 && ! defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
178 #define BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
181 // SHARED_MUTEX_UPWARDS_CONVERSIONS
182 #if ! defined BOOST_THREAD_DONT_PROVIDE_SHARED_MUTEX_UPWARDS_CONVERSIONS \
183 && ! defined BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
184 #define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
187 // PROVIDE_EXPLICIT_LOCK_CONVERSION
188 #if ! defined BOOST_THREAD_DONT_PROVIDE_EXPLICIT_LOCK_CONVERSION \
189 && ! defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
190 #define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
193 // GENERIC_SHARED_MUTEX_ON_WIN
194 #if ! defined BOOST_THREAD_DONT_PROVIDE_GENERIC_SHARED_MUTEX_ON_WIN \
195 && ! defined BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
196 #define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
200 #if ! defined BOOST_THREAD_DONT_USE_MOVE \
201 && ! defined BOOST_THREAD_USES_MOVE
202 #define BOOST_THREAD_USES_MOVE
207 // deprecated since version 4
208 #if BOOST_THREAD_VERSION < 4
211 #if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS \
212 && ! defined BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
213 #define BOOST_THREAD_PROVIDES_NESTED_LOCKS
217 #if ! defined BOOST_THREAD_PROVIDES_CONDITION \
218 && ! defined BOOST_THREAD_DONT_PROVIDE_CONDITION
219 #define BOOST_THREAD_PROVIDES_CONDITION
223 #if ! defined BOOST_THREAD_DONT_USE_DATETIME \
224 && ! defined BOOST_THREAD_USES_DATETIME
225 #define BOOST_THREAD_USES_DATETIME
229 #if BOOST_THREAD_VERSION>=4
231 // SIGNATURE_PACKAGED_TASK
232 #if ! defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK \
233 && ! defined BOOST_THREAD_DONT_PROVIDE_SIGNATURE_PACKAGED_TASK
234 #define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
238 #if ! defined BOOST_THREAD_PROVIDES_VARIADIC_THREAD \
239 && ! defined BOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD
241 #if ! defined(BOOST_NO_SFINAE_EXPR) && \
242 ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
243 ! defined(BOOST_NO_CXX11_DECLTYPE) && \
244 ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) && \
245 ! defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) && \
246 ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
247 ! defined(BOOST_NO_CXX11_HDR_TUPLE)
249 #define BOOST_THREAD_PROVIDES_VARIADIC_THREAD
253 #if ! defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY \
254 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_WHEN_ALL_WHEN_ANY
256 #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
257 ! defined(BOOST_NO_CXX11_HDR_TUPLE)
259 #define BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY
263 // ! defined(BOOST_NO_SFINAE_EXPR) &&
264 // ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) &&
265 // ! defined(BOOST_NO_CXX11_AUTO) &&
266 // ! defined(BOOST_NO_CXX11_DECLTYPE) &&
267 // ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) &&
270 // MAKE_READY_AT_THREAD_EXIT
271 #if ! defined BOOST_THREAD_PROVIDES_MAKE_READY_AT_THREAD_EXIT \
272 && ! defined BOOST_THREAD_DONT_PROVIDE_MAKE_READY_AT_THREAD_EXIT
274 //#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
275 #define BOOST_THREAD_PROVIDES_MAKE_READY_AT_THREAD_EXIT
279 // FUTURE_CONTINUATION
280 #if ! defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \
281 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CONTINUATION
282 #define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
285 #if ! defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP \
286 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_UNWRAP
287 #define BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
290 // FUTURE_INVALID_AFTER_GET
291 #if ! defined BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET \
292 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_INVALID_AFTER_GET
293 #define BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
297 #if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS \
298 && ! defined BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
299 #define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
303 #if ! defined BOOST_THREAD_PROVIDES_CONDITION \
304 && ! defined BOOST_THREAD_DONT_PROVIDE_CONDITION
305 #define BOOST_THREAD_DONT_PROVIDE_CONDITION
308 #endif // BOOST_THREAD_VERSION>=4
311 #if BOOST_THREAD_VERSION>=5
312 //#define BOOST_THREAD_FUTURE_BLOCKING
314 //#define BOOST_THREAD_FUTURE_BLOCKING
315 #define BOOST_THREAD_ASYNC_FUTURE_WAITS
318 #if ! defined BOOST_THREAD_PROVIDES_INTERRUPTIONS \
319 && ! defined BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
320 #define BOOST_THREAD_PROVIDES_INTERRUPTIONS
325 // EXPLICIT_LOCK_CONVERSION.
326 #if defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
327 #define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION explicit
329 #define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION
332 // BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN is defined if BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
333 #if defined BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS \
334 && ! defined BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
335 #define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
338 // For C++11 call_once interface the compiler MUST support constexpr.
339 // Otherwise once_flag would be initialized during dynamic initialization stage, which is not thread-safe.
340 #if defined(BOOST_THREAD_PROVIDES_ONCE_CXX11)
341 #if defined(BOOST_NO_CXX11_CONSTEXPR)
342 #undef BOOST_THREAD_PROVIDES_ONCE_CXX11
346 #if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_DATETIME
347 #undef BOOST_THREAD_DONT_USE_DATETIME
348 #define BOOST_THREAD_USES_DATETIME
351 #if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_CHRONO
352 #undef BOOST_THREAD_DONT_USE_CHRONO
353 #define BOOST_THREAD_USES_CHRONO
356 // BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
357 // BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
358 #if defined BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0
360 #if ! defined BOOST_THREAD_PROVIDES_THREAD_EQ
361 #define BOOST_THREAD_PROVIDES_THREAD_EQ
367 //#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_THREAD_USES_MOVE
368 #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
369 #define BOOST_THREAD_FUTURE_USES_OPTIONAL
372 #if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
373 # pragma warn -8008 // Condition always true/false
374 # pragma warn -8080 // Identifier declared but never used
375 # pragma warn -8057 // Parameter never used
376 # pragma warn -8066 // Unreachable code
379 #include <boost/thread/detail/platform.hpp>
381 #if defined(BOOST_THREAD_PLATFORM_WIN32)
383 # if defined(BOOST_HAS_PTHREAD_DELAY_NP) || defined(BOOST_HAS_NANOSLEEP)
384 # define BOOST_THREAD_SLEEP_FOR_IS_STEADY
388 // provided for backwards compatibility, since this
389 // macro was used for several releases by mistake.
390 #if defined(BOOST_THREAD_DYN_DLL) && ! defined(BOOST_THREAD_DYN_LINK)
391 # define BOOST_THREAD_DYN_LINK
394 // compatibility with the rest of Boost's auto-linking code:
395 #if defined(BOOST_THREAD_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
396 # undef BOOST_THREAD_USE_LIB
397 # if !defined(BOOST_THREAD_USE_DLL)
398 # define BOOST_THREAD_USE_DLL
402 #if defined(BOOST_THREAD_BUILD_DLL) //Build dll
403 #elif defined(BOOST_THREAD_BUILD_LIB) //Build lib
404 #elif defined(BOOST_THREAD_USE_DLL) //Use dll
405 #elif defined(BOOST_THREAD_USE_LIB) //Use lib
407 # if defined(BOOST_THREAD_PLATFORM_WIN32)
408 # if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) \
409 || defined(__MINGW32__) || defined(MINGW32) || defined(BOOST_MINGW32)
410 //For compilers supporting auto-tss cleanup
411 //with Boost.Threads lib, use Boost.Threads lib
412 # define BOOST_THREAD_USE_LIB
414 //For compilers not yet supporting auto-tss cleanup
415 //with Boost.Threads lib, use Boost.Threads dll
416 # define BOOST_THREAD_USE_DLL
419 # define BOOST_THREAD_USE_LIB
423 #if defined(BOOST_HAS_DECLSPEC)
424 # if defined(BOOST_THREAD_BUILD_DLL) //Build dll
425 # define BOOST_THREAD_DECL BOOST_SYMBOL_EXPORT
426 //# define BOOST_THREAD_DECL __declspec(dllexport)
428 # elif defined(BOOST_THREAD_USE_DLL) //Use dll
429 # define BOOST_THREAD_DECL BOOST_SYMBOL_IMPORT
430 //# define BOOST_THREAD_DECL __declspec(dllimport)
432 # define BOOST_THREAD_DECL
434 #elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
435 # define BOOST_THREAD_DECL BOOST_SYMBOL_VISIBLE
438 # define BOOST_THREAD_DECL
439 #endif // BOOST_HAS_DECLSPEC
442 // Automatically link to the correct build variant where possible.
444 #if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_THREAD_NO_LIB) && !defined(BOOST_THREAD_BUILD_DLL) && !defined(BOOST_THREAD_BUILD_LIB)
446 // Tell the autolink to link dynamically, this will get undef'ed by auto_link.hpp
447 // once it's done with it:
449 #if defined(BOOST_THREAD_USE_DLL) & ! defined(BOOST_DYN_LINK)
450 # define BOOST_DYN_LINK
453 // Set the name of our library, this will get undef'ed by auto_link.hpp
454 // once it's done with it:
456 #if defined(BOOST_THREAD_LIB_NAME)
457 # define BOOST_LIB_NAME BOOST_THREAD_LIB_NAME
459 # define BOOST_LIB_NAME boost_thread
462 // If we're importing code from a dll, then tell auto_link.hpp about it:
464 // And include the header that does the work:
466 #include <boost/config/auto_link.hpp>
467 #endif // auto-linking disabled
469 #endif // BOOST_THREAD_CONFIG_WEK1032003_HPP
472 // 22 Jan 05 Roland Schwarz (speedsnail)
473 // Usage of BOOST_HAS_DECLSPEC macro.
474 // Default again is static lib usage.
475 // BOOST_DYN_LINK only defined when autolink included.