tbb_config.h 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. /*
  2. Copyright (c) 2005-2020 Intel Corporation
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #ifndef __TBB_tbb_config_H
  14. #define __TBB_tbb_config_H
  15. /** This header is supposed to contain macro definitions and C style comments only.
  16. The macros defined here are intended to control such aspects of TBB build as
  17. - presence of compiler features
  18. - compilation modes
  19. - feature sets
  20. - known compiler/platform issues
  21. **/
  22. /* This macro marks incomplete code or comments describing ideas which are considered for the future.
  23. * See also for plain comment with TODO and FIXME marks for small improvement opportunities.
  24. */
  25. #define __TBB_TODO 0
  26. /* Check which standard library we use. */
  27. /* __TBB_SYMBOL is defined only while processing exported symbols list where C++ is not allowed. */
  28. #if !defined(__TBB_SYMBOL) && !__TBB_CONFIG_PREPROC_ONLY
  29. #include <cstddef>
  30. #endif
  31. // Note that when ICC or Clang is in use, __TBB_GCC_VERSION might not fully match
  32. // the actual GCC version on the system.
  33. #define __TBB_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
  34. // Prior to GCC 7, GNU libstdc++ did not have a convenient version macro.
  35. // Therefore we use different ways to detect its version.
  36. #if defined(TBB_USE_GLIBCXX_VERSION) && !defined(_GLIBCXX_RELEASE)
  37. // The version is explicitly specified in our public TBB_USE_GLIBCXX_VERSION macro.
  38. // Its format should match the __TBB_GCC_VERSION above, e.g. 70301 for libstdc++ coming with GCC 7.3.1.
  39. #define __TBB_GLIBCXX_VERSION TBB_USE_GLIBCXX_VERSION
  40. #elif _GLIBCXX_RELEASE && _GLIBCXX_RELEASE != __GNUC__
  41. // Reported versions of GCC and libstdc++ do not match; trust the latter
  42. #define __TBB_GLIBCXX_VERSION (_GLIBCXX_RELEASE*10000)
  43. #elif __GLIBCPP__ || __GLIBCXX__
  44. // The version macro is not defined or matches the GCC version; use __TBB_GCC_VERSION
  45. #define __TBB_GLIBCXX_VERSION __TBB_GCC_VERSION
  46. #endif
  47. #if __clang__
  48. // according to clang documentation, version can be vendor specific
  49. #define __TBB_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
  50. #endif
  51. /** Target OS is either iOS* or iOS* simulator **/
  52. #if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
  53. #define __TBB_IOS 1
  54. #endif
  55. #if __APPLE__
  56. #if __INTEL_COMPILER && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1099 \
  57. && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101000
  58. // ICC does not correctly set the macro if -mmacosx-min-version is not specified
  59. #define __TBB_MACOS_TARGET_VERSION (100000 + 10*(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 1000))
  60. #else
  61. #define __TBB_MACOS_TARGET_VERSION __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
  62. #endif
  63. #endif
  64. /** Preprocessor symbols to determine HW architecture **/
  65. #if _WIN32||_WIN64
  66. # if defined(_M_X64)||defined(__x86_64__) // the latter for MinGW support
  67. # define __TBB_x86_64 1
  68. # elif defined(_M_IA64)
  69. # define __TBB_ipf 1
  70. # elif defined(_M_IX86)||defined(__i386__) // the latter for MinGW support
  71. # define __TBB_x86_32 1
  72. # else
  73. # define __TBB_generic_arch 1
  74. # endif
  75. #else /* Assume generic Unix */
  76. # if !__linux__ && !__APPLE__
  77. # define __TBB_generic_os 1
  78. # endif
  79. # if __TBB_IOS
  80. # define __TBB_generic_arch 1
  81. # elif __x86_64__
  82. # define __TBB_x86_64 1
  83. # elif __ia64__
  84. # define __TBB_ipf 1
  85. # elif __i386__||__i386 // __i386 is for Sun OS
  86. # define __TBB_x86_32 1
  87. # else
  88. # define __TBB_generic_arch 1
  89. # endif
  90. #endif
  91. #if __MIC__ || __MIC2__
  92. #define __TBB_DEFINE_MIC 1
  93. #endif
  94. #define __TBB_TSX_AVAILABLE ((__TBB_x86_32 || __TBB_x86_64) && !__TBB_DEFINE_MIC)
  95. /** Presence of compiler features **/
  96. #if __INTEL_COMPILER == 9999 && __INTEL_COMPILER_BUILD_DATE == 20110811
  97. /* Intel(R) Composer XE 2011 Update 6 incorrectly sets __INTEL_COMPILER. Fix it. */
  98. #undef __INTEL_COMPILER
  99. #define __INTEL_COMPILER 1210
  100. #endif
  101. #if __clang__ && !__INTEL_COMPILER
  102. #define __TBB_USE_OPTIONAL_RTTI __has_feature(cxx_rtti)
  103. #elif defined(_CPPRTTI)
  104. #define __TBB_USE_OPTIONAL_RTTI 1
  105. #else
  106. #define __TBB_USE_OPTIONAL_RTTI (__GXX_RTTI || __RTTI || __INTEL_RTTI__)
  107. #endif
  108. #if __TBB_GCC_VERSION >= 40400 && !defined(__INTEL_COMPILER)
  109. /** warning suppression pragmas available in GCC since 4.4 **/
  110. #define __TBB_GCC_WARNING_SUPPRESSION_PRESENT 1
  111. #endif
  112. /* Select particular features of C++11 based on compiler version.
  113. ICC 12.1 (Linux*), GCC 4.3 and higher, clang 2.9 and higher
  114. set __GXX_EXPERIMENTAL_CXX0X__ in c++11 mode.
  115. Compilers that mimics other compilers (ICC, clang) must be processed before
  116. compilers they mimic (GCC, MSVC).
  117. TODO: The following conditions should be extended when new compilers/runtimes
  118. support added.
  119. */
  120. /**
  121. __TBB_CPP11_PRESENT macro indicates that the compiler supports vast majority of C++11 features.
  122. Depending on the compiler, some features might still be unsupported or work incorrectly.
  123. Use it when enabling C++11 features individually is not practical, and be aware that
  124. some "good enough" compilers might be excluded. **/
  125. #define __TBB_CPP11_PRESENT (__cplusplus >= 201103L || _MSC_VER >= 1900)
  126. #define __TBB_CPP17_FALLTHROUGH_PRESENT (__cplusplus >= 201703L)
  127. #define __TBB_FALLTHROUGH_PRESENT (__TBB_GCC_VERSION >= 70000 && !__INTEL_COMPILER)
  128. /** C++11 mode detection macros for Intel(R) C++ Compiler (enabled by -std=c++XY option):
  129. __INTEL_CXX11_MODE__ for version >=13.0 (not available for ICC 15.0 if -std=c++14 is used),
  130. __STDC_HOSTED__ for version >=12.0 (useful only on Windows),
  131. __GXX_EXPERIMENTAL_CXX0X__ for version >=12.0 on Linux and macOS. **/
  132. #if __INTEL_COMPILER && !__INTEL_CXX11_MODE__
  133. // __INTEL_CXX11_MODE__ is not set, try to deduce it
  134. #define __INTEL_CXX11_MODE__ (__GXX_EXPERIMENTAL_CXX0X__ || (_MSC_VER && __STDC_HOSTED__))
  135. #endif
  136. #if __INTEL_COMPILER && (!_MSC_VER || __INTEL_CXX11_MODE__)
  137. // On Windows, C++11 features supported by Visual Studio 2010 and higher are enabled by default,
  138. // so in absence of /Qstd= use MSVC branch for feature detection.
  139. // On other platforms, no -std= means C++03.
  140. #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT (__INTEL_CXX11_MODE__ && __VARIADIC_TEMPLATES)
  141. // Both r-value reference support in compiler and std::move/std::forward
  142. // presence in C++ standard library is checked.
  143. #define __TBB_CPP11_RVALUE_REF_PRESENT ((_MSC_VER >= 1700 || __GXX_EXPERIMENTAL_CXX0X__ && (__TBB_GLIBCXX_VERSION >= 40500 || _LIBCPP_VERSION)) && __INTEL_COMPILER >= 1400)
  144. #define __TBB_IMPLICIT_MOVE_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1400 && (_MSC_VER >= 1900 || __TBB_GCC_VERSION >= 40600 || __clang__))
  145. #if _MSC_VER >= 1600
  146. #define __TBB_EXCEPTION_PTR_PRESENT ( __INTEL_COMPILER > 1300 \
  147. /*ICC 12.1 Upd 10 and 13 beta Upd 2 fixed exception_ptr linking issue*/ \
  148. || (__INTEL_COMPILER == 1300 && __INTEL_COMPILER_BUILD_DATE >= 20120530) \
  149. || (__INTEL_COMPILER == 1210 && __INTEL_COMPILER_BUILD_DATE >= 20120410) )
  150. /** libstdc++ that comes with GCC 4.6 use C++11 features not supported by ICC 12.1.
  151. * Because of that ICC 12.1 does not support C++11 mode with gcc 4.6 (or higher),
  152. * and therefore does not define __GXX_EXPERIMENTAL_CXX0X__ macro **/
  153. #elif __TBB_GLIBCXX_VERSION >= 40404 && __TBB_GLIBCXX_VERSION < 40600
  154. #define __TBB_EXCEPTION_PTR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1200)
  155. #elif __TBB_GLIBCXX_VERSION >= 40600
  156. #define __TBB_EXCEPTION_PTR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1300)
  157. #elif _LIBCPP_VERSION
  158. #define __TBB_EXCEPTION_PTR_PRESENT __GXX_EXPERIMENTAL_CXX0X__
  159. #else
  160. #define __TBB_EXCEPTION_PTR_PRESENT 0
  161. #endif
  162. #define __TBB_STATIC_ASSERT_PRESENT (__INTEL_CXX11_MODE__ || _MSC_VER >= 1600)
  163. #define __TBB_CPP11_TUPLE_PRESENT (_MSC_VER >= 1600 || __GXX_EXPERIMENTAL_CXX0X__ && (__TBB_GLIBCXX_VERSION >= 40300 || _LIBCPP_VERSION))
  164. #define __TBB_INITIALIZER_LISTS_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1400 && (_MSC_VER >= 1800 || __TBB_GLIBCXX_VERSION >= 40400 || _LIBCPP_VERSION))
  165. #define __TBB_CONSTEXPR_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1400)
  166. #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1200)
  167. /** ICC seems to disable support of noexcept event in c++11 when compiling in compatibility mode for gcc <4.6 **/
  168. #define __TBB_NOEXCEPT_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1300 && (__TBB_GLIBCXX_VERSION >= 40600 || _LIBCPP_VERSION || _MSC_VER))
  169. #define __TBB_CPP11_STD_BEGIN_END_PRESENT (_MSC_VER >= 1700 || __GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1310 && (__TBB_GLIBCXX_VERSION >= 40600 || _LIBCPP_VERSION))
  170. #define __TBB_CPP11_AUTO_PRESENT (_MSC_VER >= 1600 || __GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1210)
  171. #define __TBB_CPP11_DECLTYPE_PRESENT (_MSC_VER >= 1600 || __GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1210)
  172. #define __TBB_CPP11_LAMBDAS_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1200)
  173. #define __TBB_CPP11_DEFAULT_FUNC_TEMPLATE_ARGS_PRESENT (_MSC_VER >= 1800 || __GXX_EXPERIMENTAL_CXX0X__ && __INTEL_COMPILER >= 1210)
  174. #define __TBB_OVERRIDE_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1400)
  175. #define __TBB_ALIGNAS_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1500)
  176. #define __TBB_CPP11_TEMPLATE_ALIASES_PRESENT (__INTEL_CXX11_MODE__ && __INTEL_COMPILER >= 1210)
  177. #define __TBB_CPP14_INTEGER_SEQUENCE_PRESENT (__cplusplus >= 201402L)
  178. #define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__cplusplus >= 201402L)
  179. #define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__INTEL_COMPILER > 1910) // a future version
  180. #define __TBB_CPP17_INVOKE_RESULT_PRESENT (__cplusplus >= 201703L)
  181. #elif __clang__
  182. /** TODO: these options need to be rechecked **/
  183. #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT __has_feature(__cxx_variadic_templates__)
  184. #define __TBB_CPP11_RVALUE_REF_PRESENT (__has_feature(__cxx_rvalue_references__) && (_LIBCPP_VERSION || __TBB_GLIBCXX_VERSION >= 40500))
  185. #define __TBB_IMPLICIT_MOVE_PRESENT __has_feature(cxx_implicit_moves)
  186. /** TODO: extend exception_ptr related conditions to cover libstdc++ **/
  187. #define __TBB_EXCEPTION_PTR_PRESENT (__cplusplus >= 201103L && (_LIBCPP_VERSION || __TBB_GLIBCXX_VERSION >= 40600))
  188. #define __TBB_STATIC_ASSERT_PRESENT __has_feature(__cxx_static_assert__)
  189. #if (__cplusplus >= 201103L && __has_include(<tuple>))
  190. #define __TBB_CPP11_TUPLE_PRESENT 1
  191. #endif
  192. #if (__has_feature(__cxx_generalized_initializers__) && __has_include(<initializer_list>))
  193. #define __TBB_INITIALIZER_LISTS_PRESENT 1
  194. #endif
  195. #define __TBB_CONSTEXPR_PRESENT __has_feature(__cxx_constexpr__)
  196. #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT (__has_feature(__cxx_defaulted_functions__) && __has_feature(__cxx_deleted_functions__))
  197. /**For some unknown reason __has_feature(__cxx_noexcept) does not yield true for all cases. Compiler bug ? **/
  198. #define __TBB_NOEXCEPT_PRESENT (__cplusplus >= 201103L)
  199. #define __TBB_CPP11_STD_BEGIN_END_PRESENT (__has_feature(__cxx_range_for__) && (_LIBCPP_VERSION || __TBB_GLIBCXX_VERSION >= 40600))
  200. #define __TBB_CPP11_AUTO_PRESENT __has_feature(__cxx_auto_type__)
  201. #define __TBB_CPP11_DECLTYPE_PRESENT __has_feature(__cxx_decltype__)
  202. #define __TBB_CPP11_LAMBDAS_PRESENT __has_feature(cxx_lambdas)
  203. #define __TBB_CPP11_DEFAULT_FUNC_TEMPLATE_ARGS_PRESENT __has_feature(cxx_default_function_template_args)
  204. #define __TBB_OVERRIDE_PRESENT __has_feature(cxx_override_control)
  205. #define __TBB_ALIGNAS_PRESENT __has_feature(cxx_alignas)
  206. #define __TBB_CPP11_TEMPLATE_ALIASES_PRESENT __has_feature(cxx_alias_templates)
  207. #define __TBB_CPP14_INTEGER_SEQUENCE_PRESENT (__cplusplus >= 201402L)
  208. #define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__has_feature(cxx_variable_templates))
  209. #define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__has_feature(__cpp_deduction_guides))
  210. #define __TBB_CPP17_INVOKE_RESULT_PRESENT (__has_feature(__cpp_lib_is_invocable))
  211. #elif __GNUC__
  212. #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT __GXX_EXPERIMENTAL_CXX0X__
  213. #define __TBB_CPP11_VARIADIC_FIXED_LENGTH_EXP_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40700)
  214. #define __TBB_CPP11_RVALUE_REF_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40500)
  215. #define __TBB_IMPLICIT_MOVE_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40600)
  216. /** __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 here is a substitution for _GLIBCXX_ATOMIC_BUILTINS_4, which is a prerequisite
  217. for exception_ptr but cannot be used in this file because it is defined in a header, not by the compiler.
  218. If the compiler has no atomic intrinsics, the C++ library should not expect those as well. **/
  219. #define __TBB_EXCEPTION_PTR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40404 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
  220. #define __TBB_STATIC_ASSERT_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40300)
  221. #define __TBB_CPP11_TUPLE_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40300)
  222. #define __TBB_INITIALIZER_LISTS_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
  223. /** gcc seems have to support constexpr from 4.4 but tests in (test_atomic) seeming reasonable fail to compile prior 4.6**/
  224. #define __TBB_CONSTEXPR_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
  225. #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
  226. #define __TBB_NOEXCEPT_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40600)
  227. #define __TBB_CPP11_STD_BEGIN_END_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40600)
  228. #define __TBB_CPP11_AUTO_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
  229. #define __TBB_CPP11_DECLTYPE_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40400)
  230. #define __TBB_CPP11_LAMBDAS_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40500)
  231. #define __TBB_CPP11_DEFAULT_FUNC_TEMPLATE_ARGS_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40300)
  232. #define __TBB_OVERRIDE_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40700)
  233. #define __TBB_ALIGNAS_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40800)
  234. #define __TBB_CPP11_TEMPLATE_ALIASES_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GCC_VERSION >= 40700)
  235. #define __TBB_CPP14_INTEGER_SEQUENCE_PRESENT (__cplusplus >= 201402L && __TBB_GCC_VERSION >= 50000)
  236. #define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__cplusplus >= 201402L && __TBB_GCC_VERSION >= 50000)
  237. #define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__cpp_deduction_guides >= 201606L)
  238. #define __TBB_CPP17_INVOKE_RESULT_PRESENT (__cplusplus >= 201703L && __TBB_GCC_VERSION >= 70000)
  239. #elif _MSC_VER
  240. // These definitions are also used with Intel C++ Compiler in "default" mode (__INTEL_CXX11_MODE__ == 0);
  241. // see a comment in "__INTEL_COMPILER" section above.
  242. #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT (_MSC_VER >= 1800)
  243. // Contains a workaround for ICC 13
  244. #define __TBB_CPP11_RVALUE_REF_PRESENT (_MSC_VER >= 1700 && (!__INTEL_COMPILER || __INTEL_COMPILER >= 1400))
  245. #define __TBB_IMPLICIT_MOVE_PRESENT (_MSC_VER >= 1900)
  246. #define __TBB_EXCEPTION_PTR_PRESENT (_MSC_VER >= 1600)
  247. #define __TBB_STATIC_ASSERT_PRESENT (_MSC_VER >= 1600)
  248. #define __TBB_CPP11_TUPLE_PRESENT (_MSC_VER >= 1600)
  249. #define __TBB_INITIALIZER_LISTS_PRESENT (_MSC_VER >= 1800)
  250. #define __TBB_CONSTEXPR_PRESENT (_MSC_VER >= 1900)
  251. #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT (_MSC_VER >= 1800)
  252. #define __TBB_NOEXCEPT_PRESENT (_MSC_VER >= 1900)
  253. #define __TBB_CPP11_STD_BEGIN_END_PRESENT (_MSC_VER >= 1700)
  254. #define __TBB_CPP11_AUTO_PRESENT (_MSC_VER >= 1600)
  255. #define __TBB_CPP11_DECLTYPE_PRESENT (_MSC_VER >= 1600)
  256. #define __TBB_CPP11_LAMBDAS_PRESENT (_MSC_VER >= 1600)
  257. #define __TBB_CPP11_DEFAULT_FUNC_TEMPLATE_ARGS_PRESENT (_MSC_VER >= 1800)
  258. #define __TBB_OVERRIDE_PRESENT (_MSC_VER >= 1700)
  259. #define __TBB_ALIGNAS_PRESENT (_MSC_VER >= 1900)
  260. #define __TBB_CPP11_TEMPLATE_ALIASES_PRESENT (_MSC_VER >= 1800)
  261. #define __TBB_CPP14_INTEGER_SEQUENCE_PRESENT (_MSC_VER >= 1900)
  262. /* Variable templates are supported in VS2015 Update 2 or later */
  263. #define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (_MSC_FULL_VER >= 190023918 && (!__INTEL_COMPILER || __INTEL_COMPILER >= 1700))
  264. #define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (_MSVC_LANG >= 201703L && _MSC_VER >= 1914)
  265. #define __TBB_CPP17_INVOKE_RESULT_PRESENT (_MSVC_LANG >= 201703L && _MSC_VER >= 1911)
  266. #else
  267. #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT __TBB_CPP11_PRESENT
  268. #define __TBB_CPP11_RVALUE_REF_PRESENT __TBB_CPP11_PRESENT
  269. #define __TBB_IMPLICIT_MOVE_PRESENT __TBB_CPP11_PRESENT
  270. #define __TBB_EXCEPTION_PTR_PRESENT __TBB_CPP11_PRESENT
  271. #define __TBB_STATIC_ASSERT_PRESENT __TBB_CPP11_PRESENT
  272. #define __TBB_CPP11_TUPLE_PRESENT __TBB_CPP11_PRESENT
  273. #define __TBB_INITIALIZER_LISTS_PRESENT __TBB_CPP11_PRESENT
  274. #define __TBB_CONSTEXPR_PRESENT __TBB_CPP11_PRESENT
  275. #define __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT __TBB_CPP11_PRESENT
  276. #define __TBB_NOEXCEPT_PRESENT __TBB_CPP11_PRESENT
  277. #define __TBB_CPP11_STD_BEGIN_END_PRESENT __TBB_CPP11_PRESENT
  278. #define __TBB_CPP11_AUTO_PRESENT __TBB_CPP11_PRESENT
  279. #define __TBB_CPP11_DECLTYPE_PRESENT __TBB_CPP11_PRESENT
  280. #define __TBB_CPP11_LAMBDAS_PRESENT __TBB_CPP11_PRESENT
  281. #define __TBB_CPP11_DEFAULT_FUNC_TEMPLATE_ARGS_PRESENT __TBB_CPP11_PRESENT
  282. #define __TBB_OVERRIDE_PRESENT __TBB_CPP11_PRESENT
  283. #define __TBB_ALIGNAS_PRESENT __TBB_CPP11_PRESENT
  284. #define __TBB_CPP11_TEMPLATE_ALIASES_PRESENT __TBB_CPP11_PRESENT
  285. #define __TBB_CPP14_INTEGER_SEQUENCE_PRESENT (__cplusplus >= 201402L)
  286. #define __TBB_CPP14_VARIABLE_TEMPLATES_PRESENT (__cplusplus >= 201402L)
  287. #define __TBB_CPP17_DEDUCTION_GUIDES_PRESENT (__cplusplus >= 201703L)
  288. #define __TBB_CPP17_INVOKE_RESULT_PRESENT (__cplusplus >= 201703L)
  289. #endif
  290. // C++11 standard library features
  291. #define __TBB_CPP11_ARRAY_PRESENT (_MSC_VER >= 1700 || _LIBCPP_VERSION || __GXX_EXPERIMENTAL_CXX0X__ && __TBB_GLIBCXX_VERSION >= 40300)
  292. #ifndef __TBB_CPP11_VARIADIC_FIXED_LENGTH_EXP_PRESENT
  293. #define __TBB_CPP11_VARIADIC_FIXED_LENGTH_EXP_PRESENT __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT
  294. #endif
  295. #define __TBB_CPP11_VARIADIC_TUPLE_PRESENT (!_MSC_VER || _MSC_VER >= 1800)
  296. #define __TBB_CPP11_TYPE_PROPERTIES_PRESENT (_LIBCPP_VERSION || _MSC_VER >= 1700 || (__TBB_GLIBCXX_VERSION >= 50000 && __GXX_EXPERIMENTAL_CXX0X__))
  297. // GCC supported some of type properties since 4.7
  298. #define __TBB_CPP11_IS_COPY_CONSTRUCTIBLE_PRESENT (__GXX_EXPERIMENTAL_CXX0X__ && __TBB_GLIBCXX_VERSION >= 40700 || __TBB_CPP11_TYPE_PROPERTIES_PRESENT)
  299. // In GCC, std::move_if_noexcept appeared later than noexcept
  300. #define __TBB_MOVE_IF_NOEXCEPT_PRESENT (__TBB_NOEXCEPT_PRESENT && (__TBB_GLIBCXX_VERSION >= 40700 || _MSC_VER >= 1900 || _LIBCPP_VERSION))
  301. #define __TBB_ALLOCATOR_TRAITS_PRESENT (__cplusplus >= 201103L && _LIBCPP_VERSION || _MSC_VER >= 1800 || \
  302. __GXX_EXPERIMENTAL_CXX0X__ && __TBB_GLIBCXX_VERSION >= 40700 && !(__TBB_GLIBCXX_VERSION == 40700 && __TBB_DEFINE_MIC))
  303. #define __TBB_MAKE_EXCEPTION_PTR_PRESENT (__TBB_EXCEPTION_PTR_PRESENT && (_MSC_VER >= 1700 || __TBB_GLIBCXX_VERSION >= 40600 || _LIBCPP_VERSION || __SUNPRO_CC))
  304. // Due to libc++ limitations in C++03 mode, do not pass rvalues to std::make_shared()
  305. #define __TBB_CPP11_SMART_POINTERS_PRESENT ( _MSC_VER >= 1600 || _LIBCPP_VERSION \
  306. || ((__cplusplus >= 201103L || __GXX_EXPERIMENTAL_CXX0X__) \
  307. && (__TBB_GLIBCXX_VERSION >= 40500 || __TBB_GLIBCXX_VERSION >= 40400 && __TBB_USE_OPTIONAL_RTTI)) )
  308. #define __TBB_CPP11_FUTURE_PRESENT (_MSC_VER >= 1700 || __TBB_GLIBCXX_VERSION >= 40600 && __GXX_EXPERIMENTAL_CXX0X__ || _LIBCPP_VERSION)
  309. #define __TBB_CPP11_GET_NEW_HANDLER_PRESENT (_MSC_VER >= 1900 || __TBB_GLIBCXX_VERSION >= 40900 && __GXX_EXPERIMENTAL_CXX0X__ || _LIBCPP_VERSION)
  310. #define __TBB_CPP17_UNCAUGHT_EXCEPTIONS_PRESENT (_MSC_VER >= 1900 || __GLIBCXX__ && __cpp_lib_uncaught_exceptions \
  311. || _LIBCPP_VERSION >= 3700 && (!__TBB_MACOS_TARGET_VERSION || __TBB_MACOS_TARGET_VERSION >= 101200))
  312. // TODO: wait when memory_resource will be fully supported in clang and define the right macro
  313. // Currently it is in experimental stage since 6 version.
  314. #define __TBB_CPP17_MEMORY_RESOURCE_PRESENT (_MSC_VER >= 1913 && (_MSVC_LANG > 201402L || __cplusplus > 201402L) || \
  315. __GLIBCXX__ && __cpp_lib_memory_resource >= 201603)
  316. #define __TBB_CPP17_HW_INTERFERENCE_SIZE_PRESENT (_MSC_VER >= 1911)
  317. // std::swap is in <utility> only since C++11, though MSVC had it at least since VS2005
  318. #if _MSC_VER>=1400 || _LIBCPP_VERSION || __GXX_EXPERIMENTAL_CXX0X__
  319. #define __TBB_STD_SWAP_HEADER <utility>
  320. #else
  321. #define __TBB_STD_SWAP_HEADER <algorithm>
  322. #endif
  323. //TODO: not clear how exactly this macro affects exception_ptr - investigate
  324. // On linux ICC fails to find existing std::exception_ptr in libstdc++ without this define
  325. #if __INTEL_COMPILER && __GNUC__ && __TBB_EXCEPTION_PTR_PRESENT && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
  326. #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
  327. #endif
  328. // Work around a bug in MinGW32
  329. #if __MINGW32__ && __TBB_EXCEPTION_PTR_PRESENT && !defined(_GLIBCXX_ATOMIC_BUILTINS_4)
  330. #define _GLIBCXX_ATOMIC_BUILTINS_4
  331. #endif
  332. #if __GNUC__ || __SUNPRO_CC || __IBMCPP__
  333. /* ICC defines __GNUC__ and so is covered */
  334. #define __TBB_ATTRIBUTE_ALIGNED_PRESENT 1
  335. #elif _MSC_VER && (_MSC_VER >= 1300 || __INTEL_COMPILER)
  336. #define __TBB_DECLSPEC_ALIGN_PRESENT 1
  337. #endif
  338. /* Actually ICC supports gcc __sync_* intrinsics starting 11.1,
  339. * but 64 bit support for 32 bit target comes in later ones*/
  340. /* TODO: change the version back to 4.1.2 once macro __TBB_WORD_SIZE become optional */
  341. /* Assumed that all clang versions have these gcc compatible intrinsics. */
  342. #if __TBB_GCC_VERSION >= 40306 || __INTEL_COMPILER >= 1200 || __clang__
  343. /** built-in atomics available in GCC since 4.1.2 **/
  344. #define __TBB_GCC_BUILTIN_ATOMICS_PRESENT 1
  345. #endif
  346. #if __TBB_GCC_VERSION >= 70000 && !__INTEL_COMPILER && !__clang__
  347. // After GCC7 there was possible reordering problem in generic atomic load/store operations.
  348. // So always using builtins.
  349. #define TBB_USE_GCC_BUILTINS 1
  350. #endif
  351. #if __INTEL_COMPILER >= 1200
  352. /** built-in C++11 style atomics available in ICC since 12.0 **/
  353. #define __TBB_ICC_BUILTIN_ATOMICS_PRESENT 1
  354. #endif
  355. #if _MSC_VER>=1600 && (!__INTEL_COMPILER || __INTEL_COMPILER>=1310)
  356. #define __TBB_MSVC_PART_WORD_INTERLOCKED_INTRINSICS_PRESENT 1
  357. #endif
  358. #define __TBB_TSX_INTRINSICS_PRESENT ((__RTM__ || _MSC_VER>=1700 || __INTEL_COMPILER>=1300) && !__TBB_DEFINE_MIC && !__ANDROID__)
  359. /** Macro helpers **/
  360. #define __TBB_CONCAT_AUX(A,B) A##B
  361. // The additional level of indirection is needed to expand macros A and B (not to get the AB macro).
  362. // See [cpp.subst] and [cpp.concat] for more details.
  363. #define __TBB_CONCAT(A,B) __TBB_CONCAT_AUX(A,B)
  364. // The IGNORED argument and comma are needed to always have 2 arguments (even when A is empty).
  365. #define __TBB_IS_MACRO_EMPTY(A,IGNORED) __TBB_CONCAT_AUX(__TBB_MACRO_EMPTY,A)
  366. #define __TBB_MACRO_EMPTY 1
  367. /** User controlled TBB features & modes **/
  368. #ifndef TBB_USE_DEBUG
  369. /*
  370. There are four cases that are supported:
  371. 1. "_DEBUG is undefined" means "no debug";
  372. 2. "_DEBUG defined to something that is evaluated to 0" (including "garbage", as per [cpp.cond]) means "no debug";
  373. 3. "_DEBUG defined to something that is evaluated to a non-zero value" means "debug";
  374. 4. "_DEBUG defined to nothing (empty)" means "debug".
  375. */
  376. #ifdef _DEBUG
  377. // Check if _DEBUG is empty.
  378. #define __TBB_IS__DEBUG_EMPTY (__TBB_IS_MACRO_EMPTY(_DEBUG,IGNORED)==__TBB_MACRO_EMPTY)
  379. #if __TBB_IS__DEBUG_EMPTY
  380. #define TBB_USE_DEBUG 1
  381. #else
  382. #define TBB_USE_DEBUG _DEBUG
  383. #endif /* __TBB_IS__DEBUG_EMPTY */
  384. #else
  385. #define TBB_USE_DEBUG 0
  386. #endif
  387. #endif /* TBB_USE_DEBUG */
  388. #ifndef TBB_USE_ASSERT
  389. #define TBB_USE_ASSERT TBB_USE_DEBUG
  390. #endif /* TBB_USE_ASSERT */
  391. #ifndef TBB_USE_THREADING_TOOLS
  392. #define TBB_USE_THREADING_TOOLS TBB_USE_DEBUG
  393. #endif /* TBB_USE_THREADING_TOOLS */
  394. #ifndef TBB_USE_PERFORMANCE_WARNINGS
  395. #ifdef TBB_PERFORMANCE_WARNINGS
  396. #define TBB_USE_PERFORMANCE_WARNINGS TBB_PERFORMANCE_WARNINGS
  397. #else
  398. #define TBB_USE_PERFORMANCE_WARNINGS TBB_USE_DEBUG
  399. #endif /* TBB_PERFORMANCE_WARNINGS */
  400. #endif /* TBB_USE_PERFORMANCE_WARNINGS */
  401. #if __TBB_DEFINE_MIC
  402. #if TBB_USE_EXCEPTIONS
  403. #error The platform does not properly support exception handling. Please do not set TBB_USE_EXCEPTIONS macro or set it to 0.
  404. #elif !defined(TBB_USE_EXCEPTIONS)
  405. #define TBB_USE_EXCEPTIONS 0
  406. #endif
  407. #elif !(__EXCEPTIONS || defined(_CPPUNWIND) || __SUNPRO_CC)
  408. #if TBB_USE_EXCEPTIONS
  409. #error Compilation settings do not support exception handling. Please do not set TBB_USE_EXCEPTIONS macro or set it to 0.
  410. #elif !defined(TBB_USE_EXCEPTIONS)
  411. #define TBB_USE_EXCEPTIONS 0
  412. #endif
  413. #elif !defined(TBB_USE_EXCEPTIONS)
  414. #define TBB_USE_EXCEPTIONS 1
  415. #endif
  416. #ifndef TBB_IMPLEMENT_CPP0X
  417. /** By default, use C++11 classes if available **/
  418. #if __clang__
  419. /* Old versions of Intel C++ Compiler do not have __has_include or cannot use it in #define */
  420. #if (__INTEL_COMPILER && (__INTEL_COMPILER < 1500 || __INTEL_COMPILER == 1500 && __INTEL_COMPILER_UPDATE <= 1))
  421. #define TBB_IMPLEMENT_CPP0X (__cplusplus < 201103L || !_LIBCPP_VERSION)
  422. #else
  423. #define TBB_IMPLEMENT_CPP0X (__cplusplus < 201103L || (!__has_include(<thread>) && !__has_include(<condition_variable>)))
  424. #endif
  425. #elif __GNUC__
  426. #define TBB_IMPLEMENT_CPP0X (__TBB_GCC_VERSION < 40400 || !__GXX_EXPERIMENTAL_CXX0X__)
  427. #elif _MSC_VER
  428. #define TBB_IMPLEMENT_CPP0X (_MSC_VER < 1700)
  429. #else
  430. // TODO: Reconsider general approach to be more reliable, e.g. (!(__cplusplus >= 201103L && __ STDC_HOSTED__))
  431. #define TBB_IMPLEMENT_CPP0X (!__STDCPP_THREADS__)
  432. #endif
  433. #endif /* TBB_IMPLEMENT_CPP0X */
  434. /* TBB_USE_CAPTURED_EXCEPTION should be explicitly set to either 0 or 1, as it is used as C++ const */
  435. #ifndef TBB_USE_CAPTURED_EXCEPTION
  436. /** IA-64 architecture pre-built TBB binaries do not support exception_ptr. **/
  437. #if __TBB_EXCEPTION_PTR_PRESENT && !defined(__ia64__)
  438. #define TBB_USE_CAPTURED_EXCEPTION 0
  439. #else
  440. #define TBB_USE_CAPTURED_EXCEPTION 1
  441. #endif
  442. #else /* defined TBB_USE_CAPTURED_EXCEPTION */
  443. #if !TBB_USE_CAPTURED_EXCEPTION && !__TBB_EXCEPTION_PTR_PRESENT
  444. #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.
  445. #endif
  446. #endif /* defined TBB_USE_CAPTURED_EXCEPTION */
  447. /** Check whether the request to use GCC atomics can be satisfied **/
  448. #if TBB_USE_GCC_BUILTINS && !__TBB_GCC_BUILTIN_ATOMICS_PRESENT
  449. #error "GCC atomic built-ins are not supported."
  450. #endif
  451. /** Internal TBB features & modes **/
  452. /** __TBB_CONCURRENT_ORDERED_CONTAINERS indicates that all conditions of use
  453. * concurrent_map and concurrent_set are met. **/
  454. // TODO: Add cpp11 random generation macro
  455. #ifndef __TBB_CONCURRENT_ORDERED_CONTAINERS_PRESENT
  456. #define __TBB_CONCURRENT_ORDERED_CONTAINERS_PRESENT ( __TBB_CPP11_RVALUE_REF_PRESENT && __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT \
  457. && __TBB_IMPLICIT_MOVE_PRESENT && __TBB_CPP11_AUTO_PRESENT && __TBB_CPP11_LAMBDAS_PRESENT && __TBB_CPP11_ARRAY_PRESENT \
  458. && __TBB_INITIALIZER_LISTS_PRESENT )
  459. #endif
  460. /** __TBB_WEAK_SYMBOLS_PRESENT denotes that the system supports the weak symbol mechanism **/
  461. #ifndef __TBB_WEAK_SYMBOLS_PRESENT
  462. #define __TBB_WEAK_SYMBOLS_PRESENT ( !_WIN32 && !__APPLE__ && !__sun && (__TBB_GCC_VERSION >= 40000 || __INTEL_COMPILER ) )
  463. #endif
  464. /** __TBB_DYNAMIC_LOAD_ENABLED describes the system possibility to load shared libraries at run time **/
  465. #ifndef __TBB_DYNAMIC_LOAD_ENABLED
  466. #define __TBB_DYNAMIC_LOAD_ENABLED 1
  467. #endif
  468. /** __TBB_SOURCE_DIRECTLY_INCLUDED is a mode used in whitebox testing when
  469. it's necessary to test internal functions not exported from TBB DLLs
  470. **/
  471. #if (_WIN32||_WIN64) && (__TBB_SOURCE_DIRECTLY_INCLUDED || TBB_USE_PREVIEW_BINARY)
  472. #define __TBB_NO_IMPLICIT_LINKAGE 1
  473. #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1
  474. #endif
  475. #ifndef __TBB_COUNT_TASK_NODES
  476. #define __TBB_COUNT_TASK_NODES TBB_USE_ASSERT
  477. #endif
  478. #ifndef __TBB_TASK_GROUP_CONTEXT
  479. #define __TBB_TASK_GROUP_CONTEXT 1
  480. #endif /* __TBB_TASK_GROUP_CONTEXT */
  481. #ifndef __TBB_SCHEDULER_OBSERVER
  482. #define __TBB_SCHEDULER_OBSERVER 1
  483. #endif /* __TBB_SCHEDULER_OBSERVER */
  484. #ifndef __TBB_FP_CONTEXT
  485. #define __TBB_FP_CONTEXT __TBB_TASK_GROUP_CONTEXT
  486. #endif /* __TBB_FP_CONTEXT */
  487. #if __TBB_FP_CONTEXT && !__TBB_TASK_GROUP_CONTEXT
  488. #error __TBB_FP_CONTEXT requires __TBB_TASK_GROUP_CONTEXT to be enabled
  489. #endif
  490. #define __TBB_RECYCLE_TO_ENQUEUE __TBB_BUILD // keep non-official
  491. #ifndef __TBB_ARENA_OBSERVER
  492. #define __TBB_ARENA_OBSERVER __TBB_SCHEDULER_OBSERVER
  493. #endif /* __TBB_ARENA_OBSERVER */
  494. #ifndef __TBB_TASK_ISOLATION
  495. #define __TBB_TASK_ISOLATION 1
  496. #endif /* __TBB_TASK_ISOLATION */
  497. #if TBB_USE_EXCEPTIONS && !__TBB_TASK_GROUP_CONTEXT
  498. #error TBB_USE_EXCEPTIONS requires __TBB_TASK_GROUP_CONTEXT to be enabled
  499. #endif
  500. #ifndef __TBB_TASK_PRIORITY
  501. #define __TBB_TASK_PRIORITY (__TBB_TASK_GROUP_CONTEXT)
  502. #endif /* __TBB_TASK_PRIORITY */
  503. #if __TBB_TASK_PRIORITY && !__TBB_TASK_GROUP_CONTEXT
  504. #error __TBB_TASK_PRIORITY requires __TBB_TASK_GROUP_CONTEXT to be enabled
  505. #endif
  506. #if TBB_PREVIEW_NUMA_SUPPORT || __TBB_BUILD
  507. #define __TBB_NUMA_SUPPORT 1
  508. #endif
  509. #if TBB_PREVIEW_WAITING_FOR_WORKERS || __TBB_BUILD
  510. #define __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE 1
  511. #endif
  512. #ifndef __TBB_ENQUEUE_ENFORCED_CONCURRENCY
  513. #define __TBB_ENQUEUE_ENFORCED_CONCURRENCY 1
  514. #endif
  515. #if !defined(__TBB_SURVIVE_THREAD_SWITCH) && \
  516. (_WIN32 || _WIN64 || __APPLE__ || (__linux__ && !__ANDROID__))
  517. #define __TBB_SURVIVE_THREAD_SWITCH 1
  518. #endif /* __TBB_SURVIVE_THREAD_SWITCH */
  519. #ifndef __TBB_DEFAULT_PARTITIONER
  520. #define __TBB_DEFAULT_PARTITIONER tbb::auto_partitioner
  521. #endif
  522. #ifndef __TBB_USE_PROPORTIONAL_SPLIT_IN_BLOCKED_RANGES
  523. #define __TBB_USE_PROPORTIONAL_SPLIT_IN_BLOCKED_RANGES 1
  524. #endif
  525. #ifndef __TBB_ENABLE_RANGE_FEEDBACK
  526. #define __TBB_ENABLE_RANGE_FEEDBACK 0
  527. #endif
  528. #ifdef _VARIADIC_MAX
  529. #define __TBB_VARIADIC_MAX _VARIADIC_MAX
  530. #else
  531. #if _MSC_VER == 1700
  532. #define __TBB_VARIADIC_MAX 5 // VS11 setting, issue resolved in VS12
  533. #elif _MSC_VER == 1600
  534. #define __TBB_VARIADIC_MAX 10 // VS10 setting
  535. #else
  536. #define __TBB_VARIADIC_MAX 15
  537. #endif
  538. #endif
  539. // Intel C++ Compiler starts analyzing usages of the deprecated content at the template
  540. // instantiation site, which is too late for suppression of the corresponding messages for internal
  541. // stuff.
  542. #if !defined(__INTEL_COMPILER) && (!defined(TBB_SUPPRESS_DEPRECATED_MESSAGES) || (TBB_SUPPRESS_DEPRECATED_MESSAGES == 0))
  543. #if (__cplusplus >= 201402L)
  544. #define __TBB_DEPRECATED [[deprecated]]
  545. #define __TBB_DEPRECATED_MSG(msg) [[deprecated(msg)]]
  546. #elif _MSC_VER
  547. #define __TBB_DEPRECATED __declspec(deprecated)
  548. #define __TBB_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
  549. #elif (__GNUC__ && __TBB_GCC_VERSION >= 40805) || __clang__
  550. #define __TBB_DEPRECATED __attribute__((deprecated))
  551. #define __TBB_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
  552. #endif
  553. #endif // !defined(TBB_SUPPRESS_DEPRECATED_MESSAGES) || (TBB_SUPPRESS_DEPRECATED_MESSAGES == 0)
  554. #if !defined(__TBB_DEPRECATED)
  555. #define __TBB_DEPRECATED
  556. #define __TBB_DEPRECATED_MSG(msg)
  557. #elif !defined(__TBB_SUPPRESS_INTERNAL_DEPRECATED_MESSAGES)
  558. // Suppress deprecated messages from self
  559. #define __TBB_SUPPRESS_INTERNAL_DEPRECATED_MESSAGES 1
  560. #endif
  561. #if defined(TBB_SUPPRESS_DEPRECATED_MESSAGES) && (TBB_SUPPRESS_DEPRECATED_MESSAGES == 0)
  562. #define __TBB_DEPRECATED_IN_VERBOSE_MODE __TBB_DEPRECATED
  563. #define __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG(msg) __TBB_DEPRECATED_MSG(msg)
  564. #else
  565. #define __TBB_DEPRECATED_IN_VERBOSE_MODE
  566. #define __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG(msg)
  567. #endif // (TBB_SUPPRESS_DEPRECATED_MESSAGES == 0)
  568. #if (!defined(TBB_SUPPRESS_DEPRECATED_MESSAGES) || (TBB_SUPPRESS_DEPRECATED_MESSAGES == 0)) && !__TBB_CPP11_PRESENT
  569. #pragma message("TBB Warning: Support for C++98/03 is deprecated. Please use the compiler that supports C++11 features at least.")
  570. #endif
  571. /** __TBB_WIN8UI_SUPPORT enables support of Windows* Store Apps and limit a possibility to load
  572. shared libraries at run time only from application container **/
  573. // TODO: Separate this single macro into two for Windows 8 Store* (win8ui mode) and UWP/UWD modes.
  574. #if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_APP
  575. #define __TBB_WIN8UI_SUPPORT 1
  576. #else
  577. #define __TBB_WIN8UI_SUPPORT 0
  578. #endif
  579. /** Macros of the form __TBB_XXX_BROKEN denote known issues that are caused by
  580. the bugs in compilers, standard or OS specific libraries. They should be
  581. removed as soon as the corresponding bugs are fixed or the buggy OS/compiler
  582. versions go out of the support list.
  583. **/
  584. #if __SIZEOF_POINTER__ < 8 && __ANDROID__ && __TBB_GCC_VERSION <= 40403 && !__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
  585. /** Necessary because on Android 8-byte CAS and F&A are not available for some processor architectures,
  586. but no mandatory warning message appears from GCC 4.4.3. Instead, only a linkage error occurs when
  587. these atomic operations are used (such as in unit test test_atomic.exe). **/
  588. #define __TBB_GCC_64BIT_ATOMIC_BUILTINS_BROKEN 1
  589. #elif __TBB_x86_32 && __TBB_GCC_VERSION == 40102 && ! __GNUC_RH_RELEASE__
  590. /** GCC 4.1.2 erroneously emit call to external function for 64 bit sync_ intrinsics.
  591. However these functions are not defined anywhere. It seems that this problem was fixed later on
  592. and RHEL got an updated version of gcc 4.1.2. **/
  593. #define __TBB_GCC_64BIT_ATOMIC_BUILTINS_BROKEN 1
  594. #endif
  595. #if __GNUC__ && __TBB_x86_64 && __INTEL_COMPILER == 1200
  596. #define __TBB_ICC_12_0_INL_ASM_FSTCW_BROKEN 1
  597. #endif
  598. #if _MSC_VER && __INTEL_COMPILER && (__INTEL_COMPILER<1110 || __INTEL_COMPILER==1110 && __INTEL_COMPILER_BUILD_DATE < 20091012)
  599. /** Necessary to avoid ICL error (or warning in non-strict mode):
  600. "exception specification for implicitly declared virtual destructor is
  601. incompatible with that of overridden one". **/
  602. #define __TBB_DEFAULT_DTOR_THROW_SPEC_BROKEN 1
  603. #endif
  604. #if !__INTEL_COMPILER && (_MSC_VER && _MSC_VER < 1500 || __GNUC__ && __TBB_GCC_VERSION < 40102)
  605. /** gcc 3.4.6 (and earlier) and VS2005 (and earlier) do not allow declaring template class as a friend
  606. of classes defined in other namespaces. **/
  607. #define __TBB_TEMPLATE_FRIENDS_BROKEN 1
  608. #endif
  609. #if __GLIBC__==2 && __GLIBC_MINOR__==3 || (__APPLE__ && ( __INTEL_COMPILER==1200 && !TBB_USE_DEBUG))
  610. /** Macro controlling EH usages in TBB tests.
  611. Some older versions of glibc crash when exception handling happens concurrently. **/
  612. #define __TBB_THROW_ACROSS_MODULE_BOUNDARY_BROKEN 1
  613. #endif
  614. #if (_WIN32||_WIN64) && __INTEL_COMPILER == 1110
  615. /** That's a bug in Intel C++ Compiler 11.1.044/IA-32 architecture/Windows* OS, that leads to a worker thread crash on the thread's startup. **/
  616. #define __TBB_ICL_11_1_CODE_GEN_BROKEN 1
  617. #endif
  618. #if __clang__ || (__GNUC__==3 && __GNUC_MINOR__==3 && !defined(__INTEL_COMPILER))
  619. /** Bugs with access to nested classes declared in protected area */
  620. #define __TBB_PROTECTED_NESTED_CLASS_BROKEN 1
  621. #endif
  622. #if __MINGW32__ && __TBB_GCC_VERSION < 40200
  623. /** MinGW has a bug with stack alignment for routines invoked from MS RTLs.
  624. Since GCC 4.2, the bug can be worked around via a special attribute. **/
  625. #define __TBB_SSE_STACK_ALIGNMENT_BROKEN 1
  626. #endif
  627. #if __TBB_GCC_VERSION==40300 && !__INTEL_COMPILER && !__clang__
  628. /* GCC of this version may rashly ignore control dependencies */
  629. #define __TBB_GCC_OPTIMIZER_ORDERING_BROKEN 1
  630. #endif
  631. #if __FreeBSD__
  632. /** A bug in FreeBSD 8.0 results in kernel panic when there is contention
  633. on a mutex created with this attribute. **/
  634. #define __TBB_PRIO_INHERIT_BROKEN 1
  635. /** A bug in FreeBSD 8.0 results in test hanging when an exception occurs
  636. during (concurrent?) object construction by means of placement new operator. **/
  637. #define __TBB_PLACEMENT_NEW_EXCEPTION_SAFETY_BROKEN 1
  638. #endif /* __FreeBSD__ */
  639. #if (__linux__ || __APPLE__) && __i386__ && defined(__INTEL_COMPILER)
  640. /** The Intel C++ Compiler for IA-32 architecture (Linux* OS|macOS) crashes or generates
  641. incorrect code when __asm__ arguments have a cast to volatile. **/
  642. #define __TBB_ICC_ASM_VOLATILE_BROKEN 1
  643. #endif
  644. #if !__INTEL_COMPILER && (_MSC_VER && _MSC_VER < 1700 || __GNUC__==3 && __GNUC_MINOR__<=2)
  645. /** Bug in GCC 3.2 and MSVC compilers that sometimes return 0 for __alignof(T)
  646. when T has not yet been instantiated. **/
  647. #define __TBB_ALIGNOF_NOT_INSTANTIATED_TYPES_BROKEN 1
  648. #endif
  649. #if __TBB_DEFINE_MIC
  650. /** Main thread and user's thread have different default thread affinity masks. **/
  651. #define __TBB_MAIN_THREAD_AFFINITY_BROKEN 1
  652. #endif
  653. #if __GXX_EXPERIMENTAL_CXX0X__ && !defined(__EXCEPTIONS) && \
  654. ((!__INTEL_COMPILER && !__clang__ && (__TBB_GCC_VERSION>=40400 && __TBB_GCC_VERSION<40600)) || \
  655. (__INTEL_COMPILER<=1400 && (__TBB_GLIBCXX_VERSION>=40400 && __TBB_GLIBCXX_VERSION<=40801)))
  656. /* There is an issue for specific GCC toolchain when C++11 is enabled
  657. and exceptions are disabled:
  658. exceprion_ptr.h/nested_exception.h use throw unconditionally.
  659. GCC can ignore 'throw' since 4.6; but with ICC the issue still exists.
  660. */
  661. #define __TBB_LIBSTDCPP_EXCEPTION_HEADERS_BROKEN 1
  662. #endif
  663. #if __INTEL_COMPILER==1300 && __TBB_GLIBCXX_VERSION>=40700 && defined(__GXX_EXPERIMENTAL_CXX0X__)
  664. /* Some C++11 features used inside libstdc++ are not supported by Intel C++ Compiler. */
  665. #define __TBB_ICC_13_0_CPP11_STDLIB_SUPPORT_BROKEN 1
  666. #endif
  667. #if (__GNUC__==4 && __GNUC_MINOR__==4 ) && !defined(__INTEL_COMPILER) && !defined(__clang__)
  668. /** excessive warnings related to strict aliasing rules in GCC 4.4 **/
  669. #define __TBB_GCC_STRICT_ALIASING_BROKEN 1
  670. /* topical remedy: #pragma GCC diagnostic ignored "-Wstrict-aliasing" */
  671. #if !__TBB_GCC_WARNING_SUPPRESSION_PRESENT
  672. #error Warning suppression is not supported, while should.
  673. #endif
  674. #endif
  675. /* In a PIC mode some versions of GCC 4.1.2 generate incorrect inlined code for 8 byte __sync_val_compare_and_swap intrinsic */
  676. #if __TBB_GCC_VERSION == 40102 && __PIC__ && !defined(__INTEL_COMPILER) && !defined(__clang__)
  677. #define __TBB_GCC_CAS8_BUILTIN_INLINING_BROKEN 1
  678. #endif
  679. #if __TBB_x86_32 && ( __INTEL_COMPILER || (__GNUC__==5 && __GNUC_MINOR__>=2 && __GXX_EXPERIMENTAL_CXX0X__) \
  680. || (__GNUC__==3 && __GNUC_MINOR__==3) || (__MINGW32__ && __GNUC__==4 && __GNUC_MINOR__==5) || __SUNPRO_CC )
  681. // Some compilers for IA-32 architecture fail to provide 8-byte alignment of objects on the stack,
  682. // even if the object specifies 8-byte alignment. On such platforms, the implementation
  683. // of 64 bit atomics for IA-32 architecture (e.g. atomic<long long>) use different tactics
  684. // depending upon whether the object is properly aligned or not.
  685. #define __TBB_FORCE_64BIT_ALIGNMENT_BROKEN 1
  686. #else
  687. // Define to 0 explicitly because the macro is used in a compiled code of test_atomic
  688. #define __TBB_FORCE_64BIT_ALIGNMENT_BROKEN 0
  689. #endif
  690. #if __GNUC__ && !__INTEL_COMPILER && !__clang__ && __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT && __TBB_GCC_VERSION < 40700
  691. #define __TBB_ZERO_INIT_WITH_DEFAULTED_CTOR_BROKEN 1
  692. #endif
  693. #if _MSC_VER && _MSC_VER <= 1800 && !__INTEL_COMPILER
  694. // With MSVC, when an array is passed by const reference to a template function,
  695. // constness from the function parameter may get propagated to the template parameter.
  696. #define __TBB_CONST_REF_TO_ARRAY_TEMPLATE_PARAM_BROKEN 1
  697. #endif
  698. // A compiler bug: a disabled copy constructor prevents use of the moving constructor
  699. #define __TBB_IF_NO_COPY_CTOR_MOVE_SEMANTICS_BROKEN (_MSC_VER && (__INTEL_COMPILER >= 1300 && __INTEL_COMPILER <= 1310) && !__INTEL_CXX11_MODE__)
  700. #define __TBB_CPP11_DECLVAL_BROKEN (_MSC_VER == 1600 || (__GNUC__ && __TBB_GCC_VERSION < 40500) )
  701. // Intel C++ Compiler has difficulties with copying std::pair with VC11 std::reference_wrapper being a const member
  702. #define __TBB_COPY_FROM_NON_CONST_REF_BROKEN (_MSC_VER == 1700 && __INTEL_COMPILER && __INTEL_COMPILER < 1600)
  703. // The implicit upcasting of the tuple of a reference of a derived class to a base class fails on icc 13.X if the system's gcc environment is 4.8
  704. // Also in gcc 4.4 standard library the implementation of the tuple<&> conversion (tuple<A&> a = tuple<B&>, B is inherited from A) is broken.
  705. #if __GXX_EXPERIMENTAL_CXX0X__ && __GLIBCXX__ && ((__INTEL_COMPILER >=1300 && __INTEL_COMPILER <=1310 && __TBB_GLIBCXX_VERSION>=40700) || (__TBB_GLIBCXX_VERSION < 40500))
  706. #define __TBB_UPCAST_OF_TUPLE_OF_REF_BROKEN 1
  707. #endif
  708. // In some cases decltype of a function adds a reference to a return type.
  709. #define __TBB_CPP11_DECLTYPE_OF_FUNCTION_RETURN_TYPE_BROKEN (_MSC_VER == 1600 && !__INTEL_COMPILER)
  710. // Visual Studio 2013 does not delete the copy constructor when a user-defined move constructor is provided
  711. #if _MSC_VER && _MSC_VER <= 1800
  712. #define __TBB_IMPLICIT_COPY_DELETION_BROKEN 1
  713. #endif
  714. /** End of __TBB_XXX_BROKEN macro section **/
  715. #if defined(_MSC_VER) && _MSC_VER>=1500 && !defined(__INTEL_COMPILER)
  716. // A macro to suppress erroneous or benign "unreachable code" MSVC warning (4702)
  717. #define __TBB_MSVC_UNREACHABLE_CODE_IGNORED 1
  718. #endif
  719. #define __TBB_ATOMIC_CTORS (__TBB_CONSTEXPR_PRESENT && __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT && (!__TBB_ZERO_INIT_WITH_DEFAULTED_CTOR_BROKEN))
  720. // Many OS versions (Android 4.0.[0-3] for example) need workaround for dlopen to avoid non-recursive loader lock hang
  721. // Setting the workaround for all compile targets ($APP_PLATFORM) below Android 4.4 (android-19)
  722. #if __ANDROID__
  723. #include <android/api-level.h>
  724. #define __TBB_USE_DLOPEN_REENTRANCY_WORKAROUND (__ANDROID_API__ < 19)
  725. #endif
  726. #define __TBB_ALLOCATOR_CONSTRUCT_VARIADIC (__TBB_CPP11_VARIADIC_TEMPLATES_PRESENT && __TBB_CPP11_RVALUE_REF_PRESENT)
  727. #define __TBB_VARIADIC_PARALLEL_INVOKE (TBB_PREVIEW_VARIADIC_PARALLEL_INVOKE && __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT && __TBB_CPP11_RVALUE_REF_PRESENT)
  728. #define __TBB_FLOW_GRAPH_CPP11_FEATURES (__TBB_CPP11_VARIADIC_TEMPLATES_PRESENT \
  729. && __TBB_CPP11_SMART_POINTERS_PRESENT && __TBB_CPP11_RVALUE_REF_PRESENT && __TBB_CPP11_AUTO_PRESENT) \
  730. && __TBB_CPP11_VARIADIC_TUPLE_PRESENT && __TBB_CPP11_DEFAULT_FUNC_TEMPLATE_ARGS_PRESENT \
  731. && !__TBB_UPCAST_OF_TUPLE_OF_REF_BROKEN
  732. #define __TBB_PREVIEW_STREAMING_NODE (__TBB_CPP11_VARIADIC_FIXED_LENGTH_EXP_PRESENT && __TBB_FLOW_GRAPH_CPP11_FEATURES \
  733. && TBB_PREVIEW_FLOW_GRAPH_NODES && !TBB_IMPLEMENT_CPP0X && !__TBB_UPCAST_OF_TUPLE_OF_REF_BROKEN)
  734. #define __TBB_PREVIEW_OPENCL_NODE (__TBB_PREVIEW_STREAMING_NODE && __TBB_CPP11_TEMPLATE_ALIASES_PRESENT)
  735. #define __TBB_PREVIEW_MESSAGE_BASED_KEY_MATCHING (TBB_PREVIEW_FLOW_GRAPH_FEATURES || __TBB_PREVIEW_OPENCL_NODE)
  736. #define __TBB_PREVIEW_ASYNC_MSG (TBB_PREVIEW_FLOW_GRAPH_FEATURES && __TBB_FLOW_GRAPH_CPP11_FEATURES)
  737. #ifndef __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES
  738. #define __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES TBB_PREVIEW_FLOW_GRAPH_FEATURES
  739. #endif
  740. // This feature works only in combination with critical tasks (__TBB_PREVIEW_CRITICAL_TASKS)
  741. #ifndef __TBB_PREVIEW_RESUMABLE_TASKS
  742. #define __TBB_PREVIEW_RESUMABLE_TASKS ((__TBB_CPF_BUILD || TBB_PREVIEW_RESUMABLE_TASKS) && !__TBB_WIN8UI_SUPPORT && !__ANDROID__ && !__TBB_ipf)
  743. #endif
  744. #ifndef __TBB_PREVIEW_CRITICAL_TASKS
  745. #define __TBB_PREVIEW_CRITICAL_TASKS (__TBB_CPF_BUILD || __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES || __TBB_PREVIEW_RESUMABLE_TASKS)
  746. #endif
  747. #ifndef __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
  748. #define __TBB_PREVIEW_FLOW_GRAPH_NODE_SET (TBB_PREVIEW_FLOW_GRAPH_FEATURES && __TBB_CPP11_PRESENT && __TBB_FLOW_GRAPH_CPP11_FEATURES)
  749. #endif
  750. #endif /* __TBB_tbb_config_H */