1 /* 2 Copyright (c) 2005-2021 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 #define ITT_INLINE static __forceinline 125 #define ITT_INLINE_ATTRIBUTE /* nothing */ 126 #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ 127 /* 128 * Generally, functions are not inlined unless optimization is specified. 129 * For functions declared inline, this attribute inlines the function even 130 * if no optimization level was specified. 131 */ 132 #ifdef __STRICT_ANSI__ 133 #define ITT_INLINE static 134 #define ITT_INLINE_ATTRIBUTE __attribute__((unused)) 135 #else /* __STRICT_ANSI__ */ 136 #define ITT_INLINE static inline 137 #define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused)) 138 #endif /* __STRICT_ANSI__ */ 139 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ 140 /** @endcond */ 141 142 #ifndef ITT_ARCH_IA32 143 # define ITT_ARCH_IA32 1 144 #endif /* ITT_ARCH_IA32 */ 145 146 #ifndef ITT_ARCH_IA32E 147 # define ITT_ARCH_IA32E 2 148 #endif /* ITT_ARCH_IA32E */ 149 150 #ifndef ITT_ARCH_IA64 151 # define ITT_ARCH_IA64 3 152 #endif /* ITT_ARCH_IA64 */ 153 154 #ifndef ITT_ARCH_ARM 155 # define ITT_ARCH_ARM 4 156 #endif /* ITT_ARCH_ARM */ 157 158 #ifndef ITT_ARCH_PPC64 159 # define ITT_ARCH_PPC64 5 160 #endif /* ITT_ARCH_PPC64 */ 161 162 #ifndef ITT_ARCH_ARM64 163 # define ITT_ARCH_ARM64 6 164 #endif /* ITT_ARCH_ARM64 */ 165 166 #ifndef ITT_ARCH 167 # if defined _M_IX86 || defined __i386__ 168 # define ITT_ARCH ITT_ARCH_IA32 169 # elif defined _M_X64 || defined _M_AMD64 || defined __x86_64__ 170 # define ITT_ARCH ITT_ARCH_IA32E 171 # elif defined _M_IA64 || defined __ia64__ 172 # define ITT_ARCH ITT_ARCH_IA64 173 # elif defined _M_ARM || defined __arm__ 174 # define ITT_ARCH ITT_ARCH_ARM 175 # elif defined __aarch64__ 176 # define ITT_ARCH ITT_ARCH_ARM64 177 # elif defined __powerpc64__ 178 # define ITT_ARCH ITT_ARCH_PPC64 179 # endif 180 #endif 181 182 #ifdef __cplusplus 183 # define ITT_EXTERN_C extern "C" 184 # define ITT_EXTERN_C_BEGIN extern "C" { 185 # define ITT_EXTERN_C_END } 186 #else 187 # define ITT_EXTERN_C /* nothing */ 188 # define ITT_EXTERN_C_BEGIN /* nothing */ 189 # define ITT_EXTERN_C_END /* nothing */ 190 #endif /* __cplusplus */ 191 192 #define ITT_TO_STR_AUX(x) #x 193 #define ITT_TO_STR(x) ITT_TO_STR_AUX(x) 194 195 #define __ITT_BUILD_ASSERT(expr, suffix) do { \ 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 { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 } 203 204 /* Replace with snapshot date YYYYMMDD for promotion build. */ 205 #define API_VERSION_BUILD 20180723 206 207 #ifndef API_VERSION_NUM 208 #define API_VERSION_NUM 3.18.6 209 #endif /* API_VERSION_NUM */ 210 211 #define API_VERSION "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) \ 212 " (" ITT_TO_STR(API_VERSION_BUILD) ")" 213 214 /* OS communication functions */ 215 #if ITT_PLATFORM==ITT_PLATFORM_WIN 216 #include <windows.h> 217 typedef HMODULE lib_t; 218 typedef DWORD TIDT; 219 typedef CRITICAL_SECTION mutex_t; 220 #ifdef __cplusplus 221 #define MUTEX_INITIALIZER {} 222 #else 223 #define MUTEX_INITIALIZER { 0 } 224 #endif 225 #define strong_alias(name, aliasname) /* empty for Windows */ 226 #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */ 227 #include <dlfcn.h> 228 #if defined(UNICODE) || defined(_UNICODE) 229 #include <wchar.h> 230 #endif /* UNICODE */ 231 #ifndef _GNU_SOURCE 232 #define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */ 233 #endif /* _GNU_SOURCE */ 234 #ifndef __USE_UNIX98 235 #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 */ 236 #endif /*__USE_UNIX98*/ 237 #include <pthread.h> 238 typedef void* lib_t; 239 typedef pthread_t TIDT; 240 typedef pthread_mutex_t mutex_t; 241 #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER 242 #define _strong_alias(name, aliasname) \ 243 extern __typeof (name) aliasname __attribute__ ((alias (#name))); 244 #define strong_alias(name, aliasname) _strong_alias(name, aliasname) 245 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ 246 247 #if ITT_PLATFORM==ITT_PLATFORM_WIN 248 #define __itt_get_proc(lib, name) GetProcAddress(lib, name) 249 #define __itt_mutex_init(mutex) InitializeCriticalSection(mutex) 250 #define __itt_mutex_lock(mutex) EnterCriticalSection(mutex) 251 #define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex) 252 #define __itt_load_lib(name) LoadLibraryA(name) 253 #define __itt_unload_lib(handle) FreeLibrary(handle) 254 #define __itt_system_error() (int)GetLastError() 255 #define __itt_fstrcmp(s1, s2) lstrcmpA(s1, s2) 256 #define __itt_fstrnlen(s, l) strnlen_s(s, l) 257 #define __itt_fstrcpyn(s1, b, s2, l) strncpy_s(s1, b, s2, l) 258 #define __itt_fstrdup(s) _strdup(s) 259 #define __itt_thread_id() GetCurrentThreadId() 260 #define __itt_thread_yield() SwitchToThread() 261 #ifndef ITT_SIMPLE_INIT 262 ITT_INLINE long 263 __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; 264 ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) 265 { 266 return InterlockedIncrement(ptr); 267 } 268 #endif /* ITT_SIMPLE_INIT */ 269 270 #define DL_SYMBOLS (1) 271 #define PTHREAD_SYMBOLS (1) 272 273 #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */ 274 #define __itt_get_proc(lib, name) dlsym(lib, name) 275 #define __itt_mutex_init(mutex) {\ 276 pthread_mutexattr_t mutex_attr; \ 277 int error_code = pthread_mutexattr_init(&mutex_attr); \ 278 if (error_code) \ 279 __itt_report_error(__itt_error_system, "pthread_mutexattr_init", \ 280 error_code); \ 281 error_code = pthread_mutexattr_settype(&mutex_attr, \ 282 PTHREAD_MUTEX_RECURSIVE); \ 283 if (error_code) \ 284 __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", \ 285 error_code); \ 286 error_code = pthread_mutex_init(mutex, &mutex_attr); \ 287 if (error_code) \ 288 __itt_report_error(__itt_error_system, "pthread_mutex_init", \ 289 error_code); \ 290 error_code = pthread_mutexattr_destroy(&mutex_attr); \ 291 if (error_code) \ 292 __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", \ 293 error_code); \ 294 } 295 #define __itt_mutex_lock(mutex) pthread_mutex_lock(mutex) 296 #define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex) 297 #define __itt_load_lib(name) dlopen(name, RTLD_LAZY) 298 #define __itt_unload_lib(handle) dlclose(handle) 299 #define __itt_system_error() errno 300 #define __itt_fstrcmp(s1, s2) strcmp(s1, s2) 301 302 /* makes customer code define safe APIs for SDL_STRNLEN_S and SDL_STRNCPY_S */ 303 #ifdef SDL_STRNLEN_S 304 #define __itt_fstrnlen(s, l) SDL_STRNLEN_S(s, l) 305 #else 306 #define __itt_fstrnlen(s, l) strlen(s) 307 #endif /* SDL_STRNLEN_S */ 308 #ifdef SDL_STRNCPY_S 309 #define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l) 310 #else 311 #define __itt_fstrcpyn(s1, b, s2, l) { \ 312 if (b > 0) { \ 313 /* 'volatile' is used to suppress the warning that a destination */ \ 314 /* bound depends on the length of the source. */ \ 315 volatile size_t num_to_copy = (size_t)(b - 1) < (size_t)(l) ? \ 316 (size_t)(b - 1) : (size_t)(l); \ 317 strncpy(s1, s2, num_to_copy); \ 318 s1[num_to_copy] = 0; \ 319 } \ 320 } 321 #endif /* SDL_STRNCPY_S */ 322 323 #define __itt_fstrdup(s) strdup(s) 324 #define __itt_thread_id() pthread_self() 325 #define __itt_thread_yield() sched_yield() 326 #if ITT_ARCH==ITT_ARCH_IA64 327 #ifdef __INTEL_COMPILER 328 #define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val) 329 #else /* __INTEL_COMPILER */ 330 /* TODO: Add Support for not Intel compilers for IA-64 architecture */ 331 #endif /* __INTEL_COMPILER */ 332 #elif ITT_ARCH==ITT_ARCH_IA32 || ITT_ARCH==ITT_ARCH_IA32E /* ITT_ARCH!=ITT_ARCH_IA64 */ 333 ITT_INLINE long 334 __TBB_machine_fetchadd4(volatile void* ptr, long addend) ITT_INLINE_ATTRIBUTE; 335 ITT_INLINE long __TBB_machine_fetchadd4(volatile void* ptr, long addend) 336 { 337 long result; 338 __asm__ __volatile__("lock\nxadd %0,%1" 339 : "=r"(result),"=m"(*(volatile int*)ptr) 340 : "0"(addend), "m"(*(volatile int*)ptr) 341 : "memory"); 342 return result; 343 } 344 #else 345 #define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val) 346 #endif /* ITT_ARCH==ITT_ARCH_IA64 */ 347 #ifndef ITT_SIMPLE_INIT 348 ITT_INLINE long 349 __itt_interlocked_increment(volatile long* ptr) ITT_INLINE_ATTRIBUTE; 350 ITT_INLINE long __itt_interlocked_increment(volatile long* ptr) 351 { 352 return __TBB_machine_fetchadd4(ptr, 1) + 1L; 353 } 354 #endif /* ITT_SIMPLE_INIT */ 355 356 void* dlopen(const char*, int) __attribute__((weak)); 357 void* dlsym(void*, const char*) __attribute__((weak)); 358 int dlclose(void*) __attribute__((weak)); 359 #define DL_SYMBOLS (dlopen && dlsym && dlclose) 360 361 int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __attribute__((weak)); 362 int pthread_mutex_lock(pthread_mutex_t*) __attribute__((weak)); 363 int pthread_mutex_unlock(pthread_mutex_t*) __attribute__((weak)); 364 int pthread_mutex_destroy(pthread_mutex_t*) __attribute__((weak)); 365 int pthread_mutexattr_init(pthread_mutexattr_t*) __attribute__((weak)); 366 int pthread_mutexattr_settype(pthread_mutexattr_t*, int) __attribute__((weak)); 367 int pthread_mutexattr_destroy(pthread_mutexattr_t*) __attribute__((weak)); 368 pthread_t pthread_self(void) __attribute__((weak)); 369 #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) 370 371 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ 372 373 typedef enum { 374 __itt_collection_normal = 0, 375 __itt_collection_paused = 1 376 } __itt_collection_state; 377 378 typedef enum { 379 __itt_thread_normal = 0, 380 __itt_thread_ignored = 1 381 } __itt_thread_state; 382 383 #pragma pack(push, 8) 384 385 typedef struct ___itt_thread_info 386 { 387 const char* nameA; /*!< Copy of original name in ASCII. */ 388 #if defined(UNICODE) || defined(_UNICODE) 389 const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ 390 #else /* UNICODE || _UNICODE */ 391 void* nameW; 392 #endif /* UNICODE || _UNICODE */ 393 TIDT tid; 394 __itt_thread_state state; /*!< Thread state (paused or normal) */ 395 int extra1; /*!< Reserved to the runtime */ 396 void* extra2; /*!< Reserved to the runtime */ 397 struct ___itt_thread_info* next; 398 } __itt_thread_info; 399 400 #include "ittnotify_types.h" /* For __itt_group_id definition */ 401 402 typedef struct ___itt_api_info_20101001 403 { 404 const char* name; 405 void** func_ptr; 406 void* init_func; 407 __itt_group_id group; 408 } __itt_api_info_20101001; 409 410 typedef struct ___itt_api_info 411 { 412 const char* name; 413 void** func_ptr; 414 void* init_func; 415 void* null_func; 416 __itt_group_id group; 417 } __itt_api_info; 418 419 typedef struct __itt_counter_info 420 { 421 const char* nameA; /*!< Copy of original name in ASCII. */ 422 #if defined(UNICODE) || defined(_UNICODE) 423 const wchar_t* nameW; /*!< Copy of original name in UNICODE. */ 424 #else /* UNICODE || _UNICODE */ 425 void* nameW; 426 #endif /* UNICODE || _UNICODE */ 427 const char* domainA; /*!< Copy of original name in ASCII. */ 428 #if defined(UNICODE) || defined(_UNICODE) 429 const wchar_t* domainW; /*!< Copy of original name in UNICODE. */ 430 #else /* UNICODE || _UNICODE */ 431 void* domainW; 432 #endif /* UNICODE || _UNICODE */ 433 int type; 434 long index; 435 int extra1; /*!< Reserved to the runtime */ 436 void* extra2; /*!< Reserved to the runtime */ 437 struct __itt_counter_info* next; 438 } __itt_counter_info_t; 439 440 struct ___itt_domain; 441 struct ___itt_string_handle; 442 443 typedef struct ___itt_global 444 { 445 unsigned char magic[8]; 446 unsigned long version_major; 447 unsigned long version_minor; 448 unsigned long version_build; 449 volatile long api_initialized; 450 volatile long mutex_initialized; 451 volatile long atomic_counter; 452 mutex_t mutex; 453 lib_t lib; 454 void* error_handler; 455 const char** dll_path_ptr; 456 __itt_api_info* api_list_ptr; 457 struct ___itt_global* next; 458 /* Joinable structures below */ 459 __itt_thread_info* thread_list; 460 struct ___itt_domain* domain_list; 461 struct ___itt_string_handle* string_list; 462 __itt_collection_state state; 463 __itt_counter_info_t* counter_list; 464 unsigned int ipt_collect_events; 465 } __itt_global; 466 467 #pragma pack(pop) 468 469 #define NEW_THREAD_INFO_W(gptr,h,h_tail,t,s,n) { \ 470 h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ 471 if (h != NULL) { \ 472 h->tid = t; \ 473 h->nameA = NULL; \ 474 h->nameW = n ? _wcsdup(n) : NULL; \ 475 h->state = s; \ 476 h->extra1 = 0; /* reserved */ \ 477 h->extra2 = NULL; /* reserved */ \ 478 h->next = NULL; \ 479 if (h_tail == NULL) \ 480 (gptr)->thread_list = h; \ 481 else \ 482 h_tail->next = h; \ 483 } \ 484 } 485 486 #define NEW_THREAD_INFO_A(gptr,h,h_tail,t,s,n) { \ 487 h = (__itt_thread_info*)malloc(sizeof(__itt_thread_info)); \ 488 if (h != NULL) { \ 489 h->tid = t; \ 490 h->nameA = n ? __itt_fstrdup(n) : NULL; \ 491 h->nameW = NULL; \ 492 h->state = s; \ 493 h->extra1 = 0; /* reserved */ \ 494 h->extra2 = NULL; /* reserved */ \ 495 h->next = NULL; \ 496 if (h_tail == NULL) \ 497 (gptr)->thread_list = h; \ 498 else \ 499 h_tail->next = h; \ 500 } \ 501 } 502 503 #define NEW_DOMAIN_W(gptr,h,h_tail,name) { \ 504 h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ 505 if (h != NULL) { \ 506 h->flags = 1; /* domain is enabled by default */ \ 507 h->nameA = NULL; \ 508 h->nameW = name ? _wcsdup(name) : NULL; \ 509 h->extra1 = 0; /* reserved */ \ 510 h->extra2 = NULL; /* reserved */ \ 511 h->next = NULL; \ 512 if (h_tail == NULL) \ 513 (gptr)->domain_list = h; \ 514 else \ 515 h_tail->next = h; \ 516 } \ 517 } 518 519 #define NEW_DOMAIN_A(gptr,h,h_tail,name) { \ 520 h = (__itt_domain*)malloc(sizeof(__itt_domain)); \ 521 if (h != NULL) { \ 522 h->flags = 1; /* domain is enabled by default */ \ 523 h->nameA = name ? __itt_fstrdup(name) : NULL; \ 524 h->nameW = NULL; \ 525 h->extra1 = 0; /* reserved */ \ 526 h->extra2 = NULL; /* reserved */ \ 527 h->next = NULL; \ 528 if (h_tail == NULL) \ 529 (gptr)->domain_list = h; \ 530 else \ 531 h_tail->next = h; \ 532 } \ 533 } 534 535 #define NEW_STRING_HANDLE_W(gptr,h,h_tail,name) { \ 536 h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ 537 if (h != NULL) { \ 538 h->strA = NULL; \ 539 h->strW = name ? _wcsdup(name) : NULL; \ 540 h->extra1 = 0; /* reserved */ \ 541 h->extra2 = NULL; /* reserved */ \ 542 h->next = NULL; \ 543 if (h_tail == NULL) \ 544 (gptr)->string_list = h; \ 545 else \ 546 h_tail->next = h; \ 547 } \ 548 } 549 550 #define NEW_STRING_HANDLE_A(gptr,h,h_tail,name) { \ 551 h = (__itt_string_handle*)malloc(sizeof(__itt_string_handle)); \ 552 if (h != NULL) { \ 553 h->strA = name ? __itt_fstrdup(name) : NULL; \ 554 h->strW = NULL; \ 555 h->extra1 = 0; /* reserved */ \ 556 h->extra2 = NULL; /* reserved */ \ 557 h->next = NULL; \ 558 if (h_tail == NULL) \ 559 (gptr)->string_list = h; \ 560 else \ 561 h_tail->next = h; \ 562 } \ 563 } 564 565 #define NEW_COUNTER_W(gptr,h,h_tail,name,domain,type) { \ 566 h = (__itt_counter_info_t*)malloc(sizeof(__itt_counter_info_t)); \ 567 if (h != NULL) { \ 568 h->nameA = NULL; \ 569 h->nameW = name ? _wcsdup(name) : NULL; \ 570 h->domainA = NULL; \ 571 h->domainW = name ? _wcsdup(domain) : NULL; \ 572 h->type = type; \ 573 h->index = 0; \ 574 h->next = NULL; \ 575 if (h_tail == NULL) \ 576 (gptr)->counter_list = h; \ 577 else \ 578 h_tail->next = h; \ 579 } \ 580 } 581 582 #define NEW_COUNTER_A(gptr,h,h_tail,name,domain,type) { \ 583 h = (__itt_counter_info_t*)malloc(sizeof(__itt_counter_info_t)); \ 584 if (h != NULL) { \ 585 h->nameA = name ? __itt_fstrdup(name) : NULL; \ 586 h->nameW = NULL; \ 587 h->domainA = domain ? __itt_fstrdup(domain) : NULL; \ 588 h->domainW = NULL; \ 589 h->type = type; \ 590 h->index = 0; \ 591 h->next = NULL; \ 592 if (h_tail == NULL) \ 593 (gptr)->counter_list = h; \ 594 else \ 595 h_tail->next = h; \ 596 } \ 597 } 598 599 #endif /* _ITTNOTIFY_CONFIG_H_ */ 600