tbb_stddef.h

00001 /*
00002     Copyright 2005-2013 Intel Corporation.  All Rights Reserved.
00003 
00004     The source code contained or described herein and all documents related
00005     to the source code ("Material") are owned by Intel Corporation or its
00006     suppliers or licensors.  Title to the Material remains with Intel
00007     Corporation or its suppliers and licensors.  The Material is protected
00008     by worldwide copyright laws and treaty provisions.  No part of the
00009     Material may be used, copied, reproduced, modified, published, uploaded,
00010     posted, transmitted, distributed, or disclosed in any way without
00011     Intel's prior express written permission.
00012 
00013     No license under any patent, copyright, trade secret or other
00014     intellectual property right is granted to or conferred upon you by
00015     disclosure or delivery of the Materials, either expressly, by
00016     implication, inducement, estoppel or otherwise.  Any license under such
00017     intellectual property rights must be express and approved by Intel in
00018     writing.
00019 */
00020 
00021 #ifndef __TBB_tbb_stddef_H
00022 #define __TBB_tbb_stddef_H
00023 
00024 // Marketing-driven product version
00025 #define TBB_VERSION_MAJOR 4
00026 #define TBB_VERSION_MINOR 1
00027 
00028 // Engineering-focused interface version
00029 #define TBB_INTERFACE_VERSION 6102
00030 #define TBB_INTERFACE_VERSION_MAJOR TBB_INTERFACE_VERSION/1000
00031 
00032 // The oldest major interface version still supported
00033 // To be used in SONAME, manifests, etc.
00034 #define TBB_COMPATIBLE_INTERFACE_VERSION 2
00035 
00036 #define __TBB_STRING_AUX(x) #x
00037 #define __TBB_STRING(x) __TBB_STRING_AUX(x)
00038 
00039 // We do not need defines below for resource processing on windows
00040 #if !defined RC_INVOKED
00041 
00042 // Define groups for Doxygen documentation
00052 // Simple text that is displayed on the main page of Doxygen documentation.
00094 // tbb_config.h should be included the first since it contains macro definitions used in other headers
00095 #include "tbb_config.h"
00096 
00097 #if _MSC_VER >=1400
00098     #define __TBB_EXPORTED_FUNC   __cdecl
00099     #define __TBB_EXPORTED_METHOD __thiscall
00100 #else
00101     #define __TBB_EXPORTED_FUNC
00102     #define __TBB_EXPORTED_METHOD
00103 #endif
00104 
00105 #if __INTEL_COMPILER || _MSC_VER
00106 #define __TBB_NOINLINE(decl) __declspec(noinline) decl
00107 #elif __GNUC__
00108 #define __TBB_NOINLINE(decl) decl __attribute__ ((noinline))
00109 #else
00110 #define __TBB_NOINLINE(decl) decl
00111 #endif
00112 
00113 #include <cstddef>      /* Need size_t and ptrdiff_t */
00114 
00115 #if _MSC_VER
00116     #define __TBB_tbb_windef_H
00117     #include "internal/_tbb_windef.h"
00118     #undef __TBB_tbb_windef_H
00119 #endif
00120 #if !defined(_MSC_VER) || _MSC_VER>=1600
00121     #include <stdint.h>
00122 #endif
00123 
00125 typedef void(*assertion_handler_type)( const char* filename, int line, const char* expression, const char * comment );
00126 
00127 #if TBB_USE_ASSERT
00128 
00129      #define __TBB_ASSERT_NS(predicate,message,ns) ((predicate)?((void)0) : ns::assertion_failure(__FILE__,__LINE__,#predicate,message))
00131 
00134 #if __TBBMALLOC_BUILD
00135 namespace rml { namespace internal {
00136     #define __TBB_ASSERT(predicate,message) __TBB_ASSERT_NS(predicate,message,rml::internal)
00137 #else
00138 namespace tbb {
00139     #define __TBB_ASSERT(predicate,message) __TBB_ASSERT_NS(predicate,message,tbb)
00140 #endif
00141 
00142     #define __TBB_ASSERT_EX __TBB_ASSERT
00143 
00145     assertion_handler_type __TBB_EXPORTED_FUNC set_assertion_handler( assertion_handler_type new_handler );
00146 
00148 
00151     void __TBB_EXPORTED_FUNC assertion_failure( const char* filename, int line, const char* expression, const char* comment );
00152 
00153 #if __TBBMALLOC_BUILD
00154 }}  // namespace rml::internal
00155 #else
00156 } // namespace tbb
00157 #endif
00158 #else /* !TBB_USE_ASSERT */
00159 
00161     #define __TBB_ASSERT(predicate,comment) ((void)0)
00163     #define __TBB_ASSERT_EX(predicate,comment) ((void)(1 && (predicate)))
00164 
00165 #endif /* !TBB_USE_ASSERT */
00166 
00168 namespace tbb {
00169 
00170 #if _MSC_VER && _MSC_VER<1600
00171     namespace internal {
00172         typedef __int8 int8_t;
00173         typedef __int16 int16_t;
00174         typedef __int32 int32_t;
00175         typedef __int64 int64_t;
00176         typedef unsigned __int8 uint8_t;
00177         typedef unsigned __int16 uint16_t;
00178         typedef unsigned __int32 uint32_t;
00179         typedef unsigned __int64 uint64_t;
00180     } // namespace internal
00181 #else /* Posix */
00182     namespace internal {
00183         using ::int8_t;
00184         using ::int16_t;
00185         using ::int32_t;
00186         using ::int64_t;
00187         using ::uint8_t;
00188         using ::uint16_t;
00189         using ::uint32_t;
00190         using ::uint64_t;
00191     } // namespace internal
00192 #endif /* Posix */
00193 
00194     using std::size_t;
00195     using std::ptrdiff_t;
00196 
00198 
00202 extern "C" int __TBB_EXPORTED_FUNC TBB_runtime_interface_version();
00203 
00205 
00209 class split {
00210 };
00211 
00216 namespace internal {
00217 
00219 
00222 const size_t NFS_MaxLineSize = 128;
00223 
00243 #define __TBB_atomic // intentionally empty, see above
00244 
00245 template<class T, int S>
00246 struct padded_base : T {
00247     char pad[NFS_MaxLineSize - sizeof(T) % NFS_MaxLineSize];
00248 };
00249 template<class T> struct padded_base<T, 0> : T {};
00250 
00252 template<class T>
00253 struct padded : padded_base<T, sizeof(T)> {};
00254 
00256 
00258 #define __TBB_offsetof(class_name, member_name) \
00259     ((ptrdiff_t)&(reinterpret_cast<class_name*>(0x1000)->member_name) - 0x1000)
00260 
00262 #define __TBB_get_object_ref(class_name, member_name, member_addr) \
00263     (*reinterpret_cast<class_name*>((char*)member_addr - __TBB_offsetof(class_name, member_name)))
00264 
00266 void __TBB_EXPORTED_FUNC handle_perror( int error_code, const char* aux_info );
00267 
00268 #if TBB_USE_EXCEPTIONS
00269     #define __TBB_TRY try
00270     #define __TBB_CATCH(e) catch(e)
00271     #define __TBB_THROW(e) throw e
00272     #define __TBB_RETHROW() throw
00273 #else /* !TBB_USE_EXCEPTIONS */
00274     inline bool __TBB_false() { return false; }
00275     #define __TBB_TRY
00276     #define __TBB_CATCH(e) if ( tbb::internal::__TBB_false() )
00277     #define __TBB_THROW(e) ((void)0)
00278     #define __TBB_RETHROW() ((void)0)
00279 #endif /* !TBB_USE_EXCEPTIONS */
00280 
00282 void __TBB_EXPORTED_FUNC runtime_warning( const char* format, ... );
00283 
00284 #if TBB_USE_ASSERT
00285 static void* const poisoned_ptr = reinterpret_cast<void*>(-1);
00286 
00288 template<typename T>
00289 inline void poison_pointer( T*& p ) { p = reinterpret_cast<T*>(poisoned_ptr); }
00290 
00292 template<typename T>
00293 inline bool is_poisoned( T* p ) { return p == reinterpret_cast<T*>(poisoned_ptr); }
00294 #else
00295 template<typename T>
00296 inline void poison_pointer( T* ) {/*do nothing*/}
00297 #endif /* !TBB_USE_ASSERT */
00298 
00300 
00302 template<typename T, typename U> 
00303 inline T punned_cast( U* ptr ) {
00304     uintptr_t x = reinterpret_cast<uintptr_t>(ptr);
00305     return reinterpret_cast<T>(x);
00306 }
00307 
00309 class no_assign {
00310     // Deny assignment
00311     void operator=( const no_assign& );
00312 public:
00313 #if __GNUC__
00315     no_assign() {}
00316 #endif /* __GNUC__ */
00317 };
00318 
00320 class no_copy: no_assign {
00322     no_copy( const no_copy& );
00323 public:
00325     no_copy() {}
00326 };
00327 
00329 template<typename T>
00330 struct allocator_type {
00331     typedef T value_type;
00332 };
00333 
00334 #if _MSC_VER
00336 template<typename T>
00337 struct allocator_type<const T> {
00338     typedef T value_type;
00339 };
00340 #endif
00341 
00343 inline size_t size_t_select( unsigned u, unsigned long long ull ) {
00344     /* Explicit cast of the arguments to size_t is done to avoid compiler warnings
00345        (e.g. by Clang and MSVC) about possible truncation. The value of the right size,
00346        which is selected by ?:, is anyway not truncated or promoted.
00347        MSVC still warns if this trick is applied directly to constants, hence this function. */
00348     return (sizeof(size_t)==sizeof(u)) ? size_t(u) : size_t(ull);
00349 }
00350 
00351 template<typename T>
00352 static inline bool is_aligned(T* pointer, uintptr_t alignment) {
00353     return 0==((uintptr_t)pointer & (alignment-1));
00354 }
00355 
00356 // Struct to be used as a version tag for inline functions.
00359 struct version_tag_v3 {};
00360 
00361 typedef version_tag_v3 version_tag;
00362 
00363 } // internal
00365 
00366 } // tbb
00367 
00368 namespace tbb { namespace internal {
00369 template <bool condition>
00370 struct STATIC_ASSERTION_FAILED;
00371 
00372 template <>
00373 struct STATIC_ASSERTION_FAILED<false> { enum {value=1};};
00374 
00375 template<>
00376 struct STATIC_ASSERTION_FAILED<true>; //intentionally left undefined to cause compile time error
00377 }} // namespace tbb { namespace internal {
00378 
00379 #if    __TBB_STATIC_ASSERT_PRESENT
00380 #define __TBB_STATIC_ASSERT(condition,msg) static_assert(condition,msg)
00381 #else
00382 //please note condition is intentionally inverted to get a bit more understandable error msg
00383 #define __TBB_STATIC_ASSERT_IMPL1(condition,msg,line)       \
00384     enum {static_assert_on_line_##line = tbb::internal::STATIC_ASSERTION_FAILED<!(condition)>::value}
00385 
00386 #define __TBB_STATIC_ASSERT_IMPL(condition,msg,line) __TBB_STATIC_ASSERT_IMPL1(condition,msg,line)
00388 #define __TBB_STATIC_ASSERT(condition,msg) __TBB_STATIC_ASSERT_IMPL(condition,msg,__LINE__)
00389 #endif
00390 
00391 #endif /* RC_INVOKED */
00392 #endif /* __TBB_tbb_stddef_H */

Copyright © 2005-2013 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.