1 /*
2     Copyright 2005-2014 Intel Corporation.  All Rights Reserved.
3 
4     This file is part of Threading Building Blocks. Threading Building Blocks is free software;
5     you can redistribute it and/or modify it under the terms of the GNU General Public License
6     version 2  as  published  by  the  Free Software Foundation.  Threading Building Blocks is
7     distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
8     implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9     See  the GNU General Public License for more details.   You should have received a copy of
10     the  GNU General Public License along with Threading Building Blocks; if not, write to the
11     Free Software Foundation, Inc.,  51 Franklin St,  Fifth Floor,  Boston,  MA 02110-1301 USA
12 
13     As a special exception,  you may use this file  as part of a free software library without
14     restriction.  Specifically,  if other files instantiate templates  or use macros or inline
15     functions from this file, or you compile this file and link it with other files to produce
16     an executable,  this file does not by itself cause the resulting executable to be covered
17     by the GNU General Public License. This exception does not however invalidate any other
18     reasons why the executable file might be covered by the GNU General Public License.
19 */
20 
21 #ifndef _INTERNAL_ITTNOTIFY_H_
22 #define _INTERNAL_ITTNOTIFY_H_
23 
24 /**
25  * @file
26  * @brief Internal User API functions and types
27  */
28 
29 /** @cond exclude_from_documentation */
30 #ifndef ITT_OS_WIN
31 #  define ITT_OS_WIN   1
32 #endif /* ITT_OS_WIN */
33 
34 #ifndef ITT_OS_LINUX
35 #  define ITT_OS_LINUX 2
36 #endif /* ITT_OS_LINUX */
37 
38 #ifndef ITT_OS_MAC
39 #  define ITT_OS_MAC   3
40 #endif /* ITT_OS_MAC */
41 
42 #ifndef ITT_OS
43 #  if defined WIN32 || defined _WIN32
44 #    define ITT_OS ITT_OS_WIN
45 #  elif defined( __APPLE__ ) && defined( __MACH__ )
46 #    define ITT_OS ITT_OS_MAC
47 #  else
48 #    define ITT_OS ITT_OS_LINUX
49 #  endif
50 #endif /* ITT_OS */
51 
52 #ifndef ITT_PLATFORM_WIN
53 #  define ITT_PLATFORM_WIN 1
54 #endif /* ITT_PLATFORM_WIN */
55 
56 #ifndef ITT_PLATFORM_POSIX
57 #  define ITT_PLATFORM_POSIX 2
58 #endif /* ITT_PLATFORM_POSIX */
59 
60 #ifndef ITT_PLATFORM_MAC
61 #  define ITT_PLATFORM_MAC 3
62 #endif /* ITT_PLATFORM_MAC */
63 
64 #ifndef ITT_PLATFORM
65 #  if ITT_OS==ITT_OS_WIN
66 #    define ITT_PLATFORM ITT_PLATFORM_WIN
67 #  elif ITT_OS==ITT_OS_MAC
68 #    define ITT_PLATFORM ITT_PLATFORM_MAC
69 #  else
70 #    define ITT_PLATFORM ITT_PLATFORM_POSIX
71 #  endif
72 #endif /* ITT_PLATFORM */
73 
74 #if defined(_UNICODE) && !defined(UNICODE)
75 #define UNICODE
76 #endif
77 
78 #include <stddef.h>
79 #if ITT_PLATFORM==ITT_PLATFORM_WIN
80 #include <tchar.h>
81 #else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
82 #include <stdint.h>
83 #if defined(UNICODE) || defined(_UNICODE)
84 #include <wchar.h>
85 #endif /* UNICODE || _UNICODE */
86 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
87 
88 #ifndef CDECL
89 #  if ITT_PLATFORM==ITT_PLATFORM_WIN
90 #    define CDECL __cdecl
91 #  else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
92 #    if defined _M_IX86 || defined __i386__
93 #      define CDECL __attribute__ ((cdecl))
94 #    else  /* _M_IX86 || __i386__ */
95 #      define CDECL /* actual only on x86 platform */
96 #    endif /* _M_IX86 || __i386__ */
97 #  endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
98 #endif /* CDECL */
99 
100 #ifndef STDCALL
101 #  if ITT_PLATFORM==ITT_PLATFORM_WIN
102 #    define STDCALL __stdcall
103 #  else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
104 #    if defined _M_IX86 || defined __i386__
105 #      define STDCALL __attribute__ ((stdcall))
106 #    else  /* _M_IX86 || __i386__ */
107 #      define STDCALL /* supported only on x86 platform */
108 #    endif /* _M_IX86 || __i386__ */
109 #  endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
110 #endif /* STDCALL */
111 
112 #define ITTAPI    CDECL
113 #define LIBITTAPI CDECL
114 
115 /* TODO: Temporary for compatibility! */
116 #define ITTAPI_CALL    CDECL
117 #define LIBITTAPI_CALL CDECL
118 
119 #if ITT_PLATFORM==ITT_PLATFORM_WIN
120 /* use __forceinline (VC++ specific) */
121 #define ITT_INLINE           __forceinline
122 #define ITT_INLINE_ATTRIBUTE /* nothing */
123 #else  /* ITT_PLATFORM==ITT_PLATFORM_WIN */
124 /*
125  * Generally, functions are not inlined unless optimization is specified.
126  * For functions declared inline, this attribute inlines the function even
127  * if no optimization level was specified.
128  */
129 #ifdef __STRICT_ANSI__
130 #define ITT_INLINE           static
131 #else  /* __STRICT_ANSI__ */
132 #define ITT_INLINE           static inline
133 #endif /* __STRICT_ANSI__ */
134 #define ITT_INLINE_ATTRIBUTE __attribute__ ((always_inline, unused))
135 #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
136 /** @endcond */
137 
138 /** @cond exclude_from_documentation */
139 /* Helper macro for joining tokens */
140 #define ITT_JOIN_AUX(p,n) p##n
141 #define ITT_JOIN(p,n)     ITT_JOIN_AUX(p,n)
142 
143 #ifdef ITT_MAJOR
144 #undef ITT_MAJOR
145 #endif
146 #ifdef ITT_MINOR
147 #undef ITT_MINOR
148 #endif
149 #define ITT_MAJOR     3
150 #define ITT_MINOR     0
151 
152 /* Standard versioning of a token with major and minor version numbers */
153 #define ITT_VERSIONIZE(x)    \
154     ITT_JOIN(x,              \
155     ITT_JOIN(_,              \
156     ITT_JOIN(ITT_MAJOR,      \
157     ITT_JOIN(_, ITT_MINOR))))
158 
159 #ifndef INTEL_ITTNOTIFY_PREFIX
160 #  define INTEL_ITTNOTIFY_PREFIX __itt_
161 #endif /* INTEL_ITTNOTIFY_PREFIX */
162 #ifndef INTEL_ITTNOTIFY_POSTFIX
163 #  define INTEL_ITTNOTIFY_POSTFIX _ptr_
164 #endif /* INTEL_ITTNOTIFY_POSTFIX */
165 
166 #define ITTNOTIFY_NAME_AUX(n) ITT_JOIN(INTEL_ITTNOTIFY_PREFIX,n)
167 #define ITTNOTIFY_NAME(n)     ITT_VERSIONIZE(ITTNOTIFY_NAME_AUX(ITT_JOIN(n,INTEL_ITTNOTIFY_POSTFIX)))
168 
169 #define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)
170 #define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ?       0 : ITTNOTIFY_NAME(n)
171 
172 #define ITTNOTIFY_VOID_D0(n,d)       (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d)
173 #define ITTNOTIFY_VOID_D1(n,d,x)     (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x)
174 #define ITTNOTIFY_VOID_D2(n,d,x,y)   (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y)
175 #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)
176 #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)
177 #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)
178 #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)
179 #define ITTNOTIFY_DATA_D0(n,d)       (!(d)->flags) ?       0 : (!ITTNOTIFY_NAME(n)) ?       0 : ITTNOTIFY_NAME(n)(d)
180 #define ITTNOTIFY_DATA_D1(n,d,x)     (!(d)->flags) ?       0 : (!ITTNOTIFY_NAME(n)) ?       0 : ITTNOTIFY_NAME(n)(d,x)
181 #define ITTNOTIFY_DATA_D2(n,d,x,y)   (!(d)->flags) ?       0 : (!ITTNOTIFY_NAME(n)) ?       0 : ITTNOTIFY_NAME(n)(d,x,y)
182 #define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ?       0 : (!ITTNOTIFY_NAME(n)) ?       0 : ITTNOTIFY_NAME(n)(d,x,y,z)
183 #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)
184 #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)
185 #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)
186 
187 #ifdef ITT_STUB
188 #undef ITT_STUB
189 #endif
190 #ifdef ITT_STUBV
191 #undef ITT_STUBV
192 #endif
193 #define ITT_STUBV(api,type,name,args)                             \
194     typedef type (api* ITT_JOIN(ITTNOTIFY_NAME(name),_t)) args;   \
195     extern ITT_JOIN(ITTNOTIFY_NAME(name),_t) ITTNOTIFY_NAME(name);
196 #define ITT_STUB ITT_STUBV
197 /** @endcond */
198 
199 #ifdef __cplusplus
200 extern "C" {
201 #endif /* __cplusplus */
202 
203 #define INTEL_ITTNOTIFY_API_PRIVATE
204 #include "../ittnotify.h"
205 
206 #ifdef __cplusplus
207 }
208 #endif /* __cplusplus */
209 
210 #endif /* _INTERNAL_ITTNOTIFY_H_ */
211