You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

577 lines
26 KiB

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