ittnotify.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 _INTERNAL_ITTNOTIFY_H_
  48. #define _INTERNAL_ITTNOTIFY_H_
  49. /**
  50. * @file
  51. * @brief Internal User API functions and types
  52. */
  53. /** @cond exclude_from_documentation */
  54. #ifndef ITT_OS_WIN
  55. # define ITT_OS_WIN 1
  56. #endif /* ITT_OS_WIN */
  57. #ifndef ITT_OS_LINUX
  58. # define ITT_OS_LINUX 2
  59. #endif /* ITT_OS_LINUX */
  60. #ifndef ITT_OS_MAC
  61. # define ITT_OS_MAC 3
  62. #endif /* ITT_OS_MAC */
  63. #ifndef ITT_OS_FREEBSD
  64. # define ITT_OS_FREEBSD 4
  65. #endif /* ITT_OS_FREEBSD */
  66. #ifndef ITT_OS
  67. # if defined WIN32 || defined _WIN32
  68. # define ITT_OS ITT_OS_WIN
  69. # elif defined( __APPLE__ ) && defined( __MACH__ )
  70. # define ITT_OS ITT_OS_MAC
  71. # elif defined( __FreeBSD__ )
  72. # define ITT_OS ITT_OS_FREEBSD
  73. # else
  74. # define ITT_OS ITT_OS_LINUX
  75. # endif
  76. #endif /* ITT_OS */
  77. #ifndef ITT_PLATFORM_WIN
  78. # define ITT_PLATFORM_WIN 1
  79. #endif /* ITT_PLATFORM_WIN */
  80. #ifndef ITT_PLATFORM_POSIX
  81. # define ITT_PLATFORM_POSIX 2
  82. #endif /* ITT_PLATFORM_POSIX */
  83. #ifndef ITT_PLATFORM_MAC
  84. # define ITT_PLATFORM_MAC 3
  85. #endif /* ITT_PLATFORM_MAC */
  86. #ifndef ITT_PLATFORM_FREEBSD
  87. # define ITT_PLATFORM_FREEBSD 4
  88. #endif /* ITT_PLATFORM_FREEBSD */
  89. #ifndef ITT_PLATFORM
  90. # if ITT_OS==ITT_OS_WIN
  91. # define ITT_PLATFORM ITT_PLATFORM_WIN
  92. # elif ITT_OS==ITT_OS_MAC
  93. # define ITT_PLATFORM ITT_PLATFORM_MAC
  94. # elif ITT_OS==ITT_OS_FREEBSD
  95. # define ITT_PLATFORM ITT_PLATFORM_FREEBSD
  96. # else
  97. # define ITT_PLATFORM ITT_PLATFORM_POSIX
  98. # endif
  99. #endif /* ITT_PLATFORM */
  100. #if defined(_UNICODE) && !defined(UNICODE)
  101. #define UNICODE
  102. #endif
  103. #include <stddef.h>
  104. #if ITT_PLATFORM==ITT_PLATFORM_WIN
  105. #include <tchar.h>
  106. #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
  107. #include <stdint.h>
  108. #if defined(UNICODE) || defined(_UNICODE)
  109. #include <wchar.h>
  110. #endif /* UNICODE || _UNICODE */
  111. #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
  112. #ifndef CDECL
  113. # if ITT_PLATFORM==ITT_PLATFORM_WIN
  114. # define CDECL __cdecl
  115. # else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
  116. # if defined _M_IX86 || defined __i386__
  117. # define CDECL __attribute__ ((cdecl))
  118. # else /* _M_IX86 || __i386__ */
  119. # define CDECL /* actual only on x86 platform */
  120. # endif /* _M_IX86 || __i386__ */
  121. # endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
  122. #endif /* CDECL */
  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. #define ITTAPI CDECL
  135. #define LIBITTAPI CDECL
  136. /* TODO: Temporary for compatibility! */
  137. #define ITTAPI_CALL CDECL
  138. #define LIBITTAPI_CALL CDECL
  139. #if ITT_PLATFORM==ITT_PLATFORM_WIN
  140. /* use __forceinline (VC++ specific) */
  141. #define ITT_INLINE __forceinline
  142. #define ITT_INLINE_ATTRIBUTE /* nothing */
  143. #else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
  144. /*
  145. * Generally, functions are not inlined unless optimization is specified.
  146. * For functions declared inline, this attribute inlines the function even
  147. * if no optimization level was specified.
  148. */
  149. #ifdef __STRICT_ANSI__
  150. #define ITT_INLINE static
  151. #define ITT_INLINE_ATTRIBUTE __attribute__((unused))
  152. #else /* __STRICT_ANSI__ */
  153. #define ITT_INLINE static inline
  154. #define ITT_INLINE_ATTRIBUTE __attribute__((always_inline, unused))
  155. #endif /* __STRICT_ANSI__ */
  156. #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
  157. /** @endcond */
  158. /** @cond exclude_from_documentation */
  159. /* Helper macro for joining tokens */
  160. #define ITT_JOIN_AUX(p,n) p##n
  161. #define ITT_JOIN(p,n) ITT_JOIN_AUX(p,n)
  162. #ifdef ITT_MAJOR
  163. #undef ITT_MAJOR
  164. #endif
  165. #ifdef ITT_MINOR
  166. #undef ITT_MINOR
  167. #endif
  168. #define ITT_MAJOR 3
  169. #define ITT_MINOR 0
  170. /* Standard versioning of a token with major and minor version numbers */
  171. #define ITT_VERSIONIZE(x) \
  172. ITT_JOIN(x, \
  173. ITT_JOIN(_, \
  174. ITT_JOIN(ITT_MAJOR, \
  175. ITT_JOIN(_, ITT_MINOR))))
  176. #ifndef INTEL_ITTNOTIFY_PREFIX
  177. # define INTEL_ITTNOTIFY_PREFIX __itt_
  178. #endif /* INTEL_ITTNOTIFY_PREFIX */
  179. #ifndef INTEL_ITTNOTIFY_POSTFIX
  180. # define INTEL_ITTNOTIFY_POSTFIX _ptr_
  181. #endif /* INTEL_ITTNOTIFY_POSTFIX */
  182. #define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n)
  183. #define ITTNOTIFY_NAME(n) ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX)))
  184. #define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)
  185. #define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)
  186. #define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d)
  187. #define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x)
  188. #define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y)
  189. #define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z)
  190. #define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
  191. #define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
  192. #define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
  193. #define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d)
  194. #define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x)
  195. #define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y)
  196. #define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z)
  197. #define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
  198. #define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
  199. #define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
  200. #ifdef ITT_STUB
  201. #undef ITT_STUB
  202. #endif
  203. #ifdef ITT_STUBV
  204. #undef ITT_STUBV
  205. #endif
  206. #define ITT_STUBV(api,type,name,args) \
  207. typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args; \
  208. extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name);
  209. #define ITT_STUB ITT_STUBV
  210. /** @endcond */
  211. #ifdef __cplusplus
  212. extern "C" {
  213. #endif /* __cplusplus */
  214. #define INTEL_ITTNOTIFY_API_PRIVATE
  215. #include "../ittnotify.h"
  216. #ifdef __cplusplus
  217. }
  218. #endif /* __cplusplus */
  219. #endif /* _INTERNAL_ITTNOTIFY_H_ */