V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
ittnotify_config.h
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.
4 
5  GPL LICENSE SUMMARY
6 
7  Copyright(c) 2005-2012 Intel Corporation. All rights reserved.
8 
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.
12 
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.
17 
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.
23 
24  Contact Information:
25  http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
26 
27  BSD LICENSE
28 
29  Copyright(c) 2005-2012 Intel Corporation. All rights reserved.
30  All rights reserved.
31 
32  Redistribution and use in source and binary forms, with or without
33  modification, are permitted provided that the following conditions
34  are met:
35 
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.
45 
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_
60 
62 #ifndef ITT_OS_WIN
63 # define ITT_OS_WIN 1
64 #endif /* ITT_OS_WIN */
65 
66 #ifndef ITT_OS_LINUX
67 # define ITT_OS_LINUX 2
68 #endif /* ITT_OS_LINUX */
69 
70 #ifndef ITT_OS_MAC
71 # define ITT_OS_MAC 3
72 #endif /* ITT_OS_MAC */
73 
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 */
83 
84 #ifndef ITT_PLATFORM_WIN
85 # define ITT_PLATFORM_WIN 1
86 #endif /* ITT_PLATFORM_WIN */
87 
88 #ifndef ITT_PLATFORM_POSIX
89 # define ITT_PLATFORM_POSIX 2
90 #endif /* ITT_PLATFORM_POSIX */
91 
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 */
99 
100 #if defined(_UNICODE) && !defined(UNICODE)
101 #define UNICODE
102 #endif
103 
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 */
113 
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 */
125 
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 */
137 
138 #define ITTAPI CDECL
139 #define LIBITTAPI CDECL
140 
141 /* TODO: Temporary for compatibility! */
142 #define ITTAPI_CALL CDECL
143 #define LIBITTAPI_CALL CDECL
144 
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 
164 #ifndef ITT_ARCH_IA32
165 # define ITT_ARCH_IA32 1
166 #endif /* ITT_ARCH_IA32 */
167 
168 #ifndef ITT_ARCH_IA32E
169 # define ITT_ARCH_IA32E 2
170 #endif /* ITT_ARCH_IA32E */
171 
172 #ifndef ITT_ARCH_IA64
173 # define ITT_ARCH_IA64 3
174 #endif /* ITT_ARCH_IA64 */
175 
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
185 
186 #ifdef __cplusplus
187 # define ITT_EXTERN_C extern "C"
188 #else
189 # define ITT_EXTERN_C /* nothing */
190 #endif /* __cplusplus */
191 
192 #define ITT_TO_STR_AUX(x) #x
193 #define ITT_TO_STR(x) ITT_TO_STR_AUX(x)
194 
195 #define __ITT_BUILD_ASSERT(expr, suffix) do { static char __itt_build_check_##suffix[(expr) ? 1 : -1]; __itt_build_check_##suffix[0] = 0; } while(0)
196 #define _ITT_BUILD_ASSERT(expr, suffix) __ITT_BUILD_ASSERT((expr), suffix)
197 #define ITT_BUILD_ASSERT(expr) _ITT_BUILD_ASSERT((expr), __LINE__)
198 
199 #define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 }
200 
201 /* Replace with snapshot date YYYYMMDD for promotion build. */
202 #define API_VERSION_BUILD 20111111
203 
204 #ifndef API_VERSION_NUM
205 #define API_VERSION_NUM 0.0.0
206 #endif /* API_VERSION_NUM */
207 
208 #define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) " (" ITT_TO_STR(API_VERSION_BUILD) ")"
209 
210 /* OS communication functions */
211 #if ITT_PLATFORM==ITT_PLATFORM_WIN
212 #include <windows.h>
213 typedef HMODULE lib_t;
214 typedef DWORD TIDT;
215 typedef CRITICAL_SECTION mutex_t;
216 #define MUTEX_INITIALIZER { 0 }
217 #define strong_alias(name, aliasname) /* empty for Windows */
218 #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
219 #include <dlfcn.h>
220 #if defined(UNICODE) || defined(_UNICODE)
221 #include <wchar.h>
222 #endif /* UNICODE */
223 #ifndef _GNU_SOURCE
224 #define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */
225 #endif /* _GNU_SOURCE */
226 #include <pthread.h>
227 typedef void* lib_t;
228 typedef pthread_t TIDT;
229 typedef pthread_mutex_t mutex_t;
230 #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
231 #define _strong_alias(name, aliasname) extern __typeof (name) aliasname __attribute__ ((alias (#name)));
232 #define strong_alias(name, aliasname) _strong_alias(name, aliasname)
233 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
234 
235 #if ITT_PLATFORM==ITT_PLATFORM_WIN
236 #define __itt_get_proc(lib, name) GetProcAddress(lib, name)
237 #define __itt_mutex_init(mutex) InitializeCriticalSection(mutex)
238 #define __itt_mutex_lock(mutex) EnterCriticalSection(mutex)
239 #define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex)
240 #define __itt_load_lib(name) LoadLibraryA(name)
241 #define __itt_unload_lib(handle) FreeLibrary(handle)
242 #define __itt_system_error() (int)GetLastError()
243 #define __itt_fstrcmp(s1, s2) lstrcmpA(s1, s2)
244 #define __itt_fstrlen(s) lstrlenA(s)
245 #define __itt_fstrcpyn(s1, s2, l) lstrcpynA(s1, s2, l)
246 #define __itt_fstrdup(s) _strdup(s)
247 #define __itt_thread_id() GetCurrentThreadId()
248 #define __itt_thread_yield() SwitchToThread()
249 #ifndef ITT_SIMPLE_INIT
250 ITT_INLINE int __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE;
251 ITT_INLINE int __itt_interlocked_increment(volatile long* ptr)
252 {
253  return InterlockedIncrement(ptr);
254 }
255 #endif /* ITT_SIMPLE_INIT */
256 #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */
257 #define __itt_get_proc(lib, name) dlsym(lib, name)
258 #define __itt_mutex_init(mutex) \
259  { \
260  pthread_mutexattr_t mutex_attr; \
261  int error_code = pthread_mutexattr_init(&mutex_attr); \
262  if (error_code) \
263  __itt_report_error(__itt_error_system, "pthread_mutexattr_init", error_code); \
264  error_code = pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); \
265  if (error_code) \
266  __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", error_code); \
267  error_code = pthread_mutex_init(mutex, &mutex_attr); \
268  if (error_code) \
269  __itt_report_error(__itt_error_system, "pthread_mutex_init", error_code); \
270  error_code = pthread_mutexattr_destroy(&mutex_attr); \
271  if (error_code) \
272  __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", error_code); \
273  }
274 #define __itt_mutex_lock(mutex) pthread_mutex_lock(mutex)
275 #define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex)
276 #define __itt_load_lib(name) dlopen(name, RTLD_LAZY)
277 #define __itt_unload_lib(handle) dlclose(handle)
278 #define __itt_system_error() errno
279 #define __itt_fstrcmp(s1, s2) strcmp(s1, s2)
280 #define __itt_fstrlen(s) strlen(s)
281 #define __itt_fstrcpyn(s1, s2, l) strncpy(s1, s2, l)
282 #define __itt_fstrdup(s) strdup(s)
283 #define __itt_thread_id() pthread_self()
284 #define __itt_thread_yield() sched_yield()
285 #if ITT_ARCH==ITT_ARCH_IA64
286 #ifdef __INTEL_COMPILER
287 #define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val)
288 #else /* __INTEL_COMPILER */
289 /* TODO: Add Support for not Intel compilers for IA64 */
290 #endif /* __INTEL_COMPILER */
291 #else /* ITT_ARCH!=ITT_ARCH_IA64 */
292 /*ITT_INLINE int __TBB_machine_fetchadd4(volatile void* ptr, long addend) ITT_INLINE_ATTRIBUTE;
293 ITT_INLINE int __TBB_machine_fetchadd4(volatile void* ptr, long addend)
294 {
295  int result;
296  __asm__ __volatile__("lock\nxaddl %0,%1"
297  : "=r"(result),"=m"(*(long*)ptr)
298  : "0"(addend), "m"(*(long*)ptr)
299  : "memory");
300  return result;
301 }
302 */
303 #endif /* ITT_ARCH==ITT_ARCH_IA64 */
304 #ifndef ITT_SIMPLE_INIT
305 /*ITT_INLINE int __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE;
306 ITT_INLINE int __itt_interlocked_increment(volatile long* ptr)
307 {
308  return __TBB_machine_fetchadd4(ptr, 1) + 1;
309 }
310 */
311 #endif /* ITT_SIMPLE_INIT */
312 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
313 
314 typedef enum {
315  __itt_collection_normal = 0,
316  __itt_collection_paused = 1
317 } __itt_collection_state;
318 
319 typedef enum {
320  __itt_thread_normal = 0,
321  __itt_thread_ignored = 1
322 } __itt_thread_state;
323 
324 #pragma pack(push, 8)
325 
326 typedef struct ___itt_thread_info
327 {
328  const char* nameA;
329 #if defined(UNICODE) || defined(_UNICODE)
330  const wchar_t* nameW;
331 #else /* UNICODE || _UNICODE */
332  void* nameW;
333 #endif /* UNICODE || _UNICODE */
334  TIDT tid;
335  __itt_thread_state state;
336  int extra1;
337  void* extra2;
338  struct ___itt_thread_info* next;
340 
341 #include "ittnotify_types.h" /* For __itt_group_id definition */
342 
344 {
345  const char* name;
346  void** func_ptr;
347  void* init_func;
348  __itt_group_id group;
350 
351 typedef struct ___itt_api_info
352 {
353  const char* name;
354  void** func_ptr;
355  void* init_func;
356  void* null_func;
357  __itt_group_id group;
359 
360 struct ___itt_domain;
361 struct ___itt_string_handle;
362 
363 typedef struct ___itt_global
364 {
365  unsigned char magic[8];
366  unsigned long version_major;
367  unsigned long version_minor;
368  unsigned long version_build;
369  volatile long api_initialized;
370  volatile long mutex_initialized;
371  volatile long atomic_counter;
372  mutex_t mutex;
373  lib_t lib;
374  void* error_handler;
375  const char** dll_path_ptr;
376  __itt_api_info* api_list_ptr;
377  struct ___itt_global* next;
378  /* Joinable structures below */
379  __itt_thread_info* thread_list;
380  struct ___itt_domain* domain_list;
381  struct ___itt_string_handle* string_list;
382  __itt_collection_state state;
383 } __itt_global;
384 
385 #pragma pack(pop)
386 
387 #define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \
388  h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \
389  if (h != NULL) { \
390  h->tid = t; \
391  h->nameA = NULL; \
392  h->nameW = n ? _wcsdup(n) : NULL; \
393  h->state = s; \
394  h->extra1 = 0; /* reserved */ \
395  h->extra2 = NULL; /* reserved */ \
396  h->next = NULL; \
397  if (h_tail == NULL) \
398  (gptr)->thread_list = h; \
399  else \
400  h_tail->next = h; \
401  } \
402 }
403 
404 #define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \
405  h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \
406  if (h != NULL) { \
407  h->tid = t; \
408  h->nameA = n ? __itt_fstrdup(n) : NULL; \
409  h->nameW = NULL; \
410  h->state = s; \
411  h->extra1 = 0; /* reserved */ \
412  h->extra2 = NULL; /* reserved */ \
413  h->next = NULL; \
414  if (h_tail == NULL) \
415  (gptr)->thread_list = h; \
416  else \
417  h_tail->next = h; \
418  } \
419 }
420 
421 #define NEW_DOMAIN_W(gptr,h,h_tail,name) { \
422  h = (__itt_domain*)malloc(sizeof(__itt_domain)); \
423  if (h != NULL) { \
424  h->flags = 0; /* domain is disabled by default */ \
425  h->nameA = NULL; \
426  h->nameW = name ? _wcsdup(name) : NULL; \
427  h->extra1 = 0; /* reserved */ \
428  h->extra2 = NULL; /* reserved */ \
429  h->next = NULL; \
430  if (h_tail == NULL) \
431  (gptr)->domain_list = h; \
432  else \
433  h_tail->next = h; \
434  } \
435 }
436 
437 #define NEW_DOMAIN_A(gptr,h,h_tail,name) { \
438  h = (__itt_domain*)malloc(sizeof(__itt_domain)); \
439  if (h != NULL) { \
440  h->flags = 0; /* domain is disabled by default */ \
441  h->nameA = name ? __itt_fstrdup(name) : NULL; \
442  h->nameW = NULL; \
443  h->extra1 = 0; /* reserved */ \
444  h->extra2 = NULL; /* reserved */ \
445  h->next = NULL; \
446  if (h_tail == NULL) \
447  (gptr)->domain_list = h; \
448  else \
449  h_tail->next = h; \
450  } \
451 }
452 
453 #define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \
454  h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \
455  if (h != NULL) { \
456  h->strA = NULL; \
457  h->strW = name ? _wcsdup(name) : NULL; \
458  h->extra1 = 0; /* reserved */ \
459  h->extra2 = NULL; /* reserved */ \
460  h->next = NULL; \
461  if (h_tail == NULL) \
462  (gptr)->string_list = h; \
463  else \
464  h_tail->next = h; \
465  } \
466 }
467 
468 #define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \
469  h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \
470  if (h != NULL) { \
471  h->strA = name ? __itt_fstrdup(name) : NULL; \
472  h->strW = NULL; \
473  h->extra1 = 0; /* reserved */ \
474  h->extra2 = NULL; /* reserved */ \
475  h->next = NULL; \
476  if (h_tail == NULL) \
477  (gptr)->string_list = h; \
478  else \
479  h_tail->next = h; \
480  } \
481 }
482 
483 #endif /* _ITTNOTIFY_CONFIG_H_ */
484 
__itt_thread_state state