1 | /* |
2 | Copyright (C) 2005-2019 Intel Corporation |
3 | |
4 | SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause |
5 | */ |
6 | #ifndef _ITTNOTIFY_CONFIG_H_ |
7 | #define _ITTNOTIFY_CONFIG_H_ |
8 | |
9 | /** @cond exclude_from_documentation */ |
10 | #ifndef ITT_OS_WIN |
11 | # define ITT_OS_WIN 1 |
12 | #endif /* ITT_OS_WIN */ |
13 | |
14 | #ifndef ITT_OS_LINUX |
15 | # define ITT_OS_LINUX 2 |
16 | #endif /* ITT_OS_LINUX */ |
17 | |
18 | #ifndef ITT_OS_MAC |
19 | # define ITT_OS_MAC 3 |
20 | #endif /* ITT_OS_MAC */ |
21 | |
22 | #ifndef ITT_OS_FREEBSD |
23 | # define ITT_OS_FREEBSD 4 |
24 | #endif /* ITT_OS_FREEBSD */ |
25 | |
26 | #ifndef ITT_OS |
27 | # if defined WIN32 || defined _WIN32 |
28 | # define ITT_OS ITT_OS_WIN |
29 | # elif defined( __APPLE__ ) && defined( __MACH__ ) |
30 | # define ITT_OS ITT_OS_MAC |
31 | # elif defined( __FreeBSD__ ) |
32 | # define ITT_OS ITT_OS_FREEBSD |
33 | # else |
34 | # define ITT_OS ITT_OS_LINUX |
35 | # endif |
36 | #endif /* ITT_OS */ |
37 | |
38 | #ifndef ITT_PLATFORM_WIN |
39 | # define ITT_PLATFORM_WIN 1 |
40 | #endif /* ITT_PLATFORM_WIN */ |
41 | |
42 | #ifndef ITT_PLATFORM_POSIX |
43 | # define ITT_PLATFORM_POSIX 2 |
44 | #endif /* ITT_PLATFORM_POSIX */ |
45 | |
46 | #ifndef ITT_PLATFORM_MAC |
47 | # define ITT_PLATFORM_MAC 3 |
48 | #endif /* ITT_PLATFORM_MAC */ |
49 | |
50 | #ifndef ITT_PLATFORM_FREEBSD |
51 | # define ITT_PLATFORM_FREEBSD 4 |
52 | #endif /* ITT_PLATFORM_FREEBSD */ |
53 | |
54 | #ifndef ITT_PLATFORM |
55 | # if ITT_OS==ITT_OS_WIN |
56 | # define ITT_PLATFORM ITT_PLATFORM_WIN |
57 | # elif ITT_OS==ITT_OS_MAC |
58 | # define ITT_PLATFORM ITT_PLATFORM_MAC |
59 | # elif ITT_OS==ITT_OS_FREEBSD |
60 | # define ITT_PLATFORM ITT_PLATFORM_FREEBSD |
61 | # else |
62 | # define ITT_PLATFORM ITT_PLATFORM_POSIX |
63 | # endif |
64 | #endif /* ITT_PLATFORM */ |
65 | |
66 | #if defined(_UNICODE) && !defined(UNICODE) |
67 | #define UNICODE |
68 | #endif |
69 | |
70 | #include <stddef.h> |
71 | #if ITT_PLATFORM==ITT_PLATFORM_WIN |
72 | #include <tchar.h> |
73 | #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
74 | #include <stdint.h> |
75 | #if defined(UNICODE) || defined(_UNICODE) |
76 | #include <wchar.h> |
77 | #endif /* UNICODE || _UNICODE */ |
78 | #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
79 | |
80 | #ifndef ITTAPI_CDECL |
81 | # if ITT_PLATFORM==ITT_PLATFORM_WIN |
82 | # define ITTAPI_CDECL __cdecl |
83 | # else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
84 | # if defined _M_IX86 || defined __i386__ |
85 | # define ITTAPI_CDECL __attribute__ ((cdecl)) |
86 | # else /* _M_IX86 || __i386__ */ |
87 | # define ITTAPI_CDECL /* actual only on x86 platform */ |
88 | # endif /* _M_IX86 || __i386__ */ |
89 | # endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
90 | #endif /* ITTAPI_CDECL */ |
91 | |
92 | #ifndef STDCALL |
93 | # if ITT_PLATFORM==ITT_PLATFORM_WIN |
94 | # define STDCALL __stdcall |
95 | # else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
96 | # if defined _M_IX86 || defined __i386__ |
97 | # define STDCALL __attribute__ ((stdcall)) |
98 | # else /* _M_IX86 || __i386__ */ |
99 | # define STDCALL /* supported only on x86 platform */ |
100 | # endif /* _M_IX86 || __i386__ */ |
101 | # endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
102 | #endif /* STDCALL */ |
103 | |
104 | #define ITTAPI ITTAPI_CDECL |
105 | #define LIBITTAPI ITTAPI_CDECL |
106 | |
107 | /* TODO: Temporary for compatibility! */ |
108 | #define ITTAPI_CALL ITTAPI_CDECL |
109 | #define LIBITTAPI_CALL ITTAPI_CDECL |
110 | |
111 | #if ITT_PLATFORM==ITT_PLATFORM_WIN |
112 | /* use __forceinline (VC++ specific) */ |
113 | #if defined(__MINGW32__) && !defined(__cplusplus) |
114 | #define ITT_INLINE static __inline__ __attribute__((__always_inline__,__gnu_inline__)) |
115 | #else |
116 | #define ITT_INLINE static __forceinline |
117 | #endif /* __MINGW32__ */ |
118 | |
119 | #define ITT_INLINE_ATTRIBUTE /* nothing */ |
120 | #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
121 | /* |
122 | * Generally, functions are not inlined unless optimization is specified. |
123 | * For functions declared inline, this attribute inlines the function even |
124 | * if no optimization level was specified. |
125 | */ |
126 | #ifdef __STRICT_ANSI__ |
127 | #define ITT_INLINE static |
128 | #define ITT_INLINE_ATTRIBUTE __attribute__((unused)) |
129 | #else /* __STRICT_ANSI__ */ |
130 | #define ITT_INLINE static inline |
131 | #define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) |
132 | #endif /* __STRICT_ANSI__ */ |
133 | #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
134 | /** @endcond */ |
135 | |
136 | #ifndef ITT_ARCH_IA32 |
137 | # define ITT_ARCH_IA32 1 |
138 | #endif /* ITT_ARCH_IA32 */ |
139 | |
140 | #ifndef ITT_ARCH_IA32E |
141 | # define ITT_ARCH_IA32E 2 |
142 | #endif /* ITT_ARCH_IA32E */ |
143 | |
144 | #ifndef ITT_ARCH_IA64 |
145 | # define ITT_ARCH_IA64 3 |
146 | #endif /* ITT_ARCH_IA64 */ |
147 | |
148 | #ifndef ITT_ARCH_ARM |
149 | # define ITT_ARCH_ARM 4 |
150 | #endif /* ITT_ARCH_ARM */ |
151 | |
152 | #ifndef ITT_ARCH_PPC64 |
153 | # define ITT_ARCH_PPC64 5 |
154 | #endif /* ITT_ARCH_PPC64 */ |
155 | |
156 | #ifndef ITT_ARCH_ARM64 |
157 | # define ITT_ARCH_ARM64 6 |
158 | #endif /* ITT_ARCH_ARM64 */ |
159 | |
160 | #ifndef ITT_ARCH |
161 | # if defined _M_IX86 || defined __i386__ |
162 | # define ITT_ARCH ITT_ARCH_IA32 |
163 | # elif defined _M_X64 || defined _M_AMD64 || defined __x86_64__ |
164 | # define ITT_ARCH ITT_ARCH_IA32E |
165 | # elif defined _M_IA64 || defined __ia64__ |
166 | # define ITT_ARCH ITT_ARCH_IA64 |
167 | # elif defined _M_ARM || defined __arm__ |
168 | # define ITT_ARCH ITT_ARCH_ARM |
169 | # elif defined __aarch64__ |
170 | # define ITT_ARCH ITT_ARCH_ARM64 |
171 | # elif defined __powerpc64__ |
172 | # define ITT_ARCH ITT_ARCH_PPC64 |
173 | # endif |
174 | #endif |
175 | |
176 | #ifdef __cplusplus |
177 | # define ITT_EXTERN_C extern "C" |
178 | # define ITT_EXTERN_C_BEGIN extern "C" { |
179 | # define ITT_EXTERN_C_END } |
180 | #else |
181 | # define ITT_EXTERN_C /* nothing */ |
182 | # define ITT_EXTERN_C_BEGIN /* nothing */ |
183 | # define ITT_EXTERN_C_END /* nothing */ |
184 | #endif /* __cplusplus */ |
185 | |
186 | #define ITT_TO_STR_AUX(x) #x |
187 | #define ITT_TO_STR(x) ITT_TO_STR_AUX(x) |
188 | |
189 | #define __ITT_BUILD_ASSERT(expr, suffix) do { \ |
190 | static char __itt_build_check_##suffix[(expr) ? 1 : -1]; \ |
191 | __itt_build_check_##suffix[0] = 0; \ |
192 | } while(0) |
193 | #define _ITT_BUILD_ASSERT(expr, suffix) __ITT_BUILD_ASSERT((expr), suffix) |
194 | #define ITT_BUILD_ASSERT(expr) _ITT_BUILD_ASSERT((expr), __LINE__) |
195 | |
196 | #define ITT_MAGIC { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 } |
197 | |
198 | /* Replace with snapshot date YYYYMMDD for promotion build. */ |
199 | #define API_VERSION_BUILD 20180723 |
200 | |
201 | #ifndef API_VERSION_NUM |
202 | #define API_VERSION_NUM 3.23.0 |
203 | #endif /* API_VERSION_NUM */ |
204 | |
205 | #define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \ |
206 | " (" ITT_TO_STR(API_VERSION_BUILD) ")" |
207 | |
208 | /* OS communication functions */ |
209 | #if ITT_PLATFORM==ITT_PLATFORM_WIN |
210 | #include <windows.h> |
211 | typedef HMODULE lib_t; |
212 | typedef DWORD TIDT; |
213 | typedef CRITICAL_SECTION mutex_t; |
214 | #ifdef __cplusplus |
215 | #define MUTEX_INITIALIZER {} |
216 | #else |
217 | #define MUTEX_INITIALIZER { 0 } |
218 | #endif |
219 | #define strong_alias(name, aliasname) /* empty for Windows */ |
220 | #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
221 | #include <dlfcn.h> |
222 | #if defined(UNICODE) || defined(_UNICODE) |
223 | #include <wchar.h> |
224 | #endif /* UNICODE */ |
225 | #ifndef _GNU_SOURCE |
226 | #define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */ |
227 | #endif /* _GNU_SOURCE */ |
228 | #ifndef __USE_UNIX98 |
229 | #define __USE_UNIX98 1 /* need for PTHREAD_MUTEX_RECURSIVE, on SLES11.1 with gcc 4.3.4 wherein pthread.h missing dependency on __USE_XOPEN2K8 */ |
230 | #endif /*__USE_UNIX98*/ |
231 | #include <pthread.h> |
232 | typedef void* lib_t; |
233 | typedef pthread_t TIDT; |
234 | typedef pthread_mutex_t mutex_t; |
235 | #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
236 | #define _strong_alias(name, aliasname) \ |
237 | extern __typeof (name) aliasname __attribute__ ((alias (#name))); |
238 | #define strong_alias(name, aliasname) _strong_alias(name, aliasname) |
239 | #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
240 | |
241 | #if ITT_PLATFORM==ITT_PLATFORM_WIN |
242 | #define __itt_get_proc(lib, name) GetProcAddress(lib, name) |
243 | #define __itt_mutex_init(mutex) InitializeCriticalSection(mutex) |
244 | #define __itt_mutex_lock(mutex) EnterCriticalSection(mutex) |
245 | #define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex) |
246 | #define __itt_mutex_destroy(mutex) DeleteCriticalSection(mutex) |
247 | #define __itt_load_lib(name) LoadLibraryA(name) |
248 | #define __itt_unload_lib(handle) FreeLibrary(handle) |
249 | #define __itt_system_error() (int)GetLastError() |
250 | #define __itt_fstrcmp(s1, s2) lstrcmpA(s1, s2) |
251 | #define __itt_fstrnlen(s, l) strnlen_s(s, l) |
252 | #define __itt_fstrcpyn(s1, b, s2, l) strncpy_s(s1, b, s2, l) |
253 | #define __itt_thread_id() GetCurrentThreadId() |
254 | #define __itt_thread_yield() SwitchToThread() |
255 | #ifndef ITT_SIMPLE_INIT |
256 | ITT_INLINE long |
257 | __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; |
258 | ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) |
259 | { |
260 | return InterlockedIncrement(ptr); |
261 | } |
262 | ITT_INLINE long |
263 | __itt_interlocked_compare_exchange(volatile long* ptr, long exchange, long comperand) ITT_INLINE_ATTRIBUTE; |
264 | ITT_INLINE long |
265 | __itt_interlocked_compare_exchange(volatile long* ptr, long exchange, long comperand) |
266 | { |
267 | return InterlockedCompareExchange(ptr, exchange, comperand); |
268 | } |
269 | #endif /* ITT_SIMPLE_INIT */ |
270 | |
271 | #define DL_SYMBOLS (1) |
272 | #define PTHREAD_SYMBOLS (1) |
273 | |
274 | #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ |
275 | #define __itt_get_proc(lib, name) dlsym(lib, name) |
276 | #define __itt_mutex_init(mutex) {\ |
277 | pthread_mutexattr_t mutex_attr; \ |
278 | int error_code = pthread_mutexattr_init(&mutex_attr); \ |
279 | if (error_code) \ |
280 | __itt_report_error(__itt_error_system, "pthread_mutexattr_init", \ |
281 | error_code); \ |
282 | error_code = pthread_mutexattr_settype(&mutex_attr, \ |
283 | PTHREAD_MUTEX_RECURSIVE); \ |
284 | if (error_code) \ |
285 | __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", \ |
286 | error_code); \ |
287 | error_code = pthread_mutex_init(mutex, &mutex_attr); \ |
288 | if (error_code) \ |
289 | __itt_report_error(__itt_error_system, "pthread_mutex_init", \ |
290 | error_code); \ |
291 | error_code = pthread_mutexattr_destroy(&mutex_attr); \ |
292 | if (error_code) \ |
293 | __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", \ |
294 | error_code); \ |
295 | } |
296 | #define __itt_mutex_lock(mutex) pthread_mutex_lock(mutex) |
297 | #define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex) |
298 | #define __itt_mutex_destroy(mutex) pthread_mutex_destroy(mutex) |
299 | #define __itt_load_lib(name) dlopen(name, RTLD_LAZY) |
300 | #define __itt_unload_lib(handle) dlclose(handle) |
301 | #define __itt_system_error() errno |
302 | #define __itt_fstrcmp(s1, s2) strcmp(s1, s2) |
303 | |
304 | /* makes customer code define safe APIs for SDL_STRNLEN_S and SDL_STRNCPY_S */ |
305 | #ifdef SDL_STRNLEN_S |
306 | #define __itt_fstrnlen(s, l) SDL_STRNLEN_S(s, l) |
307 | #else |
308 | #define __itt_fstrnlen(s, l) strlen(s) |
309 | #endif /* SDL_STRNLEN_S */ |
310 | #ifdef SDL_STRNCPY_S |
311 | #define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l) |
312 | #else |
313 | #define __itt_fstrcpyn(s1, b, s2, l) { \ |
314 | if (b > 0) { \ |
315 | /* 'volatile' is used to suppress the warning that a destination */ \ |
316 | /* bound depends on the length of the source. */ \ |
317 | volatile size_t num_to_copy = (size_t)(b - 1) < (size_t)(l) ? \ |
318 | (size_t)(b - 1) : (size_t)(l); \ |
319 | strncpy(s1, s2, num_to_copy); \ |
320 | s1[num_to_copy] = 0; \ |
321 | } \ |
322 | } |
323 | #endif /* SDL_STRNCPY_S */ |
324 | |
325 | #define __itt_thread_id() pthread_self() |
326 | #define __itt_thread_yield() sched_yield() |
327 | #if ITT_ARCH==ITT_ARCH_IA64 |
328 | #ifdef __INTEL_COMPILER |
329 | #define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val) |
330 | #else /* __INTEL_COMPILER */ |
331 | /* TODO: Add Support for not Intel compilers for IA-64 architecture */ |
332 | #endif /* __INTEL_COMPILER */ |
333 | #elif ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_IA32E /* ITT_ARCH!=ITT_ARCH_IA64 */ |
334 | ITT_INLINE long |
335 | __TBB_machine_fetchadd4(volatile void* ptr, long addend) ITT_INLINE_ATTRIBUTE; |
336 | ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend) |
337 | { |
338 | long result; |
339 | __asm__ __volatile__("lock\nxadd %0,%1" |
340 | : "=r" (result),"=m" (*(volatile int*)ptr) |
341 | : "0" (addend), "m" (*(volatile int*)ptr) |
342 | : "memory" ); |
343 | return result; |
344 | } |
345 | #else |
346 | #define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val) |
347 | #endif /* ITT_ARCH==ITT_ARCH_IA64 */ |
348 | #ifndef ITT_SIMPLE_INIT |
349 | ITT_INLINE long |
350 | __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; |
351 | ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) |
352 | { |
353 | return __TBB_machine_fetchadd4(ptr, 1) + 1L; |
354 | } |
355 | ITT_INLINE long |
356 | __itt_interlocked_compare_exchange(volatile long* ptr, long exchange, long comperand) ITT_INLINE_ATTRIBUTE; |
357 | ITT_INLINE long |
358 | __itt_interlocked_compare_exchange(volatile long* ptr, long exchange, long comperand) |
359 | { |
360 | return __sync_val_compare_and_swap(ptr, exchange, comperand); |
361 | } |
362 | #endif /* ITT_SIMPLE_INIT */ |
363 | |
364 | void* dlopen(const char*, int) __attribute__((weak)); |
365 | void* dlsym(void*, const char*) __attribute__((weak)); |
366 | int dlclose(void*) __attribute__((weak)); |
367 | #define DL_SYMBOLS (dlopen && dlsym && dlclose) |
368 | |
369 | int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __attribute__((weak)); |
370 | int pthread_mutex_lock(pthread_mutex_t*) __attribute__((weak)); |
371 | int pthread_mutex_unlock(pthread_mutex_t*) __attribute__((weak)); |
372 | int pthread_mutex_destroy(pthread_mutex_t*) __attribute__((weak)); |
373 | int pthread_mutexattr_init(pthread_mutexattr_t*) __attribute__((weak)); |
374 | int pthread_mutexattr_settype(pthread_mutexattr_t*, int) __attribute__((weak)); |
375 | int pthread_mutexattr_destroy(pthread_mutexattr_t*) __attribute__((weak)); |
376 | pthread_t pthread_self(void) __attribute__((weak)); |
377 | #define PTHREAD_SYMBOLS (pthread_mutex_init && pthread_mutex_lock && pthread_mutex_unlock && pthread_mutex_destroy && pthread_mutexattr_init && pthread_mutexattr_settype && pthread_mutexattr_destroy && pthread_self) |
378 | |
379 | #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ |
380 | |
381 | /* strdup() is not included into C99 which results in a compiler warning about |
382 | * implicitly declared symbol. To avoid the issue strdup is implemented |
383 | * manually. |
384 | */ |
385 | #define ITT_STRDUP_MAX_STRING_SIZE 4096 |
386 | #define __itt_fstrdup(s, new_s) do { \ |
387 | if (s != NULL) { \ |
388 | size_t s_len = __itt_fstrnlen(s, ITT_STRDUP_MAX_STRING_SIZE); \ |
389 | new_s = (char *)malloc(s_len + 1); \ |
390 | if (new_s != NULL) { \ |
391 | __itt_fstrcpyn(new_s, s_len + 1, s, s_len); \ |
392 | } \ |
393 | } \ |
394 | } while(0) |
395 | |
396 | typedef enum { |
397 | __itt_thread_normal = 0, |
398 | __itt_thread_ignored = 1 |
399 | } __itt_thread_state; |
400 | |
401 | #pragma pack(push, 8) |
402 | |
403 | typedef struct ___itt_thread_info |
404 | { |
405 | const char* nameA; /*!< Copy of original name in ASCII. */ |
406 | #if defined(UNICODE) || defined(_UNICODE) |
407 | const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ |
408 | #else /* UNICODE || _UNICODE */ |
409 | void* nameW; |
410 | #endif /* UNICODE || _UNICODE */ |
411 | TIDT tid; |
412 | __itt_thread_state state; /*!< Thread state (paused or normal) */ |
413 | int ; /*!< Reserved to the runtime */ |
414 | void* ; /*!< Reserved to the runtime */ |
415 | struct ___itt_thread_info* next; |
416 | } __itt_thread_info; |
417 | |
418 | #include "ittnotify_types.h" /* For __itt_group_id definition */ |
419 | |
420 | typedef struct ___itt_api_info_20101001 |
421 | { |
422 | const char* name; |
423 | void** func_ptr; |
424 | void* init_func; |
425 | __itt_group_id group; |
426 | } __itt_api_info_20101001; |
427 | |
428 | typedef struct ___itt_api_info |
429 | { |
430 | const char* name; |
431 | void** func_ptr; |
432 | void* init_func; |
433 | void* null_func; |
434 | __itt_group_id group; |
435 | } __itt_api_info; |
436 | |
437 | typedef struct __itt_counter_info |
438 | { |
439 | const char* nameA; /*!< Copy of original name in ASCII. */ |
440 | #if defined(UNICODE) || defined(_UNICODE) |
441 | const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ |
442 | #else /* UNICODE || _UNICODE */ |
443 | void* nameW; |
444 | #endif /* UNICODE || _UNICODE */ |
445 | const char* domainA; /*!< Copy of original name in ASCII. */ |
446 | #if defined(UNICODE) || defined(_UNICODE) |
447 | const wchar_t* domainW; /*!< Copy of original name in UNICODE. */ |
448 | #else /* UNICODE || _UNICODE */ |
449 | void* domainW; |
450 | #endif /* UNICODE || _UNICODE */ |
451 | int type; |
452 | long index; |
453 | int ; /*!< Reserved to the runtime */ |
454 | void* ; /*!< Reserved to the runtime */ |
455 | struct __itt_counter_info* next; |
456 | } __itt_counter_info_t; |
457 | |
458 | struct ___itt_domain; |
459 | struct ___itt_string_handle; |
460 | struct ___itt_histogram; |
461 | |
462 | #include "ittnotify.h" |
463 | |
464 | typedef struct ___itt_global |
465 | { |
466 | unsigned char magic[8]; |
467 | unsigned long version_major; |
468 | unsigned long version_minor; |
469 | unsigned long version_build; |
470 | volatile long api_initialized; |
471 | volatile long mutex_initialized; |
472 | volatile long atomic_counter; |
473 | mutex_t mutex; |
474 | lib_t lib; |
475 | void* error_handler; |
476 | const char** dll_path_ptr; |
477 | __itt_api_info* api_list_ptr; |
478 | struct ___itt_global* next; |
479 | /* Joinable structures below */ |
480 | __itt_thread_info* thread_list; |
481 | struct ___itt_domain* domain_list; |
482 | struct ___itt_string_handle* string_list; |
483 | __itt_collection_state state; |
484 | __itt_counter_info_t* counter_list; |
485 | unsigned int ipt_collect_events; |
486 | struct ___itt_histogram* histogram_list; |
487 | } __itt_global; |
488 | |
489 | #pragma pack(pop) |
490 | |
491 | #define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \ |
492 | h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ |
493 | if (h != NULL) { \ |
494 | h->tid = t; \ |
495 | h->nameA = NULL; \ |
496 | h->nameW = n ? _wcsdup(n) : NULL; \ |
497 | h->state = s; \ |
498 | h->extra1 = 0; /* reserved */ \ |
499 | h->extra2 = NULL; /* reserved */ \ |
500 | h->next = NULL; \ |
501 | if (h_tail == NULL) \ |
502 | (gptr)->thread_list = h; \ |
503 | else \ |
504 | h_tail->next = h; \ |
505 | } \ |
506 | } |
507 | |
508 | #define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \ |
509 | h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ |
510 | if (h != NULL) { \ |
511 | h->tid = t; \ |
512 | char *n_copy = NULL; \ |
513 | __itt_fstrdup(n, n_copy); \ |
514 | h->nameA = n_copy; \ |
515 | h->nameW = NULL; \ |
516 | h->state = s; \ |
517 | h->extra1 = 0; /* reserved */ \ |
518 | h->extra2 = NULL; /* reserved */ \ |
519 | h->next = NULL; \ |
520 | if (h_tail == NULL) \ |
521 | (gptr)->thread_list = h; \ |
522 | else \ |
523 | h_tail->next = h; \ |
524 | } \ |
525 | } |
526 | |
527 | #define NEW_DOMAIN_W(gptr,h,h_tail,name) { \ |
528 | h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ |
529 | if (h != NULL) { \ |
530 | h->flags = 1; /* domain is enabled by default */ \ |
531 | h->nameA = NULL; \ |
532 | h->nameW = name ? _wcsdup(name) : NULL; \ |
533 | h->extra1 = 0; /* reserved */ \ |
534 | h->extra2 = NULL; /* reserved */ \ |
535 | h->next = NULL; \ |
536 | if (h_tail == NULL) \ |
537 | (gptr)->domain_list = h; \ |
538 | else \ |
539 | h_tail->next = h; \ |
540 | } \ |
541 | } |
542 | |
543 | #define NEW_DOMAIN_A(gptr,h,h_tail,name) { \ |
544 | h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ |
545 | if (h != NULL) { \ |
546 | h->flags = 1; /* domain is enabled by default */ \ |
547 | char *name_copy = NULL; \ |
548 | __itt_fstrdup(name, name_copy); \ |
549 | h->nameA = name_copy; \ |
550 | h->nameW = NULL; \ |
551 | h->extra1 = 0; /* reserved */ \ |
552 | h->extra2 = NULL; /* reserved */ \ |
553 | h->next = NULL; \ |
554 | if (h_tail == NULL) \ |
555 | (gptr)->domain_list = h; \ |
556 | else \ |
557 | h_tail->next = h; \ |
558 | } \ |
559 | } |
560 | |
561 | #define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \ |
562 | h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ |
563 | if (h != NULL) { \ |
564 | h->strA = NULL; \ |
565 | h->strW = name ? _wcsdup(name) : NULL; \ |
566 | h->extra1 = 0; /* reserved */ \ |
567 | h->extra2 = NULL; /* reserved */ \ |
568 | h->next = NULL; \ |
569 | if (h_tail == NULL) \ |
570 | (gptr)->string_list = h; \ |
571 | else \ |
572 | h_tail->next = h; \ |
573 | } \ |
574 | } |
575 | |
576 | #define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \ |
577 | h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ |
578 | if (h != NULL) { \ |
579 | char *name_copy = NULL; \ |
580 | __itt_fstrdup(name, name_copy); \ |
581 | h->strA = name_copy; \ |
582 | h->strW = NULL; \ |
583 | h->extra1 = 0; /* reserved */ \ |
584 | h->extra2 = NULL; /* reserved */ \ |
585 | h->next = NULL; \ |
586 | if (h_tail == NULL) \ |
587 | (gptr)->string_list = h; \ |
588 | else \ |
589 | h_tail->next = h; \ |
590 | } \ |
591 | } |
592 | |
593 | #define NEW_COUNTER_W(gptr,h,h_tail,name,domain,type) { \ |
594 | h = (__itt_counter_info_t*)malloc(sizeof(__itt_counter_info_t)); \ |
595 | if (h != NULL) { \ |
596 | h->nameA = NULL; \ |
597 | h->nameW = name ? _wcsdup(name) : NULL; \ |
598 | h->domainA = NULL; \ |
599 | h->domainW = name ? _wcsdup(domain) : NULL; \ |
600 | h->type = type; \ |
601 | h->index = 0; \ |
602 | h->next = NULL; \ |
603 | if (h_tail == NULL) \ |
604 | (gptr)->counter_list = h; \ |
605 | else \ |
606 | h_tail->next = h; \ |
607 | } \ |
608 | } |
609 | |
610 | #define NEW_COUNTER_A(gptr,h,h_tail,name,domain,type) { \ |
611 | h = (__itt_counter_info_t*)malloc(sizeof(__itt_counter_info_t)); \ |
612 | if (h != NULL) { \ |
613 | char *name_copy = NULL; \ |
614 | __itt_fstrdup(name, name_copy); \ |
615 | h->nameA = name_copy; \ |
616 | h->nameW = NULL; \ |
617 | char *domain_copy = NULL; \ |
618 | __itt_fstrdup(domain, domain_copy); \ |
619 | h->domainA = domain_copy; \ |
620 | h->domainW = NULL; \ |
621 | h->type = type; \ |
622 | h->index = 0; \ |
623 | h->next = NULL; \ |
624 | if (h_tail == NULL) \ |
625 | (gptr)->counter_list = h; \ |
626 | else \ |
627 | h_tail->next = h; \ |
628 | } \ |
629 | } |
630 | |
631 | #define NEW_HISTOGRAM_W(gptr,h,h_tail,domain,name,x_type,y_type) { \ |
632 | h = (__itt_histogram*)malloc(sizeof(__itt_histogram)); \ |
633 | if (h != NULL) { \ |
634 | h->domain = domain; \ |
635 | h->nameA = NULL; \ |
636 | h->nameW = name ? _wcsdup(name) : NULL; \ |
637 | h->x_type = x_type; \ |
638 | h->y_type = y_type; \ |
639 | h->extra1 = 0; \ |
640 | h->extra2 = NULL; \ |
641 | if (h_tail == NULL) \ |
642 | (gptr)->histogram_list = h; \ |
643 | else \ |
644 | h_tail->next = h; \ |
645 | } \ |
646 | } |
647 | |
648 | #define NEW_HISTOGRAM_A(gptr,h,h_tail,domain,name,x_type,y_type) { \ |
649 | h = (__itt_histogram*)malloc(sizeof(__itt_histogram)); \ |
650 | if (h != NULL) { \ |
651 | h->domain = domain; \ |
652 | char *name_copy = NULL; \ |
653 | __itt_fstrdup(name, name_copy); \ |
654 | h->nameA = name_copy; \ |
655 | h->nameW = NULL; \ |
656 | h->x_type = x_type; \ |
657 | h->y_type = y_type; \ |
658 | h->extra1 = 0; \ |
659 | h->extra2 = NULL; \ |
660 | if (h_tail == NULL) \ |
661 | (gptr)->histogram_list = h; \ |
662 | else \ |
663 | h_tail->next = h; \ |
664 | } \ |
665 | } |
666 | |
667 | #endif /* _ITTNOTIFY_CONFIG_H_ */ |
668 | |