1// Copyright (C) 2001-2003
2// William E. Kempf
3// Copyright (C) 2011-2013 Vicente J. Botet Escriba
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#ifndef BOOST_THREAD_CONFIG_WEK01032003_HPP
9#define BOOST_THREAD_CONFIG_WEK01032003_HPP
10
11#include <boost/config.hpp>
12#include <boost/detail/workaround.hpp>
13#include <boost/thread/detail/platform.hpp>
14
15//#define BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
16// ATTRIBUTE_MAY_ALIAS
17
18#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
19
20 // GCC since 3.3 has may_alias attribute that helps to alleviate optimizer issues with
21 // regard to violation of the strict aliasing rules.
22
23 #define BOOST_THREAD_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
24 #define BOOST_THREAD_ATTRIBUTE_MAY_ALIAS __attribute__((__may_alias__))
25#else
26 #define BOOST_THREAD_ATTRIBUTE_MAY_ALIAS
27#endif
28
29
30#if defined BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
31#define BOOST_THREAD_ASSERT_PRECONDITION(EXPR, EX) \
32 if (EXPR) {} else boost::throw_exception(EX)
33#define BOOST_THREAD_VERIFY_PRECONDITION(EXPR, EX) \
34 if (EXPR) {} else boost::throw_exception(EX)
35#define BOOST_THREAD_THROW_ELSE_RETURN(EX, RET) \
36 boost::throw_exception(EX)
37#else
38#define BOOST_THREAD_ASSERT_PRECONDITION(EXPR, EX)
39#define BOOST_THREAD_VERIFY_PRECONDITION(EXPR, EX) \
40 (void)(EXPR)
41#define BOOST_THREAD_THROW_ELSE_RETURN(EX, RET) \
42 return (RET)
43#endif
44
45// This compiler doesn't support Boost.Chrono
46#if defined __IBMCPP__ && (__IBMCPP__ < 1100) \
47 && ! defined BOOST_THREAD_DONT_USE_CHRONO
48#define BOOST_THREAD_DONT_USE_CHRONO
49#if ! defined BOOST_THREAD_USES_DATETIME
50#define BOOST_THREAD_USES_DATETIME
51#endif
52#endif
53
54// This compiler doesn't support Boost.Move
55#if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) \
56 && ! defined BOOST_THREAD_DONT_USE_MOVE
57#define BOOST_THREAD_DONT_USE_MOVE
58#endif
59
60// This compiler doesn't support Boost.Container Allocators files
61#if defined __SUNPRO_CC \
62 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
63#define BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
64#endif
65
66#if defined _WIN32_WCE && _WIN32_WCE==0x501 \
67 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
68#define BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS
69#endif
70
71
72#if defined BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX || defined BOOST_NO_CXX11_HDR_INITIALIZER_LIST
73#define BOOST_THREAD_NO_CXX11_HDR_INITIALIZER_LIST
74#define BOOST_THREAD_NO_MAKE_LOCK_GUARD
75#define BOOST_THREAD_NO_MAKE_STRICT_LOCK
76#define BOOST_THREAD_NO_MAKE_NESTED_STRICT_LOCK
77#endif
78
79#if defined(BOOST_NO_CXX11_HDR_TUPLE) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
80#define BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS
81#define BOOST_THREAD_NO_SYNCHRONIZE
82#elif defined _MSC_VER && _MSC_VER <= 1600
83// C++ features supported by VC++ 10 (aka 2010)
84#define BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS
85#define BOOST_THREAD_NO_SYNCHRONIZE
86#endif
87
88/// BASIC_THREAD_ID
89#if ! defined BOOST_THREAD_DONT_PROVIDE_BASIC_THREAD_ID \
90 && ! defined BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
91#define BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
92#endif
93
94/// RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
95//#if defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC
96#define BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
97//#endif
98
99// Default version
100#if !defined BOOST_THREAD_VERSION
101#define BOOST_THREAD_VERSION 2
102#else
103#if BOOST_THREAD_VERSION!=2 && BOOST_THREAD_VERSION!=3 && BOOST_THREAD_VERSION!=4
104#error "BOOST_THREAD_VERSION must be 2, 3 or 4"
105#endif
106#endif
107
108// CHRONO
109// Uses Boost.Chrono by default if not stated the opposite defining BOOST_THREAD_DONT_USE_CHRONO
110#if ! defined BOOST_THREAD_DONT_USE_CHRONO \
111 && ! defined BOOST_THREAD_USES_CHRONO
112#define BOOST_THREAD_USES_CHRONO
113#endif
114
115#if ! defined BOOST_THREAD_DONT_USE_ATOMIC \
116 && ! defined BOOST_THREAD_USES_ATOMIC
117#define BOOST_THREAD_USES_ATOMIC
118//#define BOOST_THREAD_DONT_USE_ATOMIC
119#endif
120
121#if defined BOOST_THREAD_USES_ATOMIC
122// Andrey Semashev
123#define BOOST_THREAD_ONCE_ATOMIC
124#else
125//#elif ! defined BOOST_NO_CXX11_THREAD_LOCAL && ! defined BOOST_NO_THREAD_LOCAL && ! defined BOOST_THREAD_NO_UINT32_PSEUDO_ATOMIC
126// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2444.html#Appendix
127#define BOOST_THREAD_ONCE_FAST_EPOCH
128#endif
129#if BOOST_THREAD_VERSION==2
130
131// PROVIDE_PROMISE_LAZY
132#if ! defined BOOST_THREAD_DONT_PROVIDE_PROMISE_LAZY \
133 && ! defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
134#define BOOST_THREAD_PROVIDES_PROMISE_LAZY
135#endif
136
137// PROVIDE_THREAD_EQ
138#if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_EQ \
139 && ! defined BOOST_THREAD_PROVIDES_THREAD_EQ
140#define BOOST_THREAD_PROVIDES_THREAD_EQ
141#endif
142
143#endif
144
145#if BOOST_THREAD_VERSION>=3
146
147// ONCE_CXX11
148// fixme BOOST_THREAD_PROVIDES_ONCE_CXX11 doesn't works when thread.cpp is compiled BOOST_THREAD_VERSION 3
149#if ! defined BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11 \
150 && ! defined BOOST_THREAD_PROVIDES_ONCE_CXX11
151#define BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11
152#endif
153
154// THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
155#if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE \
156 && ! defined BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
157#define BOOST_THREAD_PROVIDES_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE
158#endif
159
160// THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
161#if ! defined BOOST_THREAD_DONT_PROVIDE_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE \
162 && ! defined BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
163#define BOOST_THREAD_PROVIDES_THREAD_MOVE_ASSIGN_CALLS_TERMINATE_IF_JOINABLE
164#endif
165
166// PROVIDE_FUTURE
167#if ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE \
168 && ! defined BOOST_THREAD_PROVIDES_FUTURE
169#define BOOST_THREAD_PROVIDES_FUTURE
170#endif
171
172// FUTURE_CTOR_ALLOCATORS
173#if ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS \
174 && ! defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
175#define BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
176#endif
177
178// SHARED_MUTEX_UPWARDS_CONVERSIONS
179#if ! defined BOOST_THREAD_DONT_PROVIDE_SHARED_MUTEX_UPWARDS_CONVERSIONS \
180 && ! defined BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
181#define BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
182#endif
183
184// PROVIDE_EXPLICIT_LOCK_CONVERSION
185#if ! defined BOOST_THREAD_DONT_PROVIDE_EXPLICIT_LOCK_CONVERSION \
186 && ! defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
187#define BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
188#endif
189
190// GENERIC_SHARED_MUTEX_ON_WIN
191#if ! defined BOOST_THREAD_DONT_PROVIDE_GENERIC_SHARED_MUTEX_ON_WIN \
192 && ! defined BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
193#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
194#endif
195
196// USE_MOVE
197#if ! defined BOOST_THREAD_DONT_USE_MOVE \
198 && ! defined BOOST_THREAD_USES_MOVE
199#define BOOST_THREAD_USES_MOVE
200#endif
201
202#endif
203
204// deprecated since version 4
205#if BOOST_THREAD_VERSION < 4
206
207// NESTED_LOCKS
208#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS \
209 && ! defined BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
210#define BOOST_THREAD_PROVIDES_NESTED_LOCKS
211#endif
212
213// CONDITION
214#if ! defined BOOST_THREAD_PROVIDES_CONDITION \
215 && ! defined BOOST_THREAD_DONT_PROVIDE_CONDITION
216#define BOOST_THREAD_PROVIDES_CONDITION
217#endif
218
219// USE_DATETIME
220#if ! defined BOOST_THREAD_DONT_USE_DATETIME \
221 && ! defined BOOST_THREAD_USES_DATETIME
222#define BOOST_THREAD_USES_DATETIME
223#endif
224#endif
225
226#if BOOST_THREAD_VERSION>=4
227
228// SIGNATURE_PACKAGED_TASK
229#if ! defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK \
230 && ! defined BOOST_THREAD_DONT_PROVIDE_SIGNATURE_PACKAGED_TASK
231#define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
232#endif
233
234// VARIADIC_THREAD
235#if ! defined BOOST_THREAD_PROVIDES_VARIADIC_THREAD \
236 && ! defined BOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD
237
238#if ! defined(BOOST_NO_SFINAE_EXPR) && \
239 ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
240 ! defined(BOOST_NO_CXX11_DECLTYPE) && \
241 ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) && \
242 ! defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) && \
243 ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
244 ! defined(BOOST_NO_CXX11_HDR_TUPLE)
245
246#define BOOST_THREAD_PROVIDES_VARIADIC_THREAD
247#endif
248#endif
249
250#if ! defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY \
251 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_WHEN_ALL_WHEN_ANY
252
253#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
254 ! defined(BOOST_NO_CXX11_HDR_TUPLE)
255
256#define BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY
257#endif
258#endif
259
260// ! defined(BOOST_NO_SFINAE_EXPR) &&
261// ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES) &&
262// ! defined(BOOST_NO_CXX11_AUTO) &&
263// ! defined(BOOST_NO_CXX11_DECLTYPE) &&
264// ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) &&
265
266
267// MAKE_READY_AT_THREAD_EXIT
268#if ! defined BOOST_THREAD_PROVIDES_MAKE_READY_AT_THREAD_EXIT \
269 && ! defined BOOST_THREAD_DONT_PROVIDE_MAKE_READY_AT_THREAD_EXIT
270
271//#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
272#define BOOST_THREAD_PROVIDES_MAKE_READY_AT_THREAD_EXIT
273//#endif
274#endif
275
276// FUTURE_CONTINUATION
277#if ! defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \
278 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_CONTINUATION
279#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
280#endif
281
282#if ! defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP \
283 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_UNWRAP
284#define BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
285#endif
286
287// FUTURE_INVALID_AFTER_GET
288#if ! defined BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET \
289 && ! defined BOOST_THREAD_DONT_PROVIDE_FUTURE_INVALID_AFTER_GET
290#define BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
291#endif
292
293// NESTED_LOCKS
294#if ! defined BOOST_THREAD_PROVIDES_NESTED_LOCKS \
295 && ! defined BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
296#define BOOST_THREAD_DONT_PROVIDE_NESTED_LOCKS
297#endif
298
299// CONDITION
300#if ! defined BOOST_THREAD_PROVIDES_CONDITION \
301 && ! defined BOOST_THREAD_DONT_PROVIDE_CONDITION
302#define BOOST_THREAD_DONT_PROVIDE_CONDITION
303#endif
304
305#endif // BOOST_THREAD_VERSION>=4
306
307// INTERRUPTIONS
308#if ! defined BOOST_THREAD_PROVIDES_INTERRUPTIONS \
309 && ! defined BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
310#define BOOST_THREAD_PROVIDES_INTERRUPTIONS
311#endif
312
313// CORRELATIONS
314
315// EXPLICIT_LOCK_CONVERSION.
316#if defined BOOST_THREAD_PROVIDES_EXPLICIT_LOCK_CONVERSION
317#define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION explicit
318#else
319#define BOOST_THREAD_EXPLICIT_LOCK_CONVERSION
320#endif
321
322// BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN is defined if BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS
323#if defined BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSIONS \
324&& ! defined BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
325#define BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
326#endif
327
328// For C++11 call_once interface the compiler MUST support constexpr.
329// Otherwise once_flag would be initialized during dynamic initialization stage, which is not thread-safe.
330#if defined(BOOST_THREAD_PROVIDES_ONCE_CXX11)
331#if defined(BOOST_NO_CXX11_CONSTEXPR)
332#undef BOOST_THREAD_PROVIDES_ONCE_CXX11
333#endif
334#endif
335
336#if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_DATETIME
337#undef BOOST_THREAD_DONT_USE_DATETIME
338#define BOOST_THREAD_USES_DATETIME
339#endif
340
341#if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_CHRONO
342#undef BOOST_THREAD_DONT_USE_CHRONO
343#define BOOST_THREAD_USES_CHRONO
344#endif
345
346// BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
347// BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
348#if defined BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0
349
350#if ! defined BOOST_THREAD_PROVIDES_THREAD_EQ
351#define BOOST_THREAD_PROVIDES_THREAD_EQ
352#endif
353
354#endif
355
356
357//#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_THREAD_USES_MOVE
358#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
359#define BOOST_THREAD_FUTURE_USES_OPTIONAL
360#endif
361
362#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
363# pragma warn -8008 // Condition always true/false
364# pragma warn -8080 // Identifier declared but never used
365# pragma warn -8057 // Parameter never used
366# pragma warn -8066 // Unreachable code
367#endif
368
369#include <boost/thread/detail/platform.hpp>
370
371#if defined(BOOST_THREAD_PLATFORM_WIN32)
372#else
373 # if defined(BOOST_HAS_PTHREAD_DELAY_NP) || defined(BOOST_HAS_NANOSLEEP)
374 # define BOOST_THREAD_SLEEP_FOR_IS_STEADY
375 # endif
376#endif
377
378// provided for backwards compatibility, since this
379// macro was used for several releases by mistake.
380#if defined(BOOST_THREAD_DYN_DLL) && ! defined BOOST_THREAD_DYN_LINK
381# define BOOST_THREAD_DYN_LINK
382#endif
383
384// compatibility with the rest of Boost's auto-linking code:
385#if defined(BOOST_THREAD_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
386# undef BOOST_THREAD_USE_LIB
387# if !defined(BOOST_THREAD_USE_DLL)
388# define BOOST_THREAD_USE_DLL
389# endif
390#endif
391
392#if defined(BOOST_THREAD_BUILD_DLL) //Build dll
393#elif defined(BOOST_THREAD_BUILD_LIB) //Build lib
394#elif defined(BOOST_THREAD_USE_DLL) //Use dll
395#elif defined(BOOST_THREAD_USE_LIB) //Use lib
396#else //Use default
397# if defined(BOOST_THREAD_PLATFORM_WIN32)
398# if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) \
399 || defined(__MINGW32__) || defined(MINGW32) || defined(BOOST_MINGW32)
400 //For compilers supporting auto-tss cleanup
401 //with Boost.Threads lib, use Boost.Threads lib
402# define BOOST_THREAD_USE_LIB
403# else
404 //For compilers not yet supporting auto-tss cleanup
405 //with Boost.Threads lib, use Boost.Threads dll
406# define BOOST_THREAD_USE_DLL
407# endif
408# else
409# define BOOST_THREAD_USE_LIB
410# endif
411#endif
412
413#if defined(BOOST_HAS_DECLSPEC)
414# if defined(BOOST_THREAD_BUILD_DLL) //Build dll
415# define BOOST_THREAD_DECL BOOST_SYMBOL_EXPORT
416//# define BOOST_THREAD_DECL __declspec(dllexport)
417
418# elif defined(BOOST_THREAD_USE_DLL) //Use dll
419# define BOOST_THREAD_DECL BOOST_SYMBOL_IMPORT
420//# define BOOST_THREAD_DECL __declspec(dllimport)
421# else
422# define BOOST_THREAD_DECL
423# endif
424#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
425# define BOOST_THREAD_DECL BOOST_SYMBOL_VISIBLE
426
427#else
428# define BOOST_THREAD_DECL
429#endif // BOOST_HAS_DECLSPEC
430
431//
432// Automatically link to the correct build variant where possible.
433//
434#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_THREAD_NO_LIB) && !defined(BOOST_THREAD_BUILD_DLL) && !defined(BOOST_THREAD_BUILD_LIB)
435//
436// Tell the autolink to link dynamically, this will get undef'ed by auto_link.hpp
437// once it's done with it:
438//
439#if defined(BOOST_THREAD_USE_DLL)
440# define BOOST_DYN_LINK
441#endif
442//
443// Set the name of our library, this will get undef'ed by auto_link.hpp
444// once it's done with it:
445//
446#if defined(BOOST_THREAD_LIB_NAME)
447# define BOOST_LIB_NAME BOOST_THREAD_LIB_NAME
448#else
449# define BOOST_LIB_NAME boost_thread
450#endif
451//
452// If we're importing code from a dll, then tell auto_link.hpp about it:
453//
454// And include the header that does the work:
455//
456#include <boost/config/auto_link.hpp>
457#endif // auto-linking disabled
458
459#endif // BOOST_THREAD_CONFIG_WEK1032003_HPP
460
461// Change Log:
462// 22 Jan 05 Roland Schwarz (speedsnail)
463// Usage of BOOST_HAS_DECLSPEC macro.
464// Default again is static lib usage.
465// BOOST_DYN_LINK only defined when autolink included.
466