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