526 lines
24 KiB

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