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