2 Copyright 2005-2011 Intel Corporation. All Rights Reserved.
4 This file is part of Threading Building Blocks.
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.
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.
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
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.
29 #ifndef __TBB_tbb_config_H
30 #define __TBB_tbb_config_H
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
37 - known compiler/platform issues
40 #define __TBB_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
42 /** Presence of compiler features **/
44 #if (__TBB_GCC_VERSION >= 40400) && !defined(__INTEL_COMPILER)
45 /** warning suppression pragmas available in GCC since 4.4 **/
46 #define __TBB_GCC_WARNING_SUPPRESSION_PRESENT 1
49 /* TODO: The following condition should be extended when new compilers/runtimes
50 with std::exception_ptr support appear. */
51 #define __TBB_EXCEPTION_PTR_PRESENT ((_MSC_VER >= 1600 || (__GXX_EXPERIMENTAL_CXX0X__ && __GNUC__==4 && __GNUC_MINOR__>=4)) && !__INTEL_COMPILER)
53 #if __GNUC__ || __SUNPRO_CC || __IBMCPP__
54 /* ICC defines __GNUC__ and so is covered */
55 #define __TBB_ATTRIBUTE_ALIGNED_PRESENT 1
56 #elif _MSC_VER && (_MSC_VER >= 1300 || __INTEL_COMPILER)
57 #define __TBB_DECLSPEC_ALIGN_PRESENT 1
60 #if (__TBB_GCC_VERSION >= 40102) && !defined(__INTEL_COMPILER)
61 /** built-in atomics available in GCC since 4.1.2 **/
62 #define __TBB_GCC_BUILTIN_ATOMICS_PRESENT 1
65 /** User controlled TBB features & modes **/
69 #define TBB_USE_DEBUG TBB_DO_ASSERT
72 #define TBB_USE_DEBUG _DEBUG
74 #define TBB_USE_DEBUG 0
76 #endif /* TBB_DO_ASSERT */
77 #endif /* TBB_USE_DEBUG */
79 #ifndef TBB_USE_ASSERT
81 #define TBB_USE_ASSERT TBB_DO_ASSERT
83 #define TBB_USE_ASSERT TBB_USE_DEBUG
84 #endif /* TBB_DO_ASSERT */
85 #endif /* TBB_USE_ASSERT */
87 #ifndef TBB_USE_THREADING_TOOLS
88 #ifdef TBB_DO_THREADING_TOOLS
89 #define TBB_USE_THREADING_TOOLS TBB_DO_THREADING_TOOLS
91 #define TBB_USE_THREADING_TOOLS TBB_USE_DEBUG
92 #endif /* TBB_DO_THREADING_TOOLS */
93 #endif /* TBB_USE_THREADING_TOOLS */
95 #ifndef TBB_USE_PERFORMANCE_WARNINGS
96 #ifdef TBB_PERFORMANCE_WARNINGS
97 #define TBB_USE_PERFORMANCE_WARNINGS TBB_PERFORMANCE_WARNINGS
99 #define TBB_USE_PERFORMANCE_WARNINGS TBB_USE_DEBUG
100 #endif /* TBB_PEFORMANCE_WARNINGS */
101 #endif /* TBB_USE_PERFORMANCE_WARNINGS */
104 #if !defined(__EXCEPTIONS) && !defined(_CPPUNWIND) && !defined(__SUNPRO_CC) || defined(_XBOX)
105 #if TBB_USE_EXCEPTIONS
106 #error Compilation settings do not support exception handling. Please do not set TBB_USE_EXCEPTIONS macro or set it to 0.
107 #elif !defined(TBB_USE_EXCEPTIONS)
108 #define TBB_USE_EXCEPTIONS 0
110 #elif !defined(TBB_USE_EXCEPTIONS)
111 #define TBB_USE_EXCEPTIONS 1
114 #ifndef TBB_IMPLEMENT_CPP0X
115 /** By default, use C++0x classes if available **/
116 #if __GNUC__==4 && __GNUC_MINOR__>=4 && __GXX_EXPERIMENTAL_CXX0X__
117 #define TBB_IMPLEMENT_CPP0X 0
119 #define TBB_IMPLEMENT_CPP0X 1
121 #endif /* TBB_IMPLEMENT_CPP0X */
123 #ifndef TBB_USE_CAPTURED_EXCEPTION
124 #if __TBB_EXCEPTION_PTR_PRESENT
125 #define TBB_USE_CAPTURED_EXCEPTION 0
127 #define TBB_USE_CAPTURED_EXCEPTION 1
129 #else /* defined TBB_USE_CAPTURED_EXCEPTION */
130 #if !TBB_USE_CAPTURED_EXCEPTION && !__TBB_EXCEPTION_PTR_PRESENT
131 #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.
133 #endif /* defined TBB_USE_CAPTURED_EXCEPTION */
135 /** Check whether the request to use GCC atomics can be satisfied **/
136 #if (TBB_USE_GCC_BUILTINS && !__TBB_GCC_BUILTIN_ATOMICS_PRESENT)
137 #error "GCC atomic built-ins are not supported."
140 /** Internal TBB features & modes **/
142 #ifndef __TBB_DYNAMIC_LOAD_ENABLED
143 #define __TBB_DYNAMIC_LOAD_ENABLED !__TBB_TASK_CPP_DIRECTLY_INCLUDED
144 #elif !__TBB_DYNAMIC_LOAD_ENABLED
146 #define __TBB_NO_IMPLICIT_LINKAGE 1
147 #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
149 #define __TBB_WEAK_SYMBOLS 1
153 #ifndef __TBB_COUNT_TASK_NODES
154 #define __TBB_COUNT_TASK_NODES TBB_USE_ASSERT
157 #ifndef __TBB_TASK_GROUP_CONTEXT
158 #define __TBB_TASK_GROUP_CONTEXT 1
159 #endif /* __TBB_TASK_GROUP_CONTEXT */
161 #if TBB_USE_EXCEPTIONS && !__TBB_TASK_GROUP_CONTEXT
162 #error TBB_USE_EXCEPTIONS requires __TBB_TASK_GROUP_CONTEXT to be enabled
165 #ifndef __TBB_SCHEDULER_OBSERVER
166 #define __TBB_SCHEDULER_OBSERVER 1
167 #endif /* __TBB_SCHEDULER_OBSERVER */
169 #ifndef __TBB_TASK_PRIORITY
170 #define __TBB_TASK_PRIORITY __TBB_TASK_GROUP_CONTEXT
171 #endif /* __TBB_TASK_PRIORITY */
173 #if __TBB_TASK_PRIORITY && !__TBB_TASK_GROUP_CONTEXT
174 #error __TBB_TASK_PRIORITY requires __TBB_TASK_GROUP_CONTEXT to be enabled
177 #if !defined(__TBB_SURVIVE_THREAD_SWITCH) && (_WIN32 || _WIN64 || __linux__)
178 #define __TBB_SURVIVE_THREAD_SWITCH 1
179 #endif /* __TBB_SURVIVE_THREAD_SWITCH */
181 #ifndef __TBB_DEFAULT_PARTITIONER
183 /** Default partitioner for parallel loop templates in TBB 1.0-2.1 */
184 #define __TBB_DEFAULT_PARTITIONER tbb::simple_partitioner
186 /** Default partitioner for parallel loop templates since TBB 2.2 */
187 #define __TBB_DEFAULT_PARTITIONER tbb::auto_partitioner
188 #endif /* TBB_DEPRECATED */
189 #endif /* !defined(__TBB_DEFAULT_PARTITIONER */
191 /** Macros of the form __TBB_XXX_BROKEN denote known issues that are caused by
192 the bugs in compilers, standard or OS specific libraries. They should be
193 removed as soon as the corresponding bugs are fixed or the buggy OS/compiler
194 versions go out of the support list.
197 #if __GNUC__ && __TBB_x86_64 && __INTEL_COMPILER == 1200
198 #define __TBB_ICC_12_0_INL_ASM_FSTCW_BROKEN 1
201 #if _MSC_VER && __INTEL_COMPILER && (__INTEL_COMPILER<1110 || __INTEL_COMPILER==1110 && __INTEL_COMPILER_BUILD_DATE < 20091012)
202 /** Necessary to avoid ICL error (or warning in non-strict mode):
203 "exception specification for implicitly declared virtual destructor is
204 incompatible with that of overridden one". **/
205 #define __TBB_DEFAULT_DTOR_THROW_SPEC_BROKEN 1
208 #if defined(_MSC_VER) && _MSC_VER < 1500 && !defined(__INTEL_COMPILER)
209 /** VS2005 and earlier do not allow declaring template class as a friend
210 of classes defined in other namespaces. **/
211 #define __TBB_TEMPLATE_FRIENDS_BROKEN 1
214 #if __GLIBC__==2 && __GLIBC_MINOR__==3 || __MINGW32__ || (__APPLE__ && __INTEL_COMPILER==1200 && !TBB_USE_DEBUG)
215 //! Macro controlling EH usages in TBB tests
216 /** Some older versions of glibc crash when exception handling happens concurrently. **/
217 #define __TBB_THROW_ACROSS_MODULE_BOUNDARY_BROKEN 1
220 #if (_WIN32||_WIN64) && __INTEL_COMPILER == 1110
221 /** 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. **/
222 #define __TBB_ICL_11_1_CODE_GEN_BROKEN 1
225 #if __GNUC__==3 && __GNUC_MINOR__==3 && !defined(__INTEL_COMPILER)
226 /** A bug in GCC 3.3 with access to nested classes declared in protected area */
227 #define __TBB_GCC_3_3_PROTECTED_BROKEN 1
230 #if __MINGW32__ && (__GNUC__<4 || __GNUC__==4 && __GNUC_MINOR__<2)
231 /** MinGW has a bug with stack alignment for routines invoked from MS RTLs.
232 Since GCC 4.2, the bug can be worked around via a special attribute. **/
233 #define __TBB_SSE_STACK_ALIGNMENT_BROKEN 1
236 #if __GNUC__==4 && __GNUC_MINOR__==3 && __GNUC_PATCHLEVEL__==0
237 // GCC of this version may rashly ignore control dependencies
238 #define __TBB_GCC_OPTIMIZER_ORDERING_BROKEN 1
242 /** A bug in FreeBSD 8.0 results in kernel panic when there is contention
243 on a mutex created with this attribute. **/
244 #define __TBB_PRIO_INHERIT_BROKEN 1
246 /** A bug in FreeBSD 8.0 results in test hanging when an exception occurs
247 during (concurrent?) object construction by means of placement new operator. **/
248 #define __TBB_PLACEMENT_NEW_EXCEPTION_SAFETY_BROKEN 1
249 #endif /* __FreeBSD__ */
251 #if (__linux__ || __APPLE__) && __i386__ && defined(__INTEL_COMPILER)
252 /** The Intel compiler for IA-32 (Linux|Mac OS X) crashes or generates
253 incorrect code when __asm__ arguments have a cast to volatile. **/
254 #define __TBB_ICC_ASM_VOLATILE_BROKEN 1
257 #if !__INTEL_COMPILER && (_MSC_VER || __GNUC__==3 && __GNUC_MINOR__<=2)
258 /** Bug in GCC 3.2 and MSVC compilers that sometimes return 0 for __alignof(T)
259 when T has not yet been instantiated. **/
260 #define __TBB_ALIGNOF_NOT_INSTANTIATED_TYPES_BROKEN 1
263 #endif /* __TBB_tbb_config_H */