ittnotify_config.h 18 KB

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