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