Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

tbb_profiling.h

00001 /*
00002     Copyright 2005-2008 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_profiling_H
00022 #define __TBB_profiling_H
00023 
00024 // Check if the tools support is enabled
00025 #if (_WIN32||_WIN64||__linux__) && TBB_USE_THREADING_TOOLS && __TBB_NAMING_API_SUPPORT
00026 
00027 #if _WIN32||_WIN64
00028 #include <cstdlib>  /* mbstowcs */
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     } // namespace internal
00040 } // namespace tbb
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 /* !WIN */
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 /* !WIN */
00067 
00068 #else /* no tools support */
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 /* !WIN */
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 /* !WIN */
00082 
00083 #endif /* no tools support */
00084 
00085 #endif /* __TBB_profiling_H */

Copyright © 2005-2008 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.