00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __TBB_profiling_H
00022 #define __TBB_profiling_H
00023
00024
00025 #if (_WIN32||_WIN64||__linux__) && TBB_USE_THREADING_TOOLS && __TBB_NAMING_API_SUPPORT
00026
00027 #if _WIN32||_WIN64
00028 #include <cstdlib>
00029 #endif
00030 #include "tbb/tbb_stddef.h"
00031
00032 namespace tbb {
00033 namespace internal {
00034 #if _WIN32||_WIN64
00035 void __TBB_EXPORTED_FUNC itt_set_sync_name_v3( void *obj, const wchar_t* name );
00036 #else
00037 void __TBB_EXPORTED_FUNC itt_set_sync_name_v3( void *obj, const char* name );
00038 #endif
00039 }
00040 }
00041
00043
00045 #if _WIN32||_WIN64
00046 #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \
00047 namespace profiling { \
00048 inline void set_name( sync_object_type& obj, const wchar_t* name ) { \
00049 tbb::internal::itt_set_sync_name_v3( &obj, name ); \
00050 } \
00051 inline void set_name( sync_object_type& obj, const char* name ) { \
00052 size_t len = mbstowcs(NULL, name, 0) + 1; \
00053 wchar_t *wname = new wchar_t[len]; \
00054 mbstowcs(wname, name, len); \
00055 set_name( obj, wname ); \
00056 delete wname; \
00057 } \
00058 }
00059 #else
00060 #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \
00061 namespace profiling { \
00062 inline void set_name( sync_object_type& obj, const char* name ) { \
00063 tbb::internal::itt_set_sync_name_v3( &obj, name ); \
00064 } \
00065 }
00066 #endif
00067
00068 #else
00069
00070 #if _WIN32||_WIN64
00071 #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \
00072 namespace profiling { \
00073 inline void set_name( sync_object_type&, const wchar_t* ) {} \
00074 inline void set_name( sync_object_type&, const char* ) {} \
00075 }
00076 #else
00077 #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \
00078 namespace profiling { \
00079 inline void set_name( sync_object_type&, const char* ) {} \
00080 }
00081 #endif
00082
00083 #endif
00084
00085 #endif