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