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
36 - workarounds presence
39 /** Compilation modes **/
43 #define TBB_USE_DEBUG TBB_DO_ASSERT
45 #define TBB_USE_DEBUG 0
46 #endif /* TBB_DO_ASSERT */
48 #define TBB_DO_ASSERT TBB_USE_DEBUG
49 #endif /* TBB_USE_DEBUG */
51 #ifndef TBB_USE_ASSERT
53 #define TBB_USE_ASSERT TBB_DO_ASSERT
55 #define TBB_USE_ASSERT TBB_USE_DEBUG
56 #endif /* TBB_DO_ASSERT */
57 #endif /* TBB_USE_ASSERT */
59 #ifndef TBB_USE_THREADING_TOOLS
60 #ifdef TBB_DO_THREADING_TOOLS
61 #define TBB_USE_THREADING_TOOLS TBB_DO_THREADING_TOOLS
63 #define TBB_USE_THREADING_TOOLS TBB_USE_DEBUG
64 #endif /* TBB_DO_THREADING_TOOLS */
65 #endif /* TBB_USE_THREADING_TOOLS */
67 #ifndef TBB_USE_PERFORMANCE_WARNINGS
68 #ifdef TBB_PERFORMANCE_WARNINGS
69 #define TBB_USE_PERFORMANCE_WARNINGS TBB_PERFORMANCE_WARNINGS
71 #define TBB_USE_PERFORMANCE_WARNINGS TBB_USE_DEBUG
72 #endif /* TBB_PEFORMANCE_WARNINGS */
73 #endif /* TBB_USE_PERFORMANCE_WARNINGS */
75 #if !defined(__EXCEPTIONS) && !defined(_CPPUNWIND) && !defined(__SUNPRO_CC) || defined(_XBOX)
76 #if TBB_USE_EXCEPTIONS
77 #error Compilation settings do not support exception handling. Please do not set TBB_USE_EXCEPTIONS macro or set it to 0.
78 #elif !defined(TBB_USE_EXCEPTIONS)
79 #define TBB_USE_EXCEPTIONS 0
81 #elif !defined(TBB_USE_EXCEPTIONS)
82 #define TBB_USE_EXCEPTIONS 1
85 #ifndef TBB_IMPLEMENT_CPP0X
86 /** By default, use C++0x classes if available **/
87 #if __GNUC__==4 && __GNUC_MINOR__>=4 && __GXX_EXPERIMENTAL_CXX0X__
88 #define TBB_IMPLEMENT_CPP0X 0
90 #define TBB_IMPLEMENT_CPP0X 1
92 #endif /* TBB_IMPLEMENT_CPP0X */
94 #ifndef __TBB_DYNAMIC_LOAD_ENABLED
95 #define __TBB_DYNAMIC_LOAD_ENABLED !__TBB_TASK_CPP_DIRECTLY_INCLUDED
96 #elif !__TBB_DYNAMIC_LOAD_ENABLED
98 #define __TBB_NO_IMPLICIT_LINKAGE 1
99 #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
101 #define __TBB_WEAK_SYMBOLS 1
107 #ifndef __TBB_COUNT_TASK_NODES
108 #define __TBB_COUNT_TASK_NODES TBB_USE_ASSERT
111 #ifndef __TBB_TASK_GROUP_CONTEXT
112 #define __TBB_TASK_GROUP_CONTEXT 1
113 #endif /* __TBB_TASK_GROUP_CONTEXT */
115 #ifndef __TBB_SCHEDULER_OBSERVER
116 #define __TBB_SCHEDULER_OBSERVER 1
117 #endif /* __TBB_SCHEDULER_OBSERVER */
119 #ifndef __TBB_TASK_PRIORITY
120 #define __TBB_TASK_PRIORITY __TBB_CPF_BUILD
121 #endif /* __TBB_TASK_PRIORITY */
123 #if __TBB_TASK_PRIORITY && !__TBB_TASK_GROUP_CONTEXT
124 #error __TBB_TASK_PRIORITY requires __TBB_TASK_GROUP_CONTEXT to be enabled
127 #ifdef TBB_PREVIEW_TASK_PRIORITY
128 #if TBB_PREVIEW_TASK_PRIORITY
129 #define __TBB_NO_IMPLICIT_LINKAGE 1
130 #if __TBB_BUILD && !__TBB_TASK_PRIORITY
131 #error TBB_PREVIEW_TASK_PRIORITY requires __TBB_TASK_PRIORITY to be enabled during TBB build
132 #elif !__TBB_TASK_GROUP_CONTEXT
133 #error TBB_PREVIEW_TASK_PRIORITY requires __TBB_TASK_GROUP_CONTEXT to be enabled
138 #define TBB_PREVIEW_TASK_PRIORITY __TBB_TASK_PRIORITY
140 #endif /* TBB_PREVIEW_TASK_PRIORITY */
142 #if !defined(__TBB_SURVIVE_THREAD_SWITCH) && (_WIN32 || _WIN64 || __linux__)
143 #define __TBB_SURVIVE_THREAD_SWITCH 1
144 #endif /* __TBB_SURVIVE_THREAD_SWITCH */
147 /* TODO: The following condition should be extended as soon as new compilers/runtimes
148 with std::exception_ptr support appear. */
149 #define __TBB_EXCEPTION_PTR_PRESENT (_MSC_VER >= 1600 || __GXX_EXPERIMENTAL_CXX0X__ && (__GNUC__==4 && __GNUC_MINOR__>=4))
152 #ifndef TBB_USE_CAPTURED_EXCEPTION
153 #if __TBB_EXCEPTION_PTR_PRESENT
154 #define TBB_USE_CAPTURED_EXCEPTION 0
156 #define TBB_USE_CAPTURED_EXCEPTION 1
158 #else /* defined TBB_USE_CAPTURED_EXCEPTION */
159 #if !TBB_USE_CAPTURED_EXCEPTION && !__TBB_EXCEPTION_PTR_PRESENT
160 #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.
162 #endif /* defined TBB_USE_CAPTURED_EXCEPTION */
165 #ifndef __TBB_DEFAULT_PARTITIONER
167 /** Default partitioner for parallel loop templates in TBB 1.0-2.1 */
168 #define __TBB_DEFAULT_PARTITIONER tbb::simple_partitioner
170 /** Default partitioner for parallel loop templates in TBB 2.2 */
171 #define __TBB_DEFAULT_PARTITIONER tbb::auto_partitioner
172 #endif /* TBB_DEFAULT_PARTITIONER */
173 #endif /* !defined(__TBB_DEFAULT_PARTITIONER */
175 /** Workarounds presence **/
177 #if __GNUC__==4 && __GNUC_MINOR__>=4 && !defined(__INTEL_COMPILER)
178 #define __TBB_GCC_WARNING_SUPPRESSION_ENABLED 1
181 /** Macros of the form __TBB_XXX_BROKEN denote known issues that are caused by
182 the bugs in compilers, standard or OS specific libraries. They should be
183 removed as soon as the corresponding bugs are fixed or the buggy OS/compiler
184 versions go out of the support list.
187 #if _MSC_VER && __INTEL_COMPILER && (__INTEL_COMPILER<1110 || __INTEL_COMPILER==1110 && __INTEL_COMPILER_BUILD_DATE < 20091012)
188 /** Necessary to avoid ICL error (or warning in non-strict mode):
189 "exception specification for implicitly declared virtual destructor is
190 incompatible with that of overridden one". **/
191 #define __TBB_DEFAULT_DTOR_THROW_SPEC_BROKEN 1
194 #if defined(_MSC_VER) && _MSC_VER < 1500 && !defined(__INTEL_COMPILER)
195 /** VS2005 and earlier do not allow declaring template class as a friend
196 of classes defined in other namespaces. **/
197 #define __TBB_TEMPLATE_FRIENDS_BROKEN 1
200 #if __GLIBC__==2 && __GLIBC_MINOR__==3 || __MINGW32__
201 //! Macro controlling EH usages in TBB tests
202 /** Some older versions of glibc crash when exception handling happens concurrently. **/
203 #define __TBB_THROW_ACROSS_MODULE_BOUNDARY_BROKEN 1
206 #if (_WIN32||_WIN64) && __INTEL_COMPILER == 1110
207 /** 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. **/
208 #define __TBB_ICL_11_1_CODE_GEN_BROKEN 1
211 #if __GNUC__==3 && __GNUC_MINOR__==3 && !defined(__INTEL_COMPILER)
212 /** A bug in GCC 3.3 with access to nested classes declared in protected area */
213 #define __TBB_GCC_3_3_PROTECTED_BROKEN 1
216 #if __MINGW32__ && (__GNUC__<4 || __GNUC__==4 && __GNUC_MINOR__<2)
217 /** MinGW has a bug with stack alignment for routines invoked from MS RTLs.
218 Since GCC 4.2, the bug can be worked around via a special attribute. **/
219 #define __TBB_SSE_STACK_ALIGNMENT_BROKEN 1
222 #if __GNUC__==4 && __GNUC_MINOR__==3 && __GNUC_PATCHLEVEL__==0
223 // GCC of this version may rashly ignore control dependencies
224 #define __TBB_GCC_OPTIMIZER_ORDERING_BROKEN 1
228 /** A bug in FreeBSD 8.0 results in kernel panic when there is contention
229 on a mutex created with this attribute. **/
230 #define __TBB_PRIO_INHERIT_BROKEN 1
232 /** A bug in FreeBSD 8.0 results in test hanging when an exception occurs
233 during (concurrent?) object construction by means of placement new operator. **/
234 #define __TBB_PLACEMENT_NEW_EXCEPTION_SAFETY_BROKEN 1
235 #endif /* __FreeBSD__ */
237 #if (__linux__ || __APPLE__) && __i386__ && defined(__INTEL_COMPILER)
238 /** The Intel compiler for IA-32 (Linux|Mac OS X) crashes or generates
239 incorrect code when __asm__ arguments have a cast to volatile. **/
240 #define __TBB_ICC_ASM_VOLATILE_BROKEN 1
243 #define __TBB_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
245 /* #if more recent gcc than 4.1.2 */
246 #if (__TBB_GCC_VERSION > 40102 ) && !defined(__INTEL_COMPILER)
247 #define __TBB_GCC_BUILTIN_ATOMICS_PRESENT 1
250 #if (TBB_USE_GCC_BUILTINS && !__TBB_GCC_BUILTIN_ATOMICS_PRESENT)
251 #error "generic gcc port is not supported for this os/architecture."
253 #endif /* __TBB_tbb_config_H */