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 20180723 236 237 #ifndef API_VERSION_NUM 238 #define API_VERSION_NUM 3.23.0 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 498 #include "ittnotify.h" 499 500 typedef struct ___itt_global 501 { 502 unsigned char magic[8]; 503 unsigned long version_major; 504 unsigned long version_minor; 505 unsigned long version_build; 506 volatile long api_initialized; 507 volatile long mutex_initialized; 508 volatile long atomic_counter; 509 mutex_t mutex; 510 lib_t lib; 511 void* error_handler; 512 const char** dll_path_ptr; 513 __itt_api_info* api_list_ptr; 514 struct ___itt_global* next; 515 /* Joinable structures below */ 516 __itt_thread_info* thread_list; 517 struct ___itt_domain* domain_list; 518 struct ___itt_string_handle* string_list; 519 __itt_collection_state state; 520 __itt_counter_info_t* counter_list; 521 unsigned int ipt_collect_events; 522 struct ___itt_histogram* histogram_list; 523 } __itt_global; 524 525 #pragma pack(pop) 526 527 #define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \ 528 h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ 529 if (h != NULL) { \ 530 h->tid = t; \ 531 h->nameA = NULL; \ 532 h->nameW = n ? _wcsdup(n) : NULL; \ 533 h->state = s; \ 534 h->extra1 = 0; /* reserved */ \ 535 h->extra2 = NULL; /* reserved */ \ 536 h->next = NULL; \ 537 if (h_tail == NULL) \ 538 (gptr)->thread_list = h; \ 539 else \ 540 h_tail->next = h; \ 541 } \ 542 } 543 544 #define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \ 545 h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ 546 if (h != NULL) { \ 547 h->tid = t; \ 548 char *n_copy = NULL; \ 549 __itt_fstrdup(n, n_copy); \ 550 h->nameA = n_copy; \ 551 h->nameW = NULL; \ 552 h->state = s; \ 553 h->extra1 = 0; /* reserved */ \ 554 h->extra2 = NULL; /* reserved */ \ 555 h->next = NULL; \ 556 if (h_tail == NULL) \ 557 (gptr)->thread_list = h; \ 558 else \ 559 h_tail->next = h; \ 560 } \ 561 } 562 563 #define NEW_DOMAIN_W(gptr,h,h_tail,name) { \ 564 h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ 565 if (h != NULL) { \ 566 h->flags = 1; /* domain is enabled by default */ \ 567 h->nameA = NULL; \ 568 h->nameW = name ? _wcsdup(name) : NULL; \ 569 h->extra1 = 0; /* reserved */ \ 570 h->extra2 = NULL; /* reserved */ \ 571 h->next = NULL; \ 572 if (h_tail == NULL) \ 573 (gptr)->domain_list = h; \ 574 else \ 575 h_tail->next = h; \ 576 } \ 577 } 578 579 #define NEW_DOMAIN_A(gptr,h,h_tail,name) { \ 580 h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ 581 if (h != NULL) { \ 582 h->flags = 1; /* domain is enabled by default */ \ 583 char *name_copy = NULL; \ 584 __itt_fstrdup(name, name_copy); \ 585 h->nameA = name_copy; \ 586 h->nameW = NULL; \ 587 h->extra1 = 0; /* reserved */ \ 588 h->extra2 = NULL; /* reserved */ \ 589 h->next = NULL; \ 590 if (h_tail == NULL) \ 591 (gptr)->domain_list = h; \ 592 else \ 593 h_tail->next = h; \ 594 } \ 595 } 596 597 #define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \ 598 h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ 599 if (h != NULL) { \ 600 h->strA = NULL; \ 601 h->strW = name ? _wcsdup(name) : NULL; \ 602 h->extra1 = 0; /* reserved */ \ 603 h->extra2 = NULL; /* reserved */ \ 604 h->next = NULL; \ 605 if (h_tail == NULL) \ 606 (gptr)->string_list = h; \ 607 else \ 608 h_tail->next = h; \ 609 } \ 610 } 611 612 #define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \ 613 h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ 614 if (h != NULL) { \ 615 char *name_copy = NULL; \ 616 __itt_fstrdup(name, name_copy); \ 617 h->strA = name_copy; \ 618 h->strW = NULL; \ 619 h->extra1 = 0; /* reserved */ \ 620 h->extra2 = NULL; /* reserved */ \ 621 h->next = NULL; \ 622 if (h_tail == NULL) \ 623 (gptr)->string_list = h; \ 624 else \ 625 h_tail->next = h; \ 626 } \ 627 } 628 629 #define NEW_COUNTER_W(gptr,h,h_tail,name,domain,type) { \ 630 h = (__itt_counter_info_t*)malloc(sizeof(__itt_counter_info_t)); \ 631 if (h != NULL) { \ 632 h->nameA = NULL; \ 633 h->nameW = name ? _wcsdup(name) : NULL; \ 634 h->domainA = NULL; \ 635 h->domainW = name ? _wcsdup(domain) : NULL; \ 636 h->type = type; \ 637 h->index = 0; \ 638 h->next = NULL; \ 639 if (h_tail == NULL) \ 640 (gptr)->counter_list = h; \ 641 else \ 642 h_tail->next = h; \ 643 } \ 644 } 645 646 #define NEW_COUNTER_A(gptr,h,h_tail,name,domain,type) { \ 647 h = (__itt_counter_info_t*)malloc(sizeof(__itt_counter_info_t)); \ 648 if (h != NULL) { \ 649 char *name_copy = NULL; \ 650 __itt_fstrdup(name, name_copy); \ 651 h->nameA = name_copy; \ 652 h->nameW = NULL; \ 653 char *domain_copy = NULL; \ 654 __itt_fstrdup(domain, domain_copy); \ 655 h->domainA = domain_copy; \ 656 h->domainW = NULL; \ 657 h->type = type; \ 658 h->index = 0; \ 659 h->next = NULL; \ 660 if (h_tail == NULL) \ 661 (gptr)->counter_list = h; \ 662 else \ 663 h_tail->next = h; \ 664 } \ 665 } 666 667 #define NEW_HISTOGRAM_W(gptr,h,h_tail,domain,name,x_type,y_type) { \ 668 h = (__itt_histogram*)malloc(sizeof(__itt_histogram)); \ 669 if (h != NULL) { \ 670 h->domain = domain; \ 671 h->nameA = NULL; \ 672 h->nameW = name ? _wcsdup(name) : NULL; \ 673 h->x_type = x_type; \ 674 h->y_type = y_type; \ 675 h->extra1 = 0; \ 676 h->extra2 = NULL; \ 677 if (h_tail == NULL) \ 678 (gptr)->histogram_list = h; \ 679 else \ 680 h_tail->next = h; \ 681 } \ 682 } 683 684 #define NEW_HISTOGRAM_A(gptr,h,h_tail,domain,name,x_type,y_type) { \ 685 h = (__itt_histogram*)malloc(sizeof(__itt_histogram)); \ 686 if (h != NULL) { \ 687 h->domain = domain; \ 688 char *name_copy = NULL; \ 689 __itt_fstrdup(name, name_copy); \ 690 h->nameA = name_copy; \ 691 h->nameW = NULL; \ 692 h->x_type = x_type; \ 693 h->y_type = y_type; \ 694 h->extra1 = 0; \ 695 h->extra2 = NULL; \ 696 if (h_tail == NULL) \ 697 (gptr)->histogram_list = h; \ 698 else \ 699 h_tail->next = h; \ 700 } \ 701 } 702 703 #endif /* _ITTNOTIFY_CONFIG_H_ */ 704