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_VE
166 #define ITT_ARCH_VE 8
167 #endif /* ITT_ARCH_VE */
168
169 #ifndef ITT_ARCH_S390X
170 #define ITT_ARCH_S390X 8
171 #endif /* ITT_ARCH_S390X */
172
173 #ifndef ITT_ARCH
174 #if defined _M_IX86 || defined __i386__
175 #define ITT_ARCH ITT_ARCH_IA32
176 #elif defined _M_X64 || defined _M_AMD64 || defined __x86_64__
177 #define ITT_ARCH ITT_ARCH_IA32E
178 #elif defined _M_IA64 || defined __ia64__
179 #define ITT_ARCH ITT_ARCH_IA64
180 #elif defined _M_ARM || defined __arm__
181 #define ITT_ARCH ITT_ARCH_ARM
182 #elif defined __aarch64__
183 #define ITT_ARCH ITT_ARCH_ARM64
184 #elif defined __powerpc64__
185 #define ITT_ARCH ITT_ARCH_PPC64
186 #elif defined __ve__
187 #define ITT_ARCH ITT_ARCH_VE
188 #elif defined __s390x__
189 #define ITT_ARCH ITT_ARCH_S390X
190 #endif
191 #endif
192
193 #ifdef __cplusplus
194 #define ITT_EXTERN_C extern "C"
195 #define ITT_EXTERN_C_BEGIN extern "C" {
196 #define ITT_EXTERN_C_END }
197 #else
198 #define ITT_EXTERN_C /* nothing */
199 #define ITT_EXTERN_C_BEGIN /* nothing */
200 #define ITT_EXTERN_C_END /* nothing */
201 #endif /* __cplusplus */
202
203 #define ITT_TO_STR_AUX(x) #x
204 #define ITT_TO_STR(x) ITT_TO_STR_AUX(x)
205
206 #define __ITT_BUILD_ASSERT(expr, suffix) \
207 do { \
208 static char __itt_build_check_##suffix[(expr) ? 1 : -1]; \
209 __itt_build_check_##suffix[0] = 0; \
210 } while (0)
211 #define _ITT_BUILD_ASSERT(expr, suffix) __ITT_BUILD_ASSERT((expr), suffix)
212 #define ITT_BUILD_ASSERT(expr) _ITT_BUILD_ASSERT((expr), __LINE__)
213
214 #define ITT_MAGIC \
215 { 0xED, 0xAB, 0xAB, 0xEC, 0x0D, 0xEE, 0xDA, 0x30 }
216
217 /* Replace with snapshot date YYYYMMDD for promotion build. */
218 #define API_VERSION_BUILD 20180723
219
220 #ifndef API_VERSION_NUM
221 #define API_VERSION_NUM 3.20.1
222 #endif /* API_VERSION_NUM */
223
224 #define API_VERSION \
225 "ITT-API-Version " ITT_TO_STR(API_VERSION_NUM) " (" ITT_TO_STR( \
226 API_VERSION_BUILD) ")"
227
228 /* OS communication functions */
229 #if ITT_PLATFORM == ITT_PLATFORM_WIN
230 #include <windows.h>
231 typedef HMODULE lib_t;
232 typedef DWORD TIDT;
233 typedef CRITICAL_SECTION mutex_t;
234 #ifdef __cplusplus
235 #define MUTEX_INITIALIZER \
236 {}
237 #else
238 #define MUTEX_INITIALIZER \
239 { 0 }
240 #endif
241 #define strong_alias(name, aliasname) /* empty for Windows */
242 #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
243 #include <dlfcn.h>
244 #if defined(UNICODE) || defined(_UNICODE)
245 #include <wchar.h>
246 #endif /* UNICODE */
247 #ifndef _GNU_SOURCE
248 #define _GNU_SOURCE 1 /* need for PTHREAD_MUTEX_RECURSIVE */
249 #endif /* _GNU_SOURCE */
250 #ifndef __USE_UNIX98
251 #define __USE_UNIX98 \
252 1 /* need for PTHREAD_MUTEX_RECURSIVE, on SLES11.1 with gcc 4.3.4 wherein \
253 pthread.h missing dependency on __USE_XOPEN2K8 */
254 #endif /*__USE_UNIX98*/
255 #include <pthread.h>
256 typedef void *lib_t;
257 typedef pthread_t TIDT;
258 typedef pthread_mutex_t mutex_t;
259 #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
260 #define _strong_alias(name, aliasname) \
261 extern __typeof(name) aliasname __attribute__((alias(#name)));
262 #define strong_alias(name, aliasname) _strong_alias(name, aliasname)
263 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
264
265 #if ITT_PLATFORM == ITT_PLATFORM_WIN
266 #define __itt_get_proc(lib, name) GetProcAddress(lib, name)
267 #define __itt_mutex_init(mutex) InitializeCriticalSection(mutex)
268 #define __itt_mutex_lock(mutex) EnterCriticalSection(mutex)
269 #define __itt_mutex_unlock(mutex) LeaveCriticalSection(mutex)
270 #define __itt_load_lib(name) LoadLibraryA(name)
271 #define __itt_unload_lib(handle) FreeLibrary(handle)
272 #define __itt_system_error() (int)GetLastError()
273 #define __itt_fstrcmp(s1, s2) lstrcmpA(s1, s2)
274 #define __itt_fstrnlen(s, l) strnlen_s(s, l)
275 #define __itt_fstrcpyn(s1, b, s2, l) strncpy_s(s1, b, s2, l)
276 #define __itt_fstrdup(s) _strdup(s)
277 #define __itt_thread_id() GetCurrentThreadId()
278 #define __itt_thread_yield() SwitchToThread()
279 #ifndef ITT_SIMPLE_INIT
280 ITT_INLINE long
281 __itt_interlocked_increment(volatile long *ptr) ITT_INLINE_ATTRIBUTE;
__itt_interlocked_increment(volatile long * ptr)282 ITT_INLINE long __itt_interlocked_increment(volatile long *ptr) {
283 return InterlockedIncrement(ptr);
284 }
285 #endif /* ITT_SIMPLE_INIT */
286
287 #define DL_SYMBOLS (1)
288 #define PTHREAD_SYMBOLS (1)
289
290 #else /* ITT_PLATFORM!=ITT_PLATFORM_WIN */
291 #define __itt_get_proc(lib, name) dlsym(lib, name)
292 #define __itt_mutex_init(mutex) \
293 { \
294 pthread_mutexattr_t mutex_attr; \
295 int error_code = pthread_mutexattr_init(&mutex_attr); \
296 if (error_code) \
297 __itt_report_error(__itt_error_system, "pthread_mutexattr_init", \
298 error_code); \
299 error_code = \
300 pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE); \
301 if (error_code) \
302 __itt_report_error(__itt_error_system, "pthread_mutexattr_settype", \
303 error_code); \
304 error_code = pthread_mutex_init(mutex, &mutex_attr); \
305 if (error_code) \
306 __itt_report_error(__itt_error_system, "pthread_mutex_init", \
307 error_code); \
308 error_code = pthread_mutexattr_destroy(&mutex_attr); \
309 if (error_code) \
310 __itt_report_error(__itt_error_system, "pthread_mutexattr_destroy", \
311 error_code); \
312 }
313 #define __itt_mutex_lock(mutex) pthread_mutex_lock(mutex)
314 #define __itt_mutex_unlock(mutex) pthread_mutex_unlock(mutex)
315 #define __itt_load_lib(name) dlopen(name, RTLD_LAZY)
316 #define __itt_unload_lib(handle) dlclose(handle)
317 #define __itt_system_error() errno
318 #define __itt_fstrcmp(s1, s2) strcmp(s1, s2)
319
320 /* makes customer code define safe APIs for SDL_STRNLEN_S and SDL_STRNCPY_S */
321 #ifdef SDL_STRNLEN_S
322 #define __itt_fstrnlen(s, l) SDL_STRNLEN_S(s, l)
323 #else
324 #define __itt_fstrnlen(s, l) strlen(s)
325 #endif /* SDL_STRNLEN_S */
326 #ifdef SDL_STRNCPY_S
327 #define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l)
328 #else
329 #define __itt_fstrcpyn(s1, b, s2, l) \
330 { \
331 if (b > 0) { \
332 /* 'volatile' is used to suppress the warning that a destination */ \
333 /* bound depends on the length of the source. */ \
334 volatile size_t num_to_copy = \
335 (size_t)(b - 1) < (size_t)(l) ? (size_t)(b - 1) : (size_t)(l); \
336 strncpy(s1, s2, num_to_copy); \
337 s1[num_to_copy] = 0; \
338 } \
339 }
340 #endif /* SDL_STRNCPY_S */
341
342 #define __itt_fstrdup(s) strdup(s)
343 #define __itt_thread_id() pthread_self()
344 #define __itt_thread_yield() sched_yield()
345 #if ITT_ARCH == ITT_ARCH_IA64
346 #ifdef __INTEL_COMPILER
347 #define __TBB_machine_fetchadd4(addr, val) __fetchadd4_acq((void *)addr, val)
348 #else /* __INTEL_COMPILER */
349 /* TODO: Add Support for not Intel compilers for IA-64 architecture */
350 #endif /* __INTEL_COMPILER */
351 #elif ITT_ARCH == ITT_ARCH_IA32 || \
352 ITT_ARCH == ITT_ARCH_IA32E /* ITT_ARCH!=ITT_ARCH_IA64 */
353 ITT_INLINE long __TBB_machine_fetchadd4(volatile void *ptr,
354 long addend) ITT_INLINE_ATTRIBUTE;
__TBB_machine_fetchadd4(volatile void * ptr,long addend)355 ITT_INLINE long __TBB_machine_fetchadd4(volatile void *ptr, long addend) {
356 long result;
357 __asm__ __volatile__("lock\nxadd %0,%1"
358 : "=r"(result), "=m"(*(volatile int *)ptr)
359 : "0"(addend), "m"(*(volatile int *)ptr)
360 : "memory");
361 return result;
362 }
363 #else
364 #define __TBB_machine_fetchadd4(addr, val) __sync_fetch_and_add(addr, val)
365 #endif /* ITT_ARCH==ITT_ARCH_IA64 */
366 #ifndef ITT_SIMPLE_INIT
367 ITT_INLINE long
368 __itt_interlocked_increment(volatile long *ptr) ITT_INLINE_ATTRIBUTE;
__itt_interlocked_increment(volatile long * ptr)369 ITT_INLINE long __itt_interlocked_increment(volatile long *ptr) {
370 return __TBB_machine_fetchadd4(ptr, 1) + 1L;
371 }
372 #endif /* ITT_SIMPLE_INIT */
373
374 void *dlopen(const char *, int) __attribute__((weak));
375 void *dlsym(void *, const char *) __attribute__((weak));
376 int dlclose(void *) __attribute__((weak));
377 #define DL_SYMBOLS (dlopen && dlsym && dlclose)
378
379 int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *)
380 __attribute__((weak));
381 int pthread_mutex_lock(pthread_mutex_t *) __attribute__((weak));
382 int pthread_mutex_unlock(pthread_mutex_t *) __attribute__((weak));
383 int pthread_mutex_destroy(pthread_mutex_t *) __attribute__((weak));
384 int pthread_mutexattr_init(pthread_mutexattr_t *) __attribute__((weak));
385 int pthread_mutexattr_settype(pthread_mutexattr_t *, int) __attribute__((weak));
386 int pthread_mutexattr_destroy(pthread_mutexattr_t *) __attribute__((weak));
387 pthread_t pthread_self(void) __attribute__((weak));
388 #define PTHREAD_SYMBOLS \
389 (pthread_mutex_init && pthread_mutex_lock && pthread_mutex_unlock && \
390 pthread_mutex_destroy && pthread_mutexattr_init && \
391 pthread_mutexattr_settype && pthread_mutexattr_destroy && pthread_self)
392
393 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
394
395 typedef enum {
396 __itt_collection_normal = 0,
397 __itt_collection_paused = 1
398 } __itt_collection_state;
399
400 typedef enum {
401 __itt_thread_normal = 0,
402 __itt_thread_ignored = 1
403 } __itt_thread_state;
404
405 #pragma pack(push, 8)
406
407 typedef struct ___itt_thread_info {
408 const char *nameA; /*!< Copy of original name in ASCII. */
409 #if defined(UNICODE) || defined(_UNICODE)
410 const wchar_t *nameW; /*!< Copy of original name in UNICODE. */
411 #else /* UNICODE || _UNICODE */
412 void *nameW;
413 #endif /* UNICODE || _UNICODE */
414 TIDT tid;
415 __itt_thread_state state; /*!< Thread state (paused or normal) */
416 int extra1; /*!< Reserved to the runtime */
417 void *extra2; /*!< Reserved to the runtime */
418 struct ___itt_thread_info *next;
419 } __itt_thread_info;
420
421 #include "ittnotify_types.h" /* For __itt_group_id definition */
422
423 typedef struct ___itt_api_info_20101001 {
424 const char *name;
425 void **func_ptr;
426 void *init_func;
427 __itt_group_id group;
428 } __itt_api_info_20101001;
429
430 typedef struct ___itt_api_info {
431 const char *name;
432 void **func_ptr;
433 void *init_func;
434 void *null_func;
435 __itt_group_id group;
436 } __itt_api_info;
437
438 typedef struct __itt_counter_info {
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 extra1; /*!< Reserved to the runtime */
454 void *extra2; /*!< 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 typedef struct ___itt_global {
463 unsigned char magic[8];
464 unsigned long version_major;
465 unsigned long version_minor;
466 unsigned long version_build;
467 volatile long api_initialized;
468 volatile long mutex_initialized;
469 volatile long atomic_counter;
470 mutex_t mutex;
471 lib_t lib;
472 void *error_handler;
473 const char **dll_path_ptr;
474 __itt_api_info *api_list_ptr;
475 struct ___itt_global *next;
476 /* Joinable structures below */
477 __itt_thread_info *thread_list;
478 struct ___itt_domain *domain_list;
479 struct ___itt_string_handle *string_list;
480 __itt_collection_state state;
481 __itt_counter_info_t *counter_list;
482 unsigned int ipt_collect_events;
483 struct ___itt_histogram *histogram_list;
484 } __itt_global;
485
486 #pragma pack(pop)
487
488 #define NEW_THREAD_INFO_W(gptr, h, h_tail, t, s, n) \
489 { \
490 h = (__itt_thread_info *)malloc(sizeof(__itt_thread_info)); \
491 if (h != NULL) { \
492 h->tid = t; \
493 h->nameA = NULL; \
494 h->nameW = n ? _wcsdup(n) : NULL; \
495 h->state = s; \
496 h->extra1 = 0; /* reserved */ \
497 h->extra2 = NULL; /* reserved */ \
498 h->next = NULL; \
499 if (h_tail == NULL) \
500 (gptr)->thread_list = h; \
501 else \
502 h_tail->next = h; \
503 } \
504 }
505
506 #define NEW_THREAD_INFO_A(gptr, h, h_tail, t, s, n) \
507 { \
508 h = (__itt_thread_info *)malloc(sizeof(__itt_thread_info)); \
509 if (h != NULL) { \
510 h->tid = t; \
511 h->nameA = n ? __itt_fstrdup(n) : NULL; \
512 h->nameW = NULL; \
513 h->state = s; \
514 h->extra1 = 0; /* reserved */ \
515 h->extra2 = NULL; /* reserved */ \
516 h->next = NULL; \
517 if (h_tail == NULL) \
518 (gptr)->thread_list = h; \
519 else \
520 h_tail->next = h; \
521 } \
522 }
523
524 #define NEW_DOMAIN_W(gptr, h, h_tail, name) \
525 { \
526 h = (__itt_domain *)malloc(sizeof(__itt_domain)); \
527 if (h != NULL) { \
528 h->flags = 1; /* domain is enabled by default */ \
529 h->nameA = NULL; \
530 h->nameW = name ? _wcsdup(name) : NULL; \
531 h->extra1 = 0; /* reserved */ \
532 h->extra2 = NULL; /* reserved */ \
533 h->next = NULL; \
534 if (h_tail == NULL) \
535 (gptr)->domain_list = h; \
536 else \
537 h_tail->next = h; \
538 } \
539 }
540
541 #define NEW_DOMAIN_A(gptr, h, h_tail, name) \
542 { \
543 h = (__itt_domain *)malloc(sizeof(__itt_domain)); \
544 if (h != NULL) { \
545 h->flags = 1; /* domain is enabled by default */ \
546 h->nameA = name ? __itt_fstrdup(name) : NULL; \
547 h->nameW = NULL; \
548 h->extra1 = 0; /* reserved */ \
549 h->extra2 = NULL; /* reserved */ \
550 h->next = NULL; \
551 if (h_tail == NULL) \
552 (gptr)->domain_list = h; \
553 else \
554 h_tail->next = h; \
555 } \
556 }
557
558 #define NEW_STRING_HANDLE_W(gptr, h, h_tail, name) \
559 { \
560 h = (__itt_string_handle *)malloc(sizeof(__itt_string_handle)); \
561 if (h != NULL) { \
562 h->strA = NULL; \
563 h->strW = name ? _wcsdup(name) : NULL; \
564 h->extra1 = 0; /* reserved */ \
565 h->extra2 = NULL; /* reserved */ \
566 h->next = NULL; \
567 if (h_tail == NULL) \
568 (gptr)->string_list = h; \
569 else \
570 h_tail->next = h; \
571 } \
572 }
573
574 #define NEW_STRING_HANDLE_A(gptr, h, h_tail, name) \
575 { \
576 h = (__itt_string_handle *)malloc(sizeof(__itt_string_handle)); \
577 if (h != NULL) { \
578 h->strA = name ? __itt_fstrdup(name) : NULL; \
579 h->strW = NULL; \
580 h->extra1 = 0; /* reserved */ \
581 h->extra2 = NULL; /* reserved */ \
582 h->next = NULL; \
583 if (h_tail == NULL) \
584 (gptr)->string_list = h; \
585 else \
586 h_tail->next = h; \
587 } \
588 }
589
590 #define NEW_COUNTER_W(gptr, h, h_tail, name, domain, type) \
591 { \
592 h = (__itt_counter_info_t *)malloc(sizeof(__itt_counter_info_t)); \
593 if (h != NULL) { \
594 h->nameA = NULL; \
595 h->nameW = name ? _wcsdup(name) : NULL; \
596 h->domainA = NULL; \
597 h->domainW = name ? _wcsdup(domain) : NULL; \
598 h->type = type; \
599 h->index = 0; \
600 h->next = NULL; \
601 if (h_tail == NULL) \
602 (gptr)->counter_list = h; \
603 else \
604 h_tail->next = h; \
605 } \
606 }
607
608 #define NEW_COUNTER_A(gptr, h, h_tail, name, domain, type) \
609 { \
610 h = (__itt_counter_info_t *)malloc(sizeof(__itt_counter_info_t)); \
611 if (h != NULL) { \
612 h->nameA = name ? __itt_fstrdup(name) : NULL; \
613 h->nameW = NULL; \
614 h->domainA = domain ? __itt_fstrdup(domain) : NULL; \
615 h->domainW = NULL; \
616 h->type = type; \
617 h->index = 0; \
618 h->next = NULL; \
619 if (h_tail == NULL) \
620 (gptr)->counter_list = h; \
621 else \
622 h_tail->next = h; \
623 } \
624 }
625
626 #define NEW_HISTOGRAM_W(gptr, h, h_tail, domain, name, x_type, y_type) \
627 { \
628 h = (__itt_histogram *)malloc(sizeof(__itt_histogram)); \
629 if (h != NULL) { \
630 h->domain = domain; \
631 h->nameA = NULL; \
632 h->nameW = name ? _wcsdup(name) : NULL; \
633 h->x_type = x_type; \
634 h->y_type = y_type; \
635 h->extra1 = 0; \
636 h->extra2 = NULL; \
637 if (h_tail == NULL) \
638 (gptr)->histogram_list = h; \
639 else \
640 h_tail->next = h; \
641 } \
642 }
643
644 #define NEW_HISTOGRAM_A(gptr, h, h_tail, domain, name, x_type, y_type) \
645 { \
646 h = (__itt_histogram *)malloc(sizeof(__itt_histogram)); \
647 if (h != NULL) { \
648 h->domain = domain; \
649 h->nameA = name ? __itt_fstrdup(name) : NULL; \
650 h->nameW = NULL; \
651 h->x_type = x_type; \
652 h->y_type = y_type; \
653 h->extra1 = 0; \
654 h->extra2 = NULL; \
655 if (h_tail == NULL) \
656 (gptr)->histogram_list = h; \
657 else \
658 h_tail->next = h; \
659 } \
660 }
661
662 #endif /* _ITTNOTIFY_CONFIG_H_ */
663