]> git.sesse.net Git - casparcg/blob - tbb/include/tbb/tbb_config.h
8b86b89e52933bcd58dd9c3e7be6a8d2aa9eb8cf
[casparcg] / tbb / include / tbb / tbb_config.h
1 /*
2     Copyright 2005-2011 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 #define __TBB_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
41
42 /** Presence of compiler features **/
43
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
47 #endif
48
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)
52
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
58 #endif
59
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
63 #endif
64
65 /** User controlled TBB features & modes **/
66
67 #ifndef TBB_USE_DEBUG
68 #ifdef TBB_DO_ASSERT
69 #define TBB_USE_DEBUG TBB_DO_ASSERT
70 #else
71 #ifdef _DEBUG
72 #define TBB_USE_DEBUG _DEBUG
73 #else
74 #define TBB_USE_DEBUG 0
75 #endif
76 #endif /* TBB_DO_ASSERT */
77 #endif /* TBB_USE_DEBUG */
78
79 #ifndef TBB_USE_ASSERT
80 #ifdef TBB_DO_ASSERT
81 #define TBB_USE_ASSERT TBB_DO_ASSERT
82 #else 
83 #define TBB_USE_ASSERT TBB_USE_DEBUG
84 #endif /* TBB_DO_ASSERT */
85 #endif /* TBB_USE_ASSERT */
86
87 #ifndef TBB_USE_THREADING_TOOLS
88 #ifdef TBB_DO_THREADING_TOOLS
89 #define TBB_USE_THREADING_TOOLS TBB_DO_THREADING_TOOLS
90 #else 
91 #define TBB_USE_THREADING_TOOLS TBB_USE_DEBUG
92 #endif /* TBB_DO_THREADING_TOOLS */
93 #endif /* TBB_USE_THREADING_TOOLS */
94
95 #ifndef TBB_USE_PERFORMANCE_WARNINGS
96 #ifdef TBB_PERFORMANCE_WARNINGS
97 #define TBB_USE_PERFORMANCE_WARNINGS TBB_PERFORMANCE_WARNINGS
98 #else 
99 #define TBB_USE_PERFORMANCE_WARNINGS TBB_USE_DEBUG
100 #endif /* TBB_PEFORMANCE_WARNINGS */
101 #endif /* TBB_USE_PERFORMANCE_WARNINGS */
102
103 #if !defined(__EXCEPTIONS) && !defined(_CPPUNWIND) && !defined(__SUNPRO_CC) || defined(_XBOX)
104     #if TBB_USE_EXCEPTIONS
105         #error Compilation settings do not support exception handling. Please do not set TBB_USE_EXCEPTIONS macro or set it to 0.
106     #elif !defined(TBB_USE_EXCEPTIONS)
107         #define TBB_USE_EXCEPTIONS 0
108     #endif
109 #elif !defined(TBB_USE_EXCEPTIONS)
110     #define TBB_USE_EXCEPTIONS 1
111 #endif
112
113 #ifndef TBB_IMPLEMENT_CPP0X
114     /** By default, use C++0x classes if available **/
115     #if __GNUC__==4 && __GNUC_MINOR__>=4 && __GXX_EXPERIMENTAL_CXX0X__
116         #define TBB_IMPLEMENT_CPP0X 0
117     #else
118         #define TBB_IMPLEMENT_CPP0X 1
119     #endif
120 #endif /* TBB_IMPLEMENT_CPP0X */
121
122 #ifndef TBB_USE_CAPTURED_EXCEPTION
123     #if __TBB_EXCEPTION_PTR_PRESENT
124         #define TBB_USE_CAPTURED_EXCEPTION 0
125     #else
126         #define TBB_USE_CAPTURED_EXCEPTION 1
127     #endif
128 #else /* defined TBB_USE_CAPTURED_EXCEPTION */
129     #if !TBB_USE_CAPTURED_EXCEPTION && !__TBB_EXCEPTION_PTR_PRESENT
130         #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.
131     #endif
132 #endif /* defined TBB_USE_CAPTURED_EXCEPTION */
133
134 /** Check whether the request to use GCC atomics can be satisfied **/
135 #if (TBB_USE_GCC_BUILTINS && !__TBB_GCC_BUILTIN_ATOMICS_PRESENT)
136     #error "GCC atomic built-ins are not supported."
137 #endif
138
139 /** Internal TBB features & modes **/
140
141 #ifndef __TBB_DYNAMIC_LOAD_ENABLED
142     #define __TBB_DYNAMIC_LOAD_ENABLED !__TBB_TASK_CPP_DIRECTLY_INCLUDED
143 #elif !__TBB_DYNAMIC_LOAD_ENABLED
144     #if _WIN32||_WIN64
145         #define __TBB_NO_IMPLICIT_LINKAGE 1
146         #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
147     #else
148         #define __TBB_WEAK_SYMBOLS 1
149     #endif
150 #endif
151
152 #ifndef __TBB_COUNT_TASK_NODES
153     #define __TBB_COUNT_TASK_NODES TBB_USE_ASSERT
154 #endif
155
156 #ifndef __TBB_TASK_GROUP_CONTEXT
157     #define __TBB_TASK_GROUP_CONTEXT 1
158 #endif /* __TBB_TASK_GROUP_CONTEXT */
159
160 #if TBB_USE_EXCEPTIONS && !__TBB_TASK_GROUP_CONTEXT
161     #error TBB_USE_EXCEPTIONS requires __TBB_TASK_GROUP_CONTEXT to be enabled
162 #endif
163
164 #ifndef __TBB_SCHEDULER_OBSERVER
165     #define __TBB_SCHEDULER_OBSERVER 1
166 #endif /* __TBB_SCHEDULER_OBSERVER */
167
168 #ifndef __TBB_TASK_PRIORITY
169     #define __TBB_TASK_PRIORITY __TBB_TASK_GROUP_CONTEXT
170 #endif /* __TBB_TASK_PRIORITY */
171
172 #if __TBB_TASK_PRIORITY && !__TBB_TASK_GROUP_CONTEXT
173     #error __TBB_TASK_PRIORITY requires __TBB_TASK_GROUP_CONTEXT to be enabled
174 #endif
175
176 #if !defined(__TBB_SURVIVE_THREAD_SWITCH) && (_WIN32 || _WIN64 || __linux__)
177     #define __TBB_SURVIVE_THREAD_SWITCH 1
178 #endif /* __TBB_SURVIVE_THREAD_SWITCH */
179
180 #ifndef __TBB_DEFAULT_PARTITIONER
181 #if TBB_DEPRECATED
182 /** Default partitioner for parallel loop templates in TBB 1.0-2.1 */
183 #define __TBB_DEFAULT_PARTITIONER tbb::simple_partitioner
184 #else
185 /** Default partitioner for parallel loop templates since TBB 2.2 */
186 #define __TBB_DEFAULT_PARTITIONER tbb::auto_partitioner
187 #endif /* TBB_DEPRECATED */
188 #endif /* !defined(__TBB_DEFAULT_PARTITIONER */
189
190 /** Macros of the form __TBB_XXX_BROKEN denote known issues that are caused by
191     the bugs in compilers, standard or OS specific libraries. They should be 
192     removed as soon as the corresponding bugs are fixed or the buggy OS/compiler
193     versions go out of the support list. 
194 **/
195
196 #if __GNUC__ && __TBB_x86_64 && __INTEL_COMPILER == 1200
197     #define __TBB_ICC_12_0_INL_ASM_FSTCW_BROKEN 1
198 #endif
199
200 #if _MSC_VER && __INTEL_COMPILER && (__INTEL_COMPILER<1110 || __INTEL_COMPILER==1110 && __INTEL_COMPILER_BUILD_DATE < 20091012)
201     /** Necessary to avoid ICL error (or warning in non-strict mode): 
202         "exception specification for implicitly declared virtual destructor is 
203         incompatible with that of overridden one". **/
204     #define __TBB_DEFAULT_DTOR_THROW_SPEC_BROKEN 1
205 #endif
206
207 #if defined(_MSC_VER) && _MSC_VER < 1500 && !defined(__INTEL_COMPILER)
208     /** VS2005 and earlier do not allow declaring template class as a friend 
209         of classes defined in other namespaces. **/
210     #define __TBB_TEMPLATE_FRIENDS_BROKEN 1
211 #endif
212
213 #if __GLIBC__==2 && __GLIBC_MINOR__==3 || __MINGW32__ || (__APPLE__ && __INTEL_COMPILER==1200 && !TBB_USE_DEBUG)
214     //! Macro controlling EH usages in TBB tests
215     /** Some older versions of glibc crash when exception handling happens concurrently. **/
216     #define __TBB_THROW_ACROSS_MODULE_BOUNDARY_BROKEN 1
217 #endif
218
219 #if (_WIN32||_WIN64) && __INTEL_COMPILER == 1110
220     /** 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. **/
221     #define __TBB_ICL_11_1_CODE_GEN_BROKEN 1
222 #endif
223
224 #if __GNUC__==3 && __GNUC_MINOR__==3 && !defined(__INTEL_COMPILER)
225     /** A bug in GCC 3.3 with access to nested classes declared in protected area */
226     #define __TBB_GCC_3_3_PROTECTED_BROKEN 1
227 #endif
228
229 #if __MINGW32__ && (__GNUC__<4 || __GNUC__==4 && __GNUC_MINOR__<2)
230     /** MinGW has a bug with stack alignment for routines invoked from MS RTLs.
231         Since GCC 4.2, the bug can be worked around via a special attribute. **/
232     #define __TBB_SSE_STACK_ALIGNMENT_BROKEN 1
233 #endif
234
235 #if __GNUC__==4 && __GNUC_MINOR__==3 && __GNUC_PATCHLEVEL__==0
236     // GCC of this version may rashly ignore control dependencies
237     #define __TBB_GCC_OPTIMIZER_ORDERING_BROKEN 1
238 #endif
239
240 #if __FreeBSD__
241     /** A bug in FreeBSD 8.0 results in kernel panic when there is contention 
242         on a mutex created with this attribute. **/
243     #define __TBB_PRIO_INHERIT_BROKEN 1
244
245     /** A bug in FreeBSD 8.0 results in test hanging when an exception occurs 
246         during (concurrent?) object construction by means of placement new operator. **/
247     #define __TBB_PLACEMENT_NEW_EXCEPTION_SAFETY_BROKEN 1
248 #endif /* __FreeBSD__ */
249
250 #if (__linux__ || __APPLE__) && __i386__ && defined(__INTEL_COMPILER)
251     /** The Intel compiler for IA-32 (Linux|Mac OS X) crashes or generates 
252         incorrect code when __asm__ arguments have a cast to volatile. **/
253     #define __TBB_ICC_ASM_VOLATILE_BROKEN 1
254 #endif
255
256 #if !__INTEL_COMPILER && (_MSC_VER || __GNUC__==3 && __GNUC_MINOR__<=2)
257     /** Bug in GCC 3.2 and MSVC compilers that sometimes return 0 for __alignof(T) 
258         when T has not yet been instantiated. **/
259     #define __TBB_ALIGNOF_NOT_INSTANTIATED_TYPES_BROKEN 1
260 #endif
261
262 #endif /* __TBB_tbb_config_H */