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