File indexing completed on 2024-11-15 09:58:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef __TBB_tbb_stddef_H
0018 #define __TBB_tbb_stddef_H
0019
0020
0021 #define TBB_VERSION_MAJOR 2020
0022 #define TBB_VERSION_MINOR 3
0023
0024
0025 #define TBB_INTERFACE_VERSION 11103
0026 #define TBB_INTERFACE_VERSION_MAJOR TBB_INTERFACE_VERSION/1000
0027
0028
0029
0030 #define TBB_COMPATIBLE_INTERFACE_VERSION 2
0031
0032 #define __TBB_STRING_AUX(x) #x
0033 #define __TBB_STRING(x) __TBB_STRING_AUX(x)
0034
0035
0036 #if !defined RC_INVOKED
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 #include "tbb_config.h"
0092
0093 #if _MSC_VER >=1400
0094 #define __TBB_EXPORTED_FUNC __cdecl
0095 #define __TBB_EXPORTED_METHOD __thiscall
0096 #else
0097 #define __TBB_EXPORTED_FUNC
0098 #define __TBB_EXPORTED_METHOD
0099 #endif
0100
0101 #if __INTEL_COMPILER || _MSC_VER
0102 #define __TBB_NOINLINE(decl) __declspec(noinline) decl
0103 #elif __GNUC__
0104 #define __TBB_NOINLINE(decl) decl __attribute__ ((noinline))
0105 #else
0106 #define __TBB_NOINLINE(decl) decl
0107 #endif
0108
0109 #if __TBB_NOEXCEPT_PRESENT
0110 #define __TBB_NOEXCEPT(expression) noexcept(expression)
0111 #else
0112 #define __TBB_NOEXCEPT(expression)
0113 #endif
0114
0115 #include <cstddef> /* Need size_t and ptrdiff_t */
0116
0117 #if _MSC_VER
0118 #define __TBB_tbb_windef_H
0119 #include "internal/_tbb_windef.h"
0120 #undef __TBB_tbb_windef_H
0121 #endif
0122 #if !defined(_MSC_VER) || _MSC_VER>=1600
0123 #include <stdint.h>
0124 #endif
0125
0126
0127 typedef void(*assertion_handler_type)( const char* filename, int line, const char* expression, const char * comment );
0128
0129 #if __TBBMALLOC_BUILD
0130 namespace rml { namespace internal {
0131 #define __TBB_ASSERT_RELEASE(predicate,message) ((predicate)?((void)0) : rml::internal::assertion_failure(__FILE__,__LINE__,#predicate,message))
0132 #else
0133 namespace tbb {
0134 #define __TBB_ASSERT_RELEASE(predicate,message) ((predicate)?((void)0) : tbb::assertion_failure(__FILE__,__LINE__,#predicate,message))
0135 #endif
0136
0137
0138 assertion_handler_type __TBB_EXPORTED_FUNC set_assertion_handler( assertion_handler_type new_handler );
0139
0140
0141
0142
0143
0144 void __TBB_EXPORTED_FUNC assertion_failure( const char* filename, int line, const char* expression, const char* comment );
0145
0146 #if __TBBMALLOC_BUILD
0147 }}
0148 #else
0149 }
0150 #endif
0151
0152 #if TBB_USE_ASSERT
0153
0154
0155
0156
0157
0158 #define __TBB_ASSERT(predicate,message) __TBB_ASSERT_RELEASE(predicate,message)
0159
0160 #define __TBB_ASSERT_EX __TBB_ASSERT
0161
0162 #else
0163
0164
0165 #define __TBB_ASSERT(predicate,comment) ((void)0)
0166
0167 #define __TBB_ASSERT_EX(predicate,comment) ((void)(1 && (predicate)))
0168
0169 #endif
0170
0171
0172 namespace tbb {
0173
0174 namespace internal {
0175 #if _MSC_VER && _MSC_VER<1600
0176 typedef __int8 int8_t;
0177 typedef __int16 int16_t;
0178 typedef __int32 int32_t;
0179 typedef __int64 int64_t;
0180 typedef unsigned __int8 uint8_t;
0181 typedef unsigned __int16 uint16_t;
0182 typedef unsigned __int32 uint32_t;
0183 typedef unsigned __int64 uint64_t;
0184 #else
0185 using ::int8_t;
0186 using ::int16_t;
0187 using ::int32_t;
0188 using ::int64_t;
0189 using ::uint8_t;
0190 using ::uint16_t;
0191 using ::uint32_t;
0192 using ::uint64_t;
0193 #endif
0194 }
0195
0196 using std::size_t;
0197 using std::ptrdiff_t;
0198
0199
0200
0201
0202
0203
0204 extern "C" int __TBB_EXPORTED_FUNC TBB_runtime_interface_version();
0205
0206
0207
0208
0209
0210 namespace internal {
0211
0212
0213
0214
0215
0216 const size_t NFS_MaxLineSize = 128;
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237 #define __TBB_atomic
0238
0239 #if __TBB_OVERRIDE_PRESENT
0240 #define __TBB_override override
0241 #else
0242 #define __TBB_override
0243 #endif
0244
0245 #if __TBB_CPP17_FALLTHROUGH_PRESENT
0246 #define __TBB_fallthrough [[fallthrough]]
0247 #elif __TBB_FALLTHROUGH_PRESENT
0248 #define __TBB_fallthrough __attribute__ ((fallthrough))
0249 #else
0250 #define __TBB_fallthrough
0251 #endif
0252
0253 template<class T, size_t S, size_t R>
0254 struct padded_base : T {
0255 char pad[S - R];
0256 };
0257 template<class T, size_t S> struct padded_base<T, S, 0> : T {};
0258
0259
0260 template<class T, size_t S = NFS_MaxLineSize>
0261 struct padded : padded_base<T, S, sizeof(T) % S> {};
0262
0263
0264
0265
0266 #define __TBB_offsetof(class_name, member_name) \
0267 ((ptrdiff_t)&(reinterpret_cast<class_name*>(0x1000)->member_name) - 0x1000)
0268
0269
0270 #define __TBB_get_object_ref(class_name, member_name, member_addr) \
0271 (*reinterpret_cast<class_name*>((char*)member_addr - __TBB_offsetof(class_name, member_name)))
0272
0273
0274 void __TBB_EXPORTED_FUNC handle_perror( int error_code, const char* aux_info );
0275
0276 #if TBB_USE_EXCEPTIONS
0277 #define __TBB_TRY try
0278 #define __TBB_CATCH(e) catch(e)
0279 #define __TBB_THROW(e) throw e
0280 #define __TBB_RETHROW() throw
0281 #else
0282 inline bool __TBB_false() { return false; }
0283 #define __TBB_TRY
0284 #define __TBB_CATCH(e) if ( tbb::internal::__TBB_false() )
0285 #define __TBB_THROW(e) tbb::internal::suppress_unused_warning(e)
0286 #define __TBB_RETHROW() ((void)0)
0287 #endif
0288
0289
0290 void __TBB_EXPORTED_FUNC runtime_warning( const char* format, ... );
0291
0292 #if TBB_USE_ASSERT
0293 static void* const poisoned_ptr = reinterpret_cast<void*>(-1);
0294
0295
0296
0297 template<typename T>
0298 inline void poison_pointer( T* __TBB_atomic & p ) { p = reinterpret_cast<T*>(poisoned_ptr); }
0299
0300
0301 template<typename T>
0302 inline bool is_poisoned( T* p ) { return p == reinterpret_cast<T*>(poisoned_ptr); }
0303 #else
0304 template<typename T>
0305 inline void poison_pointer( T* __TBB_atomic & ) {}
0306 #endif
0307
0308
0309
0310
0311
0312
0313 template<typename T, typename U>
0314 inline T punned_cast( U* ptr ) {
0315 uintptr_t x = reinterpret_cast<uintptr_t>(ptr);
0316 return reinterpret_cast<T>(x);
0317 }
0318
0319 #if __TBB_DEFAULTED_AND_DELETED_FUNC_PRESENT
0320
0321
0322 class no_assign {
0323 public:
0324 void operator=( const no_assign& ) = delete;
0325 no_assign( const no_assign& ) = default;
0326 no_assign() = default;
0327 };
0328
0329
0330 class no_copy: no_assign {
0331 public:
0332 no_copy( const no_copy& ) = delete;
0333 no_copy() = default;
0334 };
0335
0336 #else
0337
0338
0339 class no_assign {
0340
0341 void operator=( const no_assign& );
0342 public:
0343 #if __GNUC__
0344
0345 no_assign() {}
0346 #endif
0347 };
0348
0349
0350 class no_copy: no_assign {
0351
0352 no_copy( const no_copy& );
0353 public:
0354
0355 no_copy() {}
0356 };
0357
0358 #endif
0359
0360 #if TBB_DEPRECATED_MUTEX_COPYING
0361 class mutex_copy_deprecated_and_disabled {};
0362 #else
0363
0364
0365 class mutex_copy_deprecated_and_disabled : no_copy {};
0366 #endif
0367
0368
0369 template<typename T>
0370 inline bool is_aligned(T* pointer, uintptr_t alignment) {
0371 return 0==((uintptr_t)pointer & (alignment-1));
0372 }
0373
0374
0375 template<typename integer_type>
0376 inline bool is_power_of_two(integer_type arg) {
0377 return arg && (0 == (arg & (arg - 1)));
0378 }
0379
0380
0381 template<typename argument_integer_type, typename divisor_integer_type>
0382 inline argument_integer_type modulo_power_of_two(argument_integer_type arg, divisor_integer_type divisor) {
0383 __TBB_ASSERT( is_power_of_two(divisor), "Divisor should be a power of two" );
0384 return (arg & (divisor - 1));
0385 }
0386
0387
0388
0389
0390
0391 template<typename argument_integer_type, typename power2_integer_type>
0392 inline bool is_power_of_two_at_least(argument_integer_type arg, power2_integer_type power2) {
0393 __TBB_ASSERT( is_power_of_two(power2), "Divisor should be a power of two" );
0394 return 0 == (arg & (arg - power2));
0395 }
0396
0397
0398 template<typename T1> void suppress_unused_warning( const T1& ) {}
0399 template<typename T1, typename T2> void suppress_unused_warning( const T1&, const T2& ) {}
0400 template<typename T1, typename T2, typename T3> void suppress_unused_warning( const T1&, const T2&, const T3& ) {}
0401
0402
0403
0404
0405 struct version_tag_v3 {};
0406
0407 typedef version_tag_v3 version_tag;
0408
0409 }
0410
0411
0412
0413
0414
0415
0416 class split {
0417 };
0418
0419
0420
0421
0422
0423
0424
0425
0426 class proportional_split: internal::no_assign {
0427 public:
0428 proportional_split(size_t _left = 1, size_t _right = 1) : my_left(_left), my_right(_right) { }
0429
0430 size_t left() const { return my_left; }
0431 size_t right() const { return my_right; }
0432
0433
0434 operator split() const { return split(); }
0435
0436 #if __TBB_ENABLE_RANGE_FEEDBACK
0437 void set_proportion(size_t _left, size_t _right) {
0438 my_left = _left;
0439 my_right = _right;
0440 }
0441 #endif
0442 private:
0443 size_t my_left, my_right;
0444 };
0445
0446 }
0447
0448
0449
0450
0451 #if __TBB_CPP11_SMART_POINTERS_PRESENT
0452 #include <memory> // for unique_ptr
0453 #endif
0454
0455 #if __TBB_CPP11_RVALUE_REF_PRESENT || __TBB_CPP11_DECLTYPE_PRESENT || _LIBCPP_VERSION
0456 #include <utility> // for std::move, std::forward, std::declval
0457 #endif
0458
0459 namespace tbb {
0460 namespace internal {
0461
0462 #if __TBB_CPP11_SMART_POINTERS_PRESENT && __TBB_CPP11_RVALUE_REF_PRESENT && __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT
0463 template<typename T, typename... Args>
0464 std::unique_ptr<T> make_unique(Args&&... args) {
0465 return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
0466 }
0467 #endif
0468
0469
0470 template<typename T>
0471 struct allocator_type {
0472 typedef T value_type;
0473 };
0474
0475 #if _MSC_VER
0476
0477 template<typename T>
0478 struct allocator_type<const T> {
0479 typedef T value_type;
0480 };
0481 #endif
0482
0483
0484
0485 template <bool v>
0486 struct bool_constant {
0487 static const bool value = v;
0488 };
0489 typedef bool_constant<true> true_type;
0490 typedef bool_constant<false> false_type;
0491
0492
0493 template <unsigned u, unsigned long long ull >
0494 struct select_size_t_constant {
0495
0496
0497 static const size_t value = (size_t)((sizeof(size_t)==sizeof(u)) ? u : ull);
0498 };
0499
0500 #if __TBB_CPP11_RVALUE_REF_PRESENT
0501 using std::move;
0502 using std::forward;
0503 #elif defined(_LIBCPP_NAMESPACE)
0504
0505 using std::_LIBCPP_NAMESPACE::move;
0506 using std::_LIBCPP_NAMESPACE::forward;
0507 #else
0508
0509 template <typename T>
0510 T& move( T& x ) { return x; }
0511 template <typename T>
0512 T& forward( T& x ) { return x; }
0513 #endif
0514
0515
0516 #if __TBB_CPP11_RVALUE_REF_PRESENT
0517 #define __TBB_FORWARDING_REF(A) A&&
0518 #else
0519
0520
0521 #define __TBB_FORWARDING_REF(A) A&
0522 #endif
0523 #if __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT
0524 #define __TBB_PARAMETER_PACK ...
0525 #define __TBB_PACK_EXPANSION(A) A...
0526 #else
0527 #define __TBB_PARAMETER_PACK
0528 #define __TBB_PACK_EXPANSION(A) A
0529 #endif
0530
0531 #if __TBB_CPP11_DECLTYPE_PRESENT
0532 #if __TBB_CPP11_DECLVAL_BROKEN
0533
0534 template <class T> __TBB_FORWARDING_REF(T) declval() ;
0535 #else
0536 using std::declval;
0537 #endif
0538 #endif
0539
0540 template <bool condition>
0541 struct STATIC_ASSERTION_FAILED;
0542
0543 template <>
0544 struct STATIC_ASSERTION_FAILED<false> { enum {value=1};};
0545
0546 template<>
0547 struct STATIC_ASSERTION_FAILED<true>;
0548
0549
0550 }}
0551
0552 #if __TBB_STATIC_ASSERT_PRESENT
0553 #define __TBB_STATIC_ASSERT(condition,msg) static_assert(condition,msg)
0554 #else
0555
0556 #define __TBB_STATIC_ASSERT_IMPL1(condition,msg,line) \
0557 enum {static_assert_on_line_##line = tbb::internal::STATIC_ASSERTION_FAILED<!(condition)>::value}
0558
0559 #define __TBB_STATIC_ASSERT_IMPL(condition,msg,line) __TBB_STATIC_ASSERT_IMPL1(condition,msg,line)
0560
0561 #define __TBB_STATIC_ASSERT(condition,msg) __TBB_STATIC_ASSERT_IMPL(condition,msg,__LINE__)
0562 #endif
0563
0564 #endif
0565 #endif