blob: cf221d603e76e17ba5e30144d0e59839bd3e3c7c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>tbb_profiling.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul></div>
<h1>tbb_profiling.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2010 Intel Corporation. All Rights Reserved.</span>
<a name="l00003"></a>00003 <span class="comment"></span>
<a name="l00004"></a>00004 <span class="comment"> The source code contained or described herein and all documents related</span>
<a name="l00005"></a>00005 <span class="comment"> to the source code ("Material") are owned by Intel Corporation or its</span>
<a name="l00006"></a>00006 <span class="comment"> suppliers or licensors. Title to the Material remains with Intel</span>
<a name="l00007"></a>00007 <span class="comment"> Corporation or its suppliers and licensors. The Material is protected</span>
<a name="l00008"></a>00008 <span class="comment"> by worldwide copyright laws and treaty provisions. No part of the</span>
<a name="l00009"></a>00009 <span class="comment"> Material may be used, copied, reproduced, modified, published, uploaded,</span>
<a name="l00010"></a>00010 <span class="comment"> posted, transmitted, distributed, or disclosed in any way without</span>
<a name="l00011"></a>00011 <span class="comment"> Intel's prior express written permission.</span>
<a name="l00012"></a>00012 <span class="comment"></span>
<a name="l00013"></a>00013 <span class="comment"> No license under any patent, copyright, trade secret or other</span>
<a name="l00014"></a>00014 <span class="comment"> intellectual property right is granted to or conferred upon you by</span>
<a name="l00015"></a>00015 <span class="comment"> disclosure or delivery of the Materials, either expressly, by</span>
<a name="l00016"></a>00016 <span class="comment"> implication, inducement, estoppel or otherwise. Any license under such</span>
<a name="l00017"></a>00017 <span class="comment"> intellectual property rights must be express and approved by Intel in</span>
<a name="l00018"></a>00018 <span class="comment"> writing.</span>
<a name="l00019"></a>00019 <span class="comment">*/</span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021 <span class="preprocessor">#ifndef __TBB_profiling_H</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define __TBB_profiling_H</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="comment">// Check if the tools support is enabled</span>
<a name="l00025"></a>00025 <span class="preprocessor">#if (_WIN32||_WIN64||__linux__) &amp;&amp; !__MINGW32__ &amp;&amp; TBB_USE_THREADING_TOOLS</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span>
<a name="l00027"></a>00027 <span class="preprocessor">#if _WIN32||_WIN64</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#include &lt;stdlib.h&gt;</span> <span class="comment">/* mbstowcs_s */</span>
<a name="l00029"></a>00029 <span class="preprocessor">#endif</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#include "tbb_stddef.h"</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="keyword">namespace </span>tbb {
<a name="l00033"></a>00033 <span class="keyword">namespace </span>internal {
<a name="l00034"></a>00034 <span class="preprocessor">#if _WIN32||_WIN64</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span> <span class="keywordtype">void</span> __TBB_EXPORTED_FUNC itt_set_sync_name_v3( <span class="keywordtype">void</span> *obj, <span class="keyword">const</span> <span class="keywordtype">wchar_t</span>* name );
<a name="l00036"></a>00036 <span class="keyword">inline</span> size_t multibyte_to_widechar( <span class="keywordtype">wchar_t</span>* wcs, <span class="keyword">const</span> <span class="keywordtype">char</span>* mbs, size_t bufsize) {
<a name="l00037"></a>00037 <span class="preprocessor">#if _MSC_VER&gt;=1400</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span> size_t len;
<a name="l00039"></a>00039 mbstowcs_s( &amp;len, wcs, bufsize, mbs, _TRUNCATE );
<a name="l00040"></a>00040 <span class="keywordflow">return</span> len; <span class="comment">// mbstowcs_s counts null terminator</span>
<a name="l00041"></a>00041 <span class="preprocessor">#else</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span> size_t len = mbstowcs( wcs, mbs, bufsize );
<a name="l00043"></a>00043 <span class="keywordflow">if</span>(wcs &amp;&amp; len!=size_t(-1) )
<a name="l00044"></a>00044 wcs[len&lt;bufsize-1? len: bufsize-1] = wchar_t(<span class="charliteral">'\0'</span>);
<a name="l00045"></a>00045 <span class="keywordflow">return</span> len+1; <span class="comment">// mbstowcs does not count null terminator</span>
<a name="l00046"></a>00046 <span class="preprocessor">#endif</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span> }
<a name="l00048"></a>00048 <span class="preprocessor">#else</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span> <span class="keywordtype">void</span> __TBB_EXPORTED_FUNC itt_set_sync_name_v3( <span class="keywordtype">void</span> *obj, <span class="keyword">const</span> <span class="keywordtype">char</span>* name );
<a name="l00050"></a>00050 <span class="preprocessor">#endif</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span> } <span class="comment">// namespace internal</span>
<a name="l00052"></a>00052 } <span class="comment">// namespace tbb</span>
<a name="l00053"></a>00053
<a name="l00055"></a>00055
<a name="l00057"></a>00057 <span class="preprocessor">#if _WIN32||_WIN64</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span><span class="preprocessor"> #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \</span>
<a name="l00059"></a>00059 <span class="preprocessor"> namespace profiling { \</span>
<a name="l00060"></a>00060 <span class="preprocessor"> inline void set_name( sync_object_type&amp; obj, const wchar_t* name ) { \</span>
<a name="l00061"></a>00061 <span class="preprocessor"> tbb::internal::itt_set_sync_name_v3( &amp;obj, name ); \</span>
<a name="l00062"></a>00062 <span class="preprocessor"> } \</span>
<a name="l00063"></a>00063 <span class="preprocessor"> inline void set_name( sync_object_type&amp; obj, const char* name ) { \</span>
<a name="l00064"></a>00064 <span class="preprocessor"> size_t len = tbb::internal::multibyte_to_widechar(NULL, name, 0); \</span>
<a name="l00065"></a>00065 <span class="preprocessor"> wchar_t *wname = new wchar_t[len]; \</span>
<a name="l00066"></a>00066 <span class="preprocessor"> tbb::internal::multibyte_to_widechar(wname, name, len); \</span>
<a name="l00067"></a>00067 <span class="preprocessor"> set_name( obj, wname ); \</span>
<a name="l00068"></a>00068 <span class="preprocessor"> delete[] wname; \</span>
<a name="l00069"></a>00069 <span class="preprocessor"> } \</span>
<a name="l00070"></a>00070 <span class="preprocessor"> }</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* !WIN */</span>
<a name="l00072"></a>00072 <span class="preprocessor"> #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \</span>
<a name="l00073"></a>00073 <span class="preprocessor"> namespace profiling { \</span>
<a name="l00074"></a>00074 <span class="preprocessor"> inline void set_name( sync_object_type&amp; obj, const char* name ) { \</span>
<a name="l00075"></a>00075 <span class="preprocessor"> tbb::internal::itt_set_sync_name_v3( &amp;obj, name ); \</span>
<a name="l00076"></a>00076 <span class="preprocessor"> } \</span>
<a name="l00077"></a>00077 <span class="preprocessor"> }</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !WIN */</span>
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="preprocessor">#else </span><span class="comment">/* no tools support */</span>
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="preprocessor">#if _WIN32||_WIN64</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span><span class="preprocessor"> #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \</span>
<a name="l00084"></a>00084 <span class="preprocessor"> namespace profiling { \</span>
<a name="l00085"></a>00085 <span class="preprocessor"> inline void set_name( sync_object_type&amp;, const wchar_t* ) {} \</span>
<a name="l00086"></a>00086 <span class="preprocessor"> inline void set_name( sync_object_type&amp;, const char* ) {} \</span>
<a name="l00087"></a>00087 <span class="preprocessor"> }</span>
<a name="l00088"></a>00088 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* !WIN */</span>
<a name="l00089"></a>00089 <span class="preprocessor"> #define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type) \</span>
<a name="l00090"></a>00090 <span class="preprocessor"> namespace profiling { \</span>
<a name="l00091"></a>00091 <span class="preprocessor"> inline void set_name( sync_object_type&amp;, const char* ) {} \</span>
<a name="l00092"></a>00092 <span class="preprocessor"> }</span>
<a name="l00093"></a>00093 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !WIN */</span>
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="preprocessor">#endif </span><span class="comment">/* no tools support */</span>
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="preprocessor">#endif </span><span class="comment">/* __TBB_profiling_H */</span>
</pre></div><hr>
<p></p>
Copyright &copy; 2005-2010 Intel Corporation. All Rights Reserved.
<p></p>
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.
<p></p>
* Other names and brands may be claimed as the property of others.