1/*
2 Copyright 2005-2013 Intel Corporation. All Rights Reserved.
3
4 This file is part of Threading Building Blocks.
5
6 Threading Building Blocks is free software; you can redistribute it
7 and/or modify it under the terms of the GNU General Public License
8 version 2 as published by the Free Software Foundation.
9
10 Threading Building Blocks is distributed in the hope that it will be
11 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Threading Building Blocks; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 As a special exception, you may use this file as part of a free software
20 library without restriction. Specifically, if other files instantiate
21 templates or use macros or inline functions from this file, or you compile
22 this file and link it with other files to produce an executable, this
23 file does not by itself cause the resulting executable to be covered by
24 the GNU General Public License. This exception does not however
25 invalidate any other reasons why the executable file might be covered by
26 the GNU General Public License.
27*/
28
29#ifndef __TBB_tbb_config_H
30#define __TBB_tbb_config_H
31
32/** This header is supposed to contain macro definitions and C style comments only.
33 The macros defined here are intended to control such aspects of TBB build as
34 - presence of compiler features
35 - compilation modes
36 - feature sets
37 - known compiler/platform issues
38**/
39
40/*Check which standard library we use on OS X.*/
41/*__TBB_SYMBOL is defined only while processing exported symbols list where C++ is not allowed.*/
42#if !defined(__TBB_SYMBOL) && __APPLE__
43 #include <cstddef>
44#endif
45
46#define __TBB_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
47
48#if __clang__
49 /**according to clang documentation version can be vendor specific **/
50 #define __TBB_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
51#endif
52
53/** Presence of compiler features **/
54
55#if __INTEL_COMPILER == 9999 && __INTEL_COMPILER_BUILD_DATE == 20110811
56/* Intel(R) Composer XE 2011 Update 6 incorrectly sets __INTEL_COMPILER. Fix it. */
57 #undef __INTEL_COMPILER
58 #define __INTEL_COMPILER 1210
59#endif
60
61#if __TBB_GCC_VERSION >= 40400 && !defined(__INTEL_COMPILER)
62 /** warning suppression pragmas available in GCC since 4.4 **/
63 #define __TBB_GCC_WARNING_SUPPRESSION_PRESENT 1
64#endif
65
66/* Select particular features of C++11 based on compiler version.
67 ICC 12.1 (Linux), GCC 4.3 and higher, clang 2.9 and higher
68 set __GXX_EXPERIMENTAL_CXX0X__ in c++11 mode.
69
70 Compilers that mimics other compilers (ICC, clang) must be processed before
71 compilers they mimic (GCC, MSVC).
72
73 TODO: The following conditions should be extended when new compilers/runtimes
74 support added.
75 */
76
77#if __INTEL_COMPILER
78 /** C++11 mode detection macros for Intel C++ compiler (enabled by -std=c++0x option):
79 __INTEL_CXX11_MODE__ for version >=13.0
80 __STDC_HOSTED__ for version >=12.0 on Windows,
81 __GXX_EXPERIMENTAL_CXX0X__ for version >=12.0 on Linux and OS X. **/
82 // On Windows, C++11 features supported by Visual Studio 2010 and higher are enabled by default
83 #ifndef __INTEL_CXX11_MODE__
84 #define __INTEL_CXX11_MODE__ ((_MSC_VER && __STDC_HOSTED__) || __GXX_EXPERIMENTAL_CXX0X__)
85 // TODO: check if more conditions can be simplified with the above macro
86 #endif
87 #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT (__INTEL_CXX11_MODE__ && __VARIADIC_TEMPLATES)
88 #define __TBB_CPP11_RVALUE_REF_PRESENT ((__GXX_EXPERIMENTAL_CXX0X__ || _MSC_VER >= 1600) && __INTEL_COMPILER >= 1200)
89 #if _MSC_VER >= 1600
90 #define __TBB_EXCEPTION_PTR_PRESENT ( __INTEL_COMPILER > 1300 \
91 /*ICC 12.1 Upd 10 and 13 beta Upd 2 fixed exception_ptr linking issue*/ \
92 || (__INTEL_COMPILER == 1300 && __INTEL_COMPILER_BUILD_DATE >= 20120530) \
93 || (__INTEL_COMPILER == 1210 && __INTEL_COMPILER_BUILD_DATE >= 20120410) )
94 /** libstdc++ that comes with GCC 4.6 use C++11 features not supported by ICC 12.1.
95 * Because of that ICC 12.1 does not support C++11 mode with with gcc 4.6 (or higher),
96 * and therefore does not define __GXX_EXPERIMENTAL_CXX0X__ macro **/
97 #elif __TBB_GCC_VERSION >= 40404 && __TBB_GCC_VERSION < 40600
98 #define __TBB_EXCEPTION_PTR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1200)
99 #elif __TBB_GCC_VERSION >= 40600
100 #define __TBB_EXCEPTION_PTR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1300)
101 #else
102 #define __TBB_EXCEPTION_PTR_PRESENT 0
103 #endif
104 #define __TBB_MAKE_EXCEPTION_PTR_PRESENT (_MSC_VER >= 1700 || (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40600))
105 #define __TBB_STATIC_ASSERT_PRESENT (__INTEL_CXX11_MODE__ || _MSC_VER >= 1600)
106 #define __TBB_CPP11_TUPLE_PRESENT (_MSC_VER >= 1600 || (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40300))
107 /** TODO: re-check for compiler version greater than 12.1 if it supports initializer lists**/
108 #define __TBB_INITIALIZER_LISTS_PRESENT 0
109 #define __TBB_CONSTEXPR_PRESENT 0
110 #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT __INTEL_CXX11_MODE__
111#elif __clang__
112//TODO: these options need to be rechecked
113/** on OS X* the only way to get C++11 is to use clang. For library features (e.g. exception_ptr) libc++ is also
114 * required. So there is no need to check GCC version for clang**/
115 #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT __has_feature(__cxx_variadic_templates__)
116 #define __TBB_CPP11_RVALUE_REF_PRESENT __has_feature(__cxx_rvalue_references__)
117/** TODO: extend exception_ptr related conditions to cover libstdc++ **/
118 #define __TBB_EXCEPTION_PTR_PRESENT (__cplusplus >= 201103L && _LIBCPP_VERSION)
119 #define __TBB_MAKE_EXCEPTION_PTR_PRESENT (__cplusplus >= 201103L && _LIBCPP_VERSION)
120 #define __TBB_STATIC_ASSERT_PRESENT __has_feature(__cxx_static_assert__)
121 /**Clang (preprocessor) has problems with dealing with expression having __has_include in #if's
122 * used inside C++ code. (At least version that comes with OS X 10.8) **/
123 #if (__GXX_EXPERIMENTAL_CXX0X__ && __has_include(<tuple>))
124 #define __TBB_CPP11_TUPLE_PRESENT 1
125 #endif
126 #if (__has_feature(__cxx_generalized_initializers__) && __has_include(<initializer_list>))
127 #define __TBB_INITIALIZER_LISTS_PRESENT 1
128 #endif
129 #define __TBB_CONSTEXPR_PRESENT __has_feature(__cxx_constexpr__)
130 #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT (__has_feature(__cxx_defaulted_functions__) && __has_feature(__cxx_deleted_functions__))
131#elif __GNUC__
132 #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT __GXX_EXPERIMENTAL_CXX0X__
133 #define __TBB_CPP11_RVALUE_REF_PRESENT __GXX_EXPERIMENTAL_CXX0X__
134 /** __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 here is a substitution for _GLIBCXX_ATOMIC_BUILTINS_4, which is a prerequisite
135 for exception_ptr but cannot be used in this file because it is defined in a header, not by the compiler.
136 If the compiler has no atomic intrinsics, the C++ library should not expect those as well. **/
137 #define __TBB_EXCEPTION_PTR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40404 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
138 #define __TBB_MAKE_EXCEPTION_PTR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40600)
139 #define __TBB_STATIC_ASSERT_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40300)
140 #define __TBB_CPP11_TUPLE_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40300)
141 #define __TBB_INITIALIZER_LISTS_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
142 /** gcc seems have to support constexpr from 4.4 but tests in (test_atomic) seeming reasonable fail to compile prior 4.6**/
143 #define __TBB_CONSTEXPR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
144 #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
145#elif _MSC_VER
146 #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 0
147 #define __TBB_CPP11_RVALUE_REF_PRESENT (_MSC_VER >= 1600)
148 #define __TBB_EXCEPTION_PTR_PRESENT (_MSC_VER >= 1600)
149 #define __TBB_STATIC_ASSERT_PRESENT (_MSC_VER >= 1600)
150 #define __TBB_MAKE_EXCEPTION_PTR_PRESENT (_MSC_VER >= 1700)
151 #define __TBB_CPP11_TUPLE_PRESENT (_MSC_VER >= 1600)
152 #define __TBB_INITIALIZER_LISTS_PRESENT 0
153 #define __TBB_CONSTEXPR_PRESENT 0
154 #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT 0
155#else
156 #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 0
157 #define __TBB_CPP11_RVALUE_REF_PRESENT 0
158 #define __TBB_EXCEPTION_PTR_PRESENT 0
159 #define __TBB_STATIC_ASSERT_PRESENT 0
160 #define __TBB_MAKE_EXCEPTION_PTR_PRESENT 0
161 #define __TBB_CPP11_TUPLE_PRESENT 0
162 #define __TBB_INITIALIZER_LISTS_PRESENT 0
163 #define __TBB_CONSTEXPR_PRESENT 0
164 #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT 0
165#endif
166
167//TODO: not clear how exactly this macro affects exception_ptr - investigate
168// On linux ICC fails to find existing std::exception_ptr in libstdc++ without this define
169#if __INTEL_COMPILER && __GNUC__ && __TBB_EXCEPTION_PTR_PRESENT && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
170 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
171#endif
172
173// Work around a bug in MinGW32
174#if __MINGW32__ && __TBB_EXCEPTION_PTR_PRESENT && !defined(_GLIBCXX_ATOMIC_BUILTINS_4)
175 #define _GLIBCXX_ATOMIC_BUILTINS_4
176#endif
177
178#if __GNUC__ || __SUNPRO_CC || __IBMCPP__
179 /* ICC defines __GNUC__ and so is covered */
180 #define __TBB_ATTRIBUTE_ALIGNED_PRESENT 1
181#elif _MSC_VER && (_MSC_VER >= 1300 || __INTEL_COMPILER)
182 #define __TBB_DECLSPEC_ALIGN_PRESENT 1
183#endif
184
185/* Actually ICC supports gcc __sync_* intrinsics starting 11.1,
186 * but 64 bit support for 32 bit target comes in later ones*/
187/* TODO: change the version back to 4.1.2 once macro __TBB_WORD_SIZE become optional */
188#if __TBB_GCC_VERSION >= 40306 || __INTEL_COMPILER >= 1200
189 /** built-in atomics available in GCC since 4.1.2 **/
190 #define __TBB_GCC_BUILTIN_ATOMICS_PRESENT 1
191#endif
192
193#if __INTEL_COMPILER >= 1200
194 /** built-in C++11 style atomics available in ICC since 12.0 **/
195 #define __TBB_ICC_BUILTIN_ATOMICS_PRESENT 1
196#endif
197
198/** User controlled TBB features & modes **/
199
200#ifndef TBB_USE_DEBUG
201#ifdef TBB_DO_ASSERT
202#define TBB_USE_DEBUG TBB_DO_ASSERT
203#else
204#ifdef _DEBUG
205#define TBB_USE_DEBUG _DEBUG
206#else
207#define TBB_USE_DEBUG 0
208#endif
209#endif /* TBB_DO_ASSERT */
210#endif /* TBB_USE_DEBUG */
211
212#ifndef TBB_USE_ASSERT
213#ifdef TBB_DO_ASSERT
214#define TBB_USE_ASSERT TBB_DO_ASSERT
215#else
216#define TBB_USE_ASSERT TBB_USE_DEBUG
217#endif /* TBB_DO_ASSERT */
218#endif /* TBB_USE_ASSERT */
219
220#ifndef TBB_USE_THREADING_TOOLS
221#ifdef TBB_DO_THREADING_TOOLS
222#define TBB_USE_THREADING_TOOLS TBB_DO_THREADING_TOOLS
223#else
224#define TBB_USE_THREADING_TOOLS TBB_USE_DEBUG
225#endif /* TBB_DO_THREADING_TOOLS */
226#endif /* TBB_USE_THREADING_TOOLS */
227
228#ifndef TBB_USE_PERFORMANCE_WARNINGS
229#ifdef TBB_PERFORMANCE_WARNINGS
230#define TBB_USE_PERFORMANCE_WARNINGS TBB_PERFORMANCE_WARNINGS
231#else
232#define TBB_USE_PERFORMANCE_WARNINGS TBB_USE_DEBUG
233#endif /* TBB_PEFORMANCE_WARNINGS */
234#endif /* TBB_USE_PERFORMANCE_WARNINGS */
235
236#if __MIC__ || __MIC2__
237#define __TBB_DEFINE_MIC 1
238#endif
239
240#if !defined(__EXCEPTIONS) && !defined(_CPPUNWIND) && !defined(__SUNPRO_CC) || defined(_XBOX)
241 #if TBB_USE_EXCEPTIONS
242 #error Compilation settings do not support exception handling. Please do not set TBB_USE_EXCEPTIONS macro or set it to 0.
243 #elif !defined(TBB_USE_EXCEPTIONS)
244 #define TBB_USE_EXCEPTIONS 0
245 #endif
246#elif !defined(TBB_USE_EXCEPTIONS)
247 #if __TBB_DEFINE_MIC
248 #define TBB_USE_EXCEPTIONS 0
249 #else
250 #define TBB_USE_EXCEPTIONS 1
251 #endif
252#elif TBB_USE_EXCEPTIONS && __TBB_DEFINE_MIC
253 #error Please do not set TBB_USE_EXCEPTIONS macro or set it to 0.
254#endif
255
256#ifndef TBB_IMPLEMENT_CPP0X
257 /** By default, use C++0x classes if available **/
258 #if __GNUC__==4 && __GNUC_MINOR__>=4 && __GXX_EXPERIMENTAL_CXX0X__
259 #define TBB_IMPLEMENT_CPP0X 0
260 #elif __clang__ && __cplusplus >= 201103L
261 //TODO: consider introducing separate macros for each file?
262 //prevent injection of corresponding tbb names into std:: namespace if native headers are present
263 #if __has_include(<thread>) || __has_include(<condition_variable>)
264 #define TBB_IMPLEMENT_CPP0X 0
265 #else
266 #define TBB_IMPLEMENT_CPP0X 1
267 #endif
268 #else
269 #define TBB_IMPLEMENT_CPP0X 1
270 #endif
271#endif /* TBB_IMPLEMENT_CPP0X */
272
273/* TBB_USE_CAPTURED_EXCEPTION should be explicitly set to either 0 or 1, as it is used as C++ const */
274#ifndef TBB_USE_CAPTURED_EXCEPTION
275 /** IA-64 architecture pre-built TBB binaries do not support exception_ptr. **/
276 #if __TBB_EXCEPTION_PTR_PRESENT && !defined(__ia64__)
277 #define TBB_USE_CAPTURED_EXCEPTION 0
278 #else
279 #define TBB_USE_CAPTURED_EXCEPTION 1
280 #endif
281#else /* defined TBB_USE_CAPTURED_EXCEPTION */
282 #if !TBB_USE_CAPTURED_EXCEPTION && !__TBB_EXCEPTION_PTR_PRESENT
283 #error Current runtime does not support std::exception_ptr. Set TBB_USE_CAPTURED_EXCEPTION and make sure that your code is ready to catch tbb::captured_exception.
284 #endif
285#endif /* defined TBB_USE_CAPTURED_EXCEPTION */
286
287/** Check whether the request to use GCC atomics can be satisfied **/
288#if TBB_USE_GCC_BUILTINS && !__TBB_GCC_BUILTIN_ATOMICS_PRESENT
289 #error "GCC atomic built-ins are not supported."
290#endif
291
292/** Internal TBB features & modes **/
293
294/** __TBB_WEAK_SYMBOLS_PRESENT denotes that the system supports the weak symbol mechanism **/
295#ifndef __TBB_WEAK_SYMBOLS_PRESENT
296#define __TBB_WEAK_SYMBOLS_PRESENT ( !_WIN32 && !__APPLE__ && !__sun && (__TBB_GCC_VERSION >= 40000 || __INTEL_COMPILER ) )
297#endif
298
299/** __TBB_DYNAMIC_LOAD_ENABLED describes the system possibility to load shared libraries at run time **/
300#ifndef __TBB_DYNAMIC_LOAD_ENABLED
301 #define __TBB_DYNAMIC_LOAD_ENABLED 1
302#endif
303
304/** __TBB_SOURCE_DIRECTLY_INCLUDED is a mode used in whitebox testing when
305 it's necessary to test internal functions not exported from TBB DLLs
306**/
307#if (_WIN32||_WIN64) && __TBB_SOURCE_DIRECTLY_INCLUDED
308 #define __TBB_NO_IMPLICIT_LINKAGE 1
309 #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
310#endif
311
312#ifndef __TBB_COUNT_TASK_NODES
313 #define __TBB_COUNT_TASK_NODES TBB_USE_ASSERT
314#endif
315
316#ifndef __TBB_TASK_GROUP_CONTEXT
317 #define __TBB_TASK_GROUP_CONTEXT 1
318#endif /* __TBB_TASK_GROUP_CONTEXT */
319
320#ifndef __TBB_SCHEDULER_OBSERVER
321 #define __TBB_SCHEDULER_OBSERVER 1
322#endif /* __TBB_SCHEDULER_OBSERVER */
323
324#if !defined(TBB_PREVIEW_TASK_ARENA) && __TBB_BUILD
325 #define TBB_PREVIEW_TASK_ARENA __TBB_CPF_BUILD
326#endif /* TBB_PREVIEW_TASK_ARENA */
327#define __TBB_TASK_ARENA TBB_PREVIEW_TASK_ARENA
328#if TBB_PREVIEW_TASK_ARENA
329 #define TBB_PREVIEW_LOCAL_OBSERVER 1
330 #define __TBB_NO_IMPLICIT_LINKAGE 1
331 #define __TBB_RECYCLE_TO_ENQUEUE 1
332 #ifndef __TBB_TASK_PRIORITY
333 #define __TBB_TASK_PRIORITY 0 // TODO: it will be removed in next versions
334 #endif
335 #if !__TBB_SCHEDULER_OBSERVER
336 #error TBB_PREVIEW_TASK_ARENA requires __TBB_SCHEDULER_OBSERVER to be enabled
337 #endif
338#endif /* TBB_PREVIEW_TASK_ARENA */
339
340#if !defined(TBB_PREVIEW_LOCAL_OBSERVER) && __TBB_BUILD && __TBB_SCHEDULER_OBSERVER
341 #define TBB_PREVIEW_LOCAL_OBSERVER 1
342#endif /* TBB_PREVIEW_LOCAL_OBSERVER */
343
344#if TBB_USE_EXCEPTIONS && !__TBB_TASK_GROUP_CONTEXT
345 #error TBB_USE_EXCEPTIONS requires __TBB_TASK_GROUP_CONTEXT to be enabled
346#endif
347
348#ifndef __TBB_TASK_PRIORITY
349 #define __TBB_TASK_PRIORITY __TBB_TASK_GROUP_CONTEXT
350#endif /* __TBB_TASK_PRIORITY */
351
352#if __TBB_TASK_PRIORITY && !__TBB_TASK_GROUP_CONTEXT
353 #error __TBB_TASK_PRIORITY requires __TBB_TASK_GROUP_CONTEXT to be enabled
354#endif
355
356#if TBB_PREVIEW_WAITING_FOR_WORKERS || __TBB_BUILD
357 #define __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE 1
358#endif
359
360#if !defined(__TBB_SURVIVE_THREAD_SWITCH) && \
361 (_WIN32 || _WIN64 || __APPLE__ || (__linux__ && !__ANDROID__))
362 #define __TBB_SURVIVE_THREAD_SWITCH 1
363#endif /* __TBB_SURVIVE_THREAD_SWITCH */
364
365#ifndef __TBB_DEFAULT_PARTITIONER
366#if TBB_DEPRECATED
367/** Default partitioner for parallel loop templates in TBB 1.0-2.1 */
368#define __TBB_DEFAULT_PARTITIONER tbb::simple_partitioner
369#else
370/** Default partitioner for parallel loop templates since TBB 2.2 */
371#define __TBB_DEFAULT_PARTITIONER tbb::auto_partitioner
372#endif /* TBB_DEPRECATED */
373#endif /* !defined(__TBB_DEFAULT_PARTITIONER */
374
375#ifdef _VARIADIC_MAX
376#define __TBB_VARIADIC_MAX _VARIADIC_MAX
377#else
378#if _MSC_VER >= 1700
379#define __TBB_VARIADIC_MAX 5 /* current VS11 setting, may change. */
380#else
381#define __TBB_VARIADIC_MAX 10
382#endif
383#endif
384
385/** __TBB_WIN8UI_SUPPORT enables support of New Windows*8 Store Apps and limit a possibility to load
386 shared libraries at run time only from application container **/
387#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_APP
388 #define __TBB_WIN8UI_SUPPORT 1
389#else
390 #define __TBB_WIN8UI_SUPPORT 0
391#endif
392
393// Define preprocessor symbols used to determine architecture
394#if _WIN32||_WIN64
395# if defined(_M_X64)||defined(__x86_64__) // the latter for MinGW support
396# define __TBB_x86_64 1
397# elif defined(_M_IA64)
398# define __TBB_ipf 1
399# elif defined(_M_IX86)||defined(__i386__) // the latter for MinGW support
400# define __TBB_x86_32 1
401# endif
402#else /* Assume generic Unix */
403# if !__linux__ && !__APPLE__
404# define __TBB_generic_os 1
405# endif
406# if __x86_64__
407# define __TBB_x86_64 1
408# elif __ia64__
409# define __TBB_ipf 1
410# elif __i386__||__i386 // __i386 is for Sun OS
411# define __TBB_x86_32 1
412# else
413# define __TBB_generic_arch 1
414# endif
415#endif
416
417/** Macros of the form __TBB_XXX_BROKEN denote known issues that are caused by
418 the bugs in compilers, standard or OS specific libraries. They should be
419 removed as soon as the corresponding bugs are fixed or the buggy OS/compiler
420 versions go out of the support list.
421**/
422
423#if __ANDROID__ && __TBB_GCC_VERSION <= 40403 && !__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
424 /** Necessary because on Android 8-byte CAS and F&A are not available for some processor architectures,
425 but no mandatory warning message appears from GCC 4.4.3. Instead, only a linkage error occurs when
426 these atomic operations are used (such as in unit test test_atomic.exe). **/
427 #define __TBB_GCC_64BIT_ATOMIC_BUILTINS_BROKEN 1
428#endif
429
430#if __GNUC__ && __TBB_x86_64 && __INTEL_COMPILER == 1200
431 #define __TBB_ICC_12_0_INL_ASM_FSTCW_BROKEN 1
432#endif
433
434#if _MSC_VER && __INTEL_COMPILER && (__INTEL_COMPILER<1110 || __INTEL_COMPILER==1110 && __INTEL_COMPILER_BUILD_DATE < 20091012)
435 /** Necessary to avoid ICL error (or warning in non-strict mode):
436 "exception specification for implicitly declared virtual destructor is
437 incompatible with that of overridden one". **/
438 #define __TBB_DEFAULT_DTOR_THROW_SPEC_BROKEN 1
439#endif
440
441#if defined(_MSC_VER) && _MSC_VER < 1500 && !defined(__INTEL_COMPILER)
442 /** VS2005 and earlier do not allow declaring template class as a friend
443 of classes defined in other namespaces. **/
444 #define __TBB_TEMPLATE_FRIENDS_BROKEN 1
445#endif
446
447//TODO: recheck for different clang versions
448#if __GLIBC__==2 && __GLIBC_MINOR__==3 || __MINGW32__ || (__APPLE__ && ( __INTEL_COMPILER==1200 && !TBB_USE_DEBUG))
449 /** Macro controlling EH usages in TBB tests.
450 Some older versions of glibc crash when exception handling happens concurrently. **/
451 #define __TBB_THROW_ACROSS_MODULE_BOUNDARY_BROKEN 1
452#else
453 #define __TBB_THROW_ACROSS_MODULE_BOUNDARY_BROKEN 0
454#endif
455
456#if (_WIN32||_WIN64) && __INTEL_COMPILER == 1110
457 /** That's a bug in Intel compiler 11.1.044/IA-32/Windows, that leads to a worker thread crash on the thread's startup. **/
458 #define __TBB_ICL_11_1_CODE_GEN_BROKEN 1
459#endif
460
461#if __clang__ || (__GNUC__==3 && __GNUC_MINOR__==3 && !defined(__INTEL_COMPILER))
462 /** Bugs with access to nested classes declared in protected area */
463 #define __TBB_PROTECTED_NESTED_CLASS_BROKEN 1
464#endif
465
466#if __MINGW32__ && __TBB_GCC_VERSION < 40200
467 /** MinGW has a bug with stack alignment for routines invoked from MS RTLs.
468 Since GCC 4.2, the bug can be worked around via a special attribute. **/
469 #define __TBB_SSE_STACK_ALIGNMENT_BROKEN 1
470#else
471 #define __TBB_SSE_STACK_ALIGNMENT_BROKEN 0
472#endif
473
474#if __GNUC__==4 && __GNUC_MINOR__==3 && __GNUC_PATCHLEVEL__==0
475 /* GCC of this version may rashly ignore control dependencies */
476 #define __TBB_GCC_OPTIMIZER_ORDERING_BROKEN 1
477#endif
478
479#if __FreeBSD__
480 /** A bug in FreeBSD 8.0 results in kernel panic when there is contention
481 on a mutex created with this attribute. **/
482 #define __TBB_PRIO_INHERIT_BROKEN 1
483
484 /** A bug in FreeBSD 8.0 results in test hanging when an exception occurs
485 during (concurrent?) object construction by means of placement new operator. **/
486 #define __TBB_PLACEMENT_NEW_EXCEPTION_SAFETY_BROKEN 1
487#endif /* __FreeBSD__ */
488
489#if (__linux__ || __APPLE__) && __i386__ && defined(__INTEL_COMPILER)
490 /** The Intel compiler for IA-32 (Linux|OS X) crashes or generates
491 incorrect code when __asm__ arguments have a cast to volatile. **/
492 #define __TBB_ICC_ASM_VOLATILE_BROKEN 1
493#endif
494
495#if !__INTEL_COMPILER && (_MSC_VER || __GNUC__==3 && __GNUC_MINOR__<=2)
496 /** Bug in GCC 3.2 and MSVC compilers that sometimes return 0 for __alignof(T)
497 when T has not yet been instantiated. **/
498 #define __TBB_ALIGNOF_NOT_INSTANTIATED_TYPES_BROKEN 1
499#endif
500
501/* Actually for Clang it should be name __TBB_CPP11_STD_FORWARD_PRESENT.
502 * But in order to check for presence of std:: library feature we need to recognize
503 * is standard library actually used stdlibc++ (GNU one) or libc++ (clang one).
504 * Unfortunately it is not possible at the moment. So postponing it to later moment.*/
505/*TODO: for clang rename it to __TBB_CPP11_STD_FORWARD_PRESENT and re-implement it.*/
506#if (__INTEL_COMPILER) || (__clang__ && __TBB_GCC_VERSION <= 40300)
507 #define __TBB_CPP11_STD_FORWARD_BROKEN 1
508#else
509 #define __TBB_CPP11_STD_FORWARD_BROKEN 0
510#endif
511
512#if __TBB_DEFINE_MIC
513 /** Main thread and user's thread have different default thread affinity masks. **/
514 #define __TBB_MAIN_THREAD_AFFINITY_BROKEN 1
515#endif
516
517#if __GXX_EXPERIMENTAL_CXX0X__ && !defined(__EXCEPTIONS) && \
518 __GNUC__==4 && (__GNUC_MINOR__==4 ||__GNUC_MINOR__==5 || (__INTEL_COMPILER==1300 && (__GNUC_MINOR__==6 ||__GNUC_MINOR__==7)))
519/* There is an issue for specific GCC toolchain when C++11 is enabled
520 and exceptions are disabled:
521 exceprion_ptr.h/nested_exception.h use throw unconditionally.
522 */
523 #define __TBB_LIBSTDCPP_EXCEPTION_HEADERS_BROKEN 1
524#else
525 #define __TBB_LIBSTDCPP_EXCEPTION_HEADERS_BROKEN 0
526#endif
527
528#if __TBB_x86_32 && (__linux__ || __APPLE__ || _WIN32 || __sun) && ((defined(__INTEL_COMPILER) && __INTEL_COMPILER <= 1300) || (__GNUC__==3 && __GNUC_MINOR__==3 ) || defined(__SUNPRO_CC))
529 // Some compilers for IA-32 fail to provide 8-byte alignment of objects on the stack,
530 // even if the object specifies 8-byte alignment. On such platforms, the IA-32 implementation
531 // of 64 bit atomics (e.g. atomic<long long>) use different tactics depending upon
532 // whether the object is properly aligned or not.
533 #define __TBB_FORCE_64BIT_ALIGNMENT_BROKEN 1
534#else
535 #define __TBB_FORCE_64BIT_ALIGNMENT_BROKEN 0
536#endif
537
538#if __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT && __TBB_GCC_VERSION < 40700 && !defined(__INTEL_COMPILER) && !defined (__clang__)
539 #define __TBB_ZERO_INIT_WITH_DEFAULTED_CTOR_BROKEN 1
540#endif
541/** End of __TBB_XXX_BROKEN macro section **/
542
543#define __TBB_ATOMIC_CTORS (__TBB_CONSTEXPR_PRESENT && __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT && (!__TBB_ZERO_INIT_WITH_DEFAULTED_CTOR_BROKEN))
544
545#endif /* __TBB_tbb_config_H */
546