ittnotify_config.h 20 KB

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