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