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