js/src/vtune/ittnotify_config.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /*
     2   This file is provided under a dual BSD/GPLv2 license.  When using or
     3   redistributing this file, you may do so under either license.
     5   GPL LICENSE SUMMARY
     7   Copyright (c) 2005-2012 Intel Corporation. All rights reserved.
     9   This program is free software; you can redistribute it and/or modify
    10   it under the terms of version 2 of the GNU General Public License as
    11   published by the Free Software Foundation.
    13   This program is distributed in the hope that it will be useful, but
    14   WITHOUT ANY WARRANTY; without even the implied warranty of
    15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    16   General Public License for more details.
    18   You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
    21   The full GNU General Public License is included in this distribution
    22   in the file called LICENSE.GPL.
    24   Contact Information:
    25   http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
    27   BSD LICENSE
    29   Copyright (c) 2005-2012 Intel Corporation. All rights reserved.
    30   All rights reserved.
    32   Redistribution and use in source and binary forms, with or without
    33   modification, are permitted provided that the following conditions
    34   are met:
    36     * Redistributions of source code must retain the above copyright
    37       notice, this list of conditions and the following disclaimer.
    38     * Redistributions in binary form must reproduce the above copyright
    39       notice, this list of conditions and the following disclaimer in
    40       the documentation and/or other materials provided with the
    41       distribution.
    42     * Neither the name of Intel Corporation nor the names of its
    43       contributors may be used to endorse or promote products derived
    44       from this software without specific prior written permission.
    46   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    47   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    48   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    49   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    50   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    51   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    52   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    53   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    54   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    55   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    56   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    57 */
    58 #ifndef _ITTNOTIFY_CONFIG_H_
    59 #define _ITTNOTIFY_CONFIG_H_
    61 /** @cond exclude_from_documentation */
    62 #ifndef ITT_OS_WIN
    63 #  define ITT_OS_WIN   1
    64 #endif /* ITT_OS_WIN */
    66 #ifndef ITT_OS_LINUX
    67 #  define ITT_OS_LINUX 2
    68 #endif /* ITT_OS_LINUX */
    70 #ifndef ITT_OS_MAC
    71 #  define ITT_OS_MAC   3
    72 #endif /* ITT_OS_MAC */
    74 #ifndef ITT_OS
    75 #  if defined WIN32 || defined _WIN32
    76 #    define ITT_OS ITT_OS_WIN
    77 #  elif defined( __APPLE__ ) && defined( __MACH__ )
    78 #    define ITT_OS ITT_OS_MAC
    79 #  else
    80 #    define ITT_OS ITT_OS_LINUX
    81 #  endif
    82 #endif /* ITT_OS */
    84 #ifndef ITT_PLATFORM_WIN
    85 #  define ITT_PLATFORM_WIN 1
    86 #endif /* ITT_PLATFORM_WIN */
    88 #ifndef ITT_PLATFORM_POSIX
    89 #  define ITT_PLATFORM_POSIX 2
    90 #endif /* ITT_PLATFORM_POSIX */
    92 #ifndef ITT_PLATFORM
    93 #  if ITT_OS==ITT_OS_WIN
    94 #    define ITT_PLATFORM ITT_PLATFORM_WIN
    95 #  else
    96 #    define ITT_PLATFORM ITT_PLATFORM_POSIX
    97 #  endif /* _WIN32 */
    98 #endif /* ITT_PLATFORM */
   100 #if defined(_UNICODE) && !defined(UNICODE)
   101 #define UNICODE
   102 #endif
   104 #include <stddef.h>
   105 #if ITT_PLATFORM==ITT_PLATFORM_WIN
   106 #include <tchar.h>
   107 #else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   108 #include <stdint.h>
   109 #if defined(UNICODE) || defined(_UNICODE)
   110 #include <wchar.h>
   111 #endif /* UNICODE || _UNICODE */
   112 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   114 #ifndef CDECL
   115 #  if ITT_PLATFORM==ITT_PLATFORM_WIN
   116 #    define CDECL __cdecl
   117 #  else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   118 #    if defined _M_X64 || defined _M_AMD64 || defined __x86_64__
   119 #      define CDECL /* not actual on x86_64 platform */
   120 #    else  /* _M_X64 || _M_AMD64 || __x86_64__ */
   121 #      define CDECL __attribute__ ((cdecl))
   122 #    endif /* _M_X64 || _M_AMD64 || __x86_64__ */
   123 #  endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   124 #endif /* CDECL */
   126 #ifndef STDCALL
   127 #  if ITT_PLATFORM==ITT_PLATFORM_WIN
   128 #    define STDCALL __stdcall
   129 #  else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   130 #    if defined _M_X64 || defined _M_AMD64 || defined __x86_64__
   131 #      define STDCALL /* not supported on x86_64 platform */
   132 #    else  /* _M_X64 || _M_AMD64 || __x86_64__ */
   133 #      define STDCALL __attribute__ ((stdcall))
   134 #    endif /* _M_X64 || _M_AMD64 || __x86_64__ */
   135 #  endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   136 #endif /* STDCALL */
   138 #define ITTAPI    CDECL
   139 #define LIBITTAPI CDECL
   141 /* TODO: Temporary for compatibility! */
   142 #define ITTAPI_CALL    CDECL
   143 #define LIBITTAPI_CALL CDECL
   145 #if ITT_PLATFORM==ITT_PLATFORM_WIN
   146 /* use __forceinline (VC++ specific) */
   147 #define ITT_INLINE           __forceinline
   148 #define ITT_INLINE_ATTRIBUTE /* nothing */
   149 #else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   150 /*
   151  * Generally, functions are not inlined unless optimization is specified.
   152  * For functions declared inline, this attribute inlines the function even
   153  * if no optimization level was specified.
   154  */
   155 #ifdef __STRICT_ANSI__
   156 #define ITT_INLINE           static
   157 #else  /* __STRICT_ANSI__ */
   158 #define ITT_INLINE           static inline
   159 #endif /* __STRICT_ANSI__ */
   160 #define ITT_INLINE_ATTRIBUTE __attribute__ ((always_inline))
   161 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   162 /** @endcond */
   164 #ifndef ITT_ARCH_IA32
   165 #  define ITT_ARCH_IA32  1
   166 #endif /* ITT_ARCH_IA32 */
   168 #ifndef ITT_ARCH_IA32E
   169 #  define ITT_ARCH_IA32E 2
   170 #endif /* ITT_ARCH_IA32E */
   172 #ifndef ITT_ARCH_IA64
   173 #  define ITT_ARCH_IA64  3
   174 #endif /* ITT_ARCH_IA64 */
   176 #ifndef ITT_ARCH
   177 #  if defined _M_X64 || defined _M_AMD64 || defined __x86_64__
   178 #    define ITT_ARCH ITT_ARCH_IA32E
   179 #  elif defined _M_IA64 || defined __ia64
   180 #    define ITT_ARCH ITT_ARCH_IA64
   181 #  else
   182 #    define ITT_ARCH ITT_ARCH_IA32
   183 #  endif
   184 #endif
   186 #ifdef __cplusplus
   187 #  define ITT_EXTERN_C extern "C"
   188 #else
   189 #  define ITT_EXTERN_C /* nothing */
   190 #endif /* __cplusplus */
   192 #define ITT_TO_STR_AUX(x) #x
   193 #define ITT_TO_STR(x)     ITT_TO_STR_AUX(x)
   195 #define __ITT_BUILD_ASSERT(expr, suffix) do { \
   196     static char __itt_build_check_##suffix[(expr) ? 1 : -1]; \
   197     __itt_build_check_##suffix[0] = 0; \
   198 } while(0)
   199 #define _ITT_BUILD_ASSERT(expr, suffix)  __ITT_BUILD_ASSERT((expr), suffix)
   200 #define ITT_BUILD_ASSERT(expr)           _ITT_BUILD_ASSERT((expr), __LINE__)
   202 #define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 }
   204 /* Replace with snapshot date YYYYMMDD for promotion build. */
   205 #define API_VERSION_BUILD    20111111
   207 #ifndef API_VERSION_NUM
   208 #define API_VERSION_NUM 0.0.0
   209 #endif /* API_VERSION_NUM */
   211 #define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \
   212                                 " (" ITT_TO_STR(API_VERSION_BUILD) ")"
   214 /* OS communication functions */
   215 #if ITT_PLATFORM==ITT_PLATFORM_WIN
   216 #include <windows.h>
   217 typedef HMODULE           lib_t;
   218 typedef DWORD             TIDT;
   219 typedef CRITICAL_SECTION  mutex_t;
   220 #define MUTEX_INITIALIZER { 0 }
   221 #define strong_alias(name, aliasname) /* empty for Windows */
   222 #else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   223 #include <dlfcn.h>
   224 #if defined(UNICODE) || defined(_UNICODE)
   225 #include <wchar.h>
   226 #endif /* UNICODE */
   227 #ifndef _GNU_SOURCE
   228 #define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */
   229 #endif /* _GNU_SOURCE */
   230 #include <pthread.h>
   231 typedef void*             lib_t;
   232 typedef pthread_t         TIDT;
   233 typedef pthread_mutex_t   mutex_t;
   234 #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
   235 #define _strong_alias(name, aliasname) \
   236             extern __typeof (name) aliasname __attribute__ ((alias (#name)));
   237 #define strong_alias(name, aliasname) _strong_alias(name, aliasname)
   238 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   240 #if ITT_PLATFORM==ITT_PLATFORM_WIN
   241 #define __itt_get_proc(lib, name) GetProcAddress(lib, name)
   242 #define __itt_mutex_init(mutex)   InitializeCriticalSection(mutex)
   243 #define __itt_mutex_lock(mutex)   EnterCriticalSection(mutex)
   244 #define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex)
   245 #define __itt_load_lib(name)      LoadLibraryA(name)
   246 #define __itt_unload_lib(handle)  FreeLibrary(handle)
   247 #define __itt_system_error()      (int)GetLastError()
   248 #define __itt_fstrcmp(s1, s2)     lstrcmpA(s1, s2)
   249 #define __itt_fstrlen(s)          lstrlenA(s)
   250 #define __itt_fstrcpyn(s1, s2, l) lstrcpynA(s1, s2, l)
   251 #define __itt_fstrdup(s)          _strdup(s)
   252 #define __itt_thread_id()         GetCurrentThreadId()
   253 #define __itt_thread_yield()      SwitchToThread()
   254 #ifndef ITT_SIMPLE_INIT
   255 ITT_INLINE long
   256 __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE;
   257 ITT_INLINE long __itt_interlocked_increment(volatile long* ptr)
   258 {
   259     return InterlockedIncrement(ptr);
   260 }
   261 #endif /* ITT_SIMPLE_INIT */
   262 #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */
   263 #define __itt_get_proc(lib, name) dlsym(lib, name)
   264 #define __itt_mutex_init(mutex)   {\
   265     pthread_mutexattr_t mutex_attr;                                         \
   266     int error_code = pthread_mutexattr_init(&mutex_attr);                   \
   267     if (error_code)                                                         \
   268         __itt_report_error(__itt_error_system, "pthread_mutexattr_init",    \
   269                            error_code);                                     \
   270     error_code = pthread_mutexattr_settype(&mutex_attr,                     \
   271                                            PTHREAD_MUTEX_RECURSIVE);        \
   272     if (error_code)                                                         \
   273         __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", \
   274                            error_code);                                     \
   275     error_code = pthread_mutex_init(mutex, &mutex_attr);                    \
   276     if (error_code)                                                         \
   277         __itt_report_error(__itt_error_system, "pthread_mutex_init",        \
   278                            error_code);                                     \
   279     error_code = pthread_mutexattr_destroy(&mutex_attr);                    \
   280     if (error_code)                                                         \
   281         __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", \
   282                            error_code);                                     \
   283 }
   284 #define __itt_mutex_lock(mutex)   pthread_mutex_lock(mutex)
   285 #define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex)
   286 #define __itt_load_lib(name)      dlopen(name, RTLD_LAZY)
   287 #define __itt_unload_lib(handle)  dlclose(handle)
   288 #define __itt_system_error()      errno
   289 #define __itt_fstrcmp(s1, s2)     strcmp(s1, s2)
   290 #define __itt_fstrlen(s)          strlen(s)
   291 #define __itt_fstrcpyn(s1, s2, l) strncpy(s1, s2, l)
   292 #define __itt_fstrdup(s)          strdup(s)
   293 #define __itt_thread_id()         pthread_self()
   294 #define __itt_thread_yield()      sched_yield()
   295 #if ITT_ARCH==ITT_ARCH_IA64
   296 #ifdef __INTEL_COMPILER
   297 #define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val)
   298 #else  /* __INTEL_COMPILER */
   299 /* TODO: Add Support for not Intel compilers for IA64 */
   300 #endif /* __INTEL_COMPILER */
   301 #else /* ITT_ARCH!=ITT_ARCH_IA64 */
   302 ITT_INLINE long
   303 __TBB_machine_fetchadd4(volatile void* ptr, long addend) ITT_INLINE_ATTRIBUTE;
   304 ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend)
   305 {
   306     long result;
   307     __asm__ __volatile__("lock\nxadd %0,%1"
   308                           : "=r"(result),"=m"(*(long*)ptr)
   309                           : "0"(addend), "m"(*(long*)ptr)
   310                           : "memory");
   311     return result;
   312 }
   313 #endif /* ITT_ARCH==ITT_ARCH_IA64 */
   314 #ifndef ITT_SIMPLE_INIT
   315 ITT_INLINE long
   316 __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE;
   317 ITT_INLINE long __itt_interlocked_increment(volatile long* ptr)
   318 {
   319     return __TBB_machine_fetchadd4(ptr, 1) + 1L;
   320 }
   321 #endif /* ITT_SIMPLE_INIT */
   322 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
   324 typedef enum {
   325     __itt_collection_normal = 0,
   326     __itt_collection_paused = 1
   327 } __itt_collection_state;
   329 typedef enum {
   330     __itt_thread_normal  = 0,
   331     __itt_thread_ignored = 1
   332 } __itt_thread_state;
   334 #pragma pack(push, 8)
   336 typedef struct ___itt_thread_info
   337 {
   338     const char* nameA; /*!< Copy of original name in ASCII. */
   339 #if defined(UNICODE) || defined(_UNICODE)
   340     const wchar_t* nameW; /*!< Copy of original name in UNICODE. */
   341 #else  /* UNICODE || _UNICODE */
   342     void* nameW;
   343 #endif /* UNICODE || _UNICODE */
   344     TIDT               tid;
   345     __itt_thread_state state;   /*!< Thread state (paused or normal) */
   346     int                extra1;  /*!< Reserved to the runtime */
   347     void*              extra2;  /*!< Reserved to the runtime */
   348     struct ___itt_thread_info* next;
   349 } __itt_thread_info;
   351 #include "ittnotify_types.h" /* For __itt_group_id definition */
   353 typedef struct ___itt_api_info_20101001
   354 {
   355     const char*    name;
   356     void**         func_ptr;
   357     void*          init_func;
   358     __itt_group_id group;
   359 }  __itt_api_info_20101001;
   361 typedef struct ___itt_api_info
   362 {
   363     const char*    name;
   364     void**         func_ptr;
   365     void*          init_func;
   366     void*          null_func;
   367     __itt_group_id group;
   368 }  __itt_api_info;
   370 struct ___itt_domain;
   371 struct ___itt_string_handle;
   373 typedef struct ___itt_global
   374 {
   375     unsigned char          magic[8];
   376     unsigned long          version_major;
   377     unsigned long          version_minor;
   378     unsigned long          version_build;
   379     volatile long          api_initialized;
   380     volatile long          mutex_initialized;
   381     volatile long          atomic_counter;
   382     mutex_t                mutex;
   383     lib_t                  lib;
   384     void*                  error_handler;
   385     const char**           dll_path_ptr;
   386     __itt_api_info*        api_list_ptr;
   387     struct ___itt_global*  next;
   388     /* Joinable structures below */
   389     __itt_thread_info*     thread_list;
   390     struct ___itt_domain*  domain_list;
   391     struct ___itt_string_handle* string_list;
   392     __itt_collection_state state;
   393 } __itt_global;
   395 #pragma pack(pop)
   397 #define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \
   398     h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \
   399     if (h != NULL) { \
   400         h->tid    = t; \
   401         h->nameA  = NULL; \
   402         h->nameW  = n ? _wcsdup(n) : NULL; \
   403         h->state  = s; \
   404         h->extra1 = 0;    /* reserved */ \
   405         h->extra2 = NULL; /* reserved */ \
   406         h->next   = NULL; \
   407         if (h_tail == NULL) \
   408             (gptr)->thread_list = h; \
   409         else \
   410             h_tail->next = h; \
   411     } \
   412 }
   414 #define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \
   415     h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \
   416     if (h != NULL) { \
   417         h->tid    = t; \
   418         h->nameA  = n ? __itt_fstrdup(n) : NULL; \
   419         h->nameW  = NULL; \
   420         h->state  = s; \
   421         h->extra1 = 0;    /* reserved */ \
   422         h->extra2 = NULL; /* reserved */ \
   423         h->next   = NULL; \
   424         if (h_tail == NULL) \
   425             (gptr)->thread_list = h; \
   426         else \
   427             h_tail->next = h; \
   428     } \
   429 }
   431 #define NEW_DOMAIN_W(gptr,h,h_tail,name) { \
   432     h = (__itt_domain*)malloc(sizeof(__itt_domain)); \
   433     if (h != NULL) { \
   434         h->flags  = 0;    /* domain is disabled by default */ \
   435         h->nameA  = NULL; \
   436         h->nameW  = name ? _wcsdup(name) : NULL; \
   437         h->extra1 = 0;    /* reserved */ \
   438         h->extra2 = NULL; /* reserved */ \
   439         h->next   = NULL; \
   440         if (h_tail == NULL) \
   441             (gptr)->domain_list = h; \
   442         else \
   443             h_tail->next = h; \
   444     } \
   445 }
   447 #define NEW_DOMAIN_A(gptr,h,h_tail,name) { \
   448     h = (__itt_domain*)malloc(sizeof(__itt_domain)); \
   449     if (h != NULL) { \
   450         h->flags  = 0;    /* domain is disabled by default */ \
   451         h->nameA  = name ? __itt_fstrdup(name) : NULL; \
   452         h->nameW  = NULL; \
   453         h->extra1 = 0;    /* reserved */ \
   454         h->extra2 = NULL; /* reserved */ \
   455         h->next   = NULL; \
   456         if (h_tail == NULL) \
   457             (gptr)->domain_list = h; \
   458         else \
   459             h_tail->next = h; \
   460     } \
   461 }
   463 #define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \
   464     h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \
   465     if (h != NULL) { \
   466         h->strA   = NULL; \
   467         h->strW   = name ? _wcsdup(name) : NULL; \
   468         h->extra1 = 0;    /* reserved */ \
   469         h->extra2 = NULL; /* reserved */ \
   470         h->next   = NULL; \
   471         if (h_tail == NULL) \
   472             (gptr)->string_list = h; \
   473         else \
   474             h_tail->next = h; \
   475     } \
   476 }
   478 #define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \
   479     h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \
   480     if (h != NULL) { \
   481         h->strA   = name ? __itt_fstrdup(name) : NULL; \
   482         h->strW   = NULL; \
   483         h->extra1 = 0;    /* reserved */ \
   484         h->extra2 = NULL; /* reserved */ \
   485         h->next   = NULL; \
   486         if (h_tail == NULL) \
   487             (gptr)->string_list = h; \
   488         else \
   489             h_tail->next = h; \
   490     } \
   491 }
   493 #endif /* _ITTNOTIFY_CONFIG_H_ */

mercurial