111
|
1 /* Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
|
2 Contributed by Richard Henderson <rth@redhat.com>.
|
|
3
|
|
4 This file is part of the GNU Transactional Memory Library (libitm).
|
|
5
|
|
6 Libitm is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by
|
|
8 the Free Software Foundation; either version 3 of the License, or
|
|
9 (at your option) any later version.
|
|
10
|
|
11 Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
14 more details.
|
|
15
|
|
16 Under Section 7 of GPL version 3, you are granted additional
|
|
17 permissions described in the GCC Runtime Library Exception, version
|
|
18 3.1, as published by the Free Software Foundation.
|
|
19
|
|
20 You should have received a copy of the GNU General Public License and
|
|
21 a copy of the GCC Runtime Library Exception along with this program;
|
|
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
23 <http://www.gnu.org/licenses/>. */
|
|
24
|
|
25 /* The external interface of this library follows the specification described
|
|
26 in version 1 of http://www.intel.com/some/path/here.pdf. */
|
|
27
|
|
28 #ifndef LIBITM_H
|
|
29 #define LIBITM_H 1
|
|
30
|
|
31 #include <stddef.h>
|
|
32 #include <stdbool.h>
|
|
33 #include <stdint.h>
|
|
34
|
|
35 #ifdef __cplusplus
|
|
36 extern "C" {
|
|
37 #endif
|
|
38
|
|
39 #ifdef __i386__
|
|
40 /* Only for 32-bit x86. */
|
|
41 # define ITM_REGPARM __attribute__((regparm(2)))
|
|
42 #else
|
|
43 # define ITM_REGPARM
|
|
44 #endif
|
|
45
|
|
46 #define ITM_NORETURN __attribute__((noreturn))
|
|
47 #define ITM_PURE __attribute__((transaction_pure))
|
|
48
|
|
49 /* The following are externally visible definitions and functions, though
|
|
50 only very few of these should be called by user code. */
|
|
51
|
|
52 /* Values used as arguments to abort. */
|
|
53 typedef enum {
|
|
54 userAbort = 1,
|
|
55 userRetry = 2,
|
|
56 TMConflict= 4,
|
|
57 exceptionBlockAbort = 8,
|
|
58 outerAbort = 16
|
|
59 } _ITM_abortReason;
|
|
60
|
|
61 /* Arguments to changeTransactionMode */
|
|
62 typedef enum
|
|
63 {
|
|
64 modeSerialIrrevocable,
|
|
65 } _ITM_transactionState;
|
|
66
|
|
67 /* Results from inTransaction */
|
|
68 typedef enum
|
|
69 {
|
|
70 outsideTransaction = 0, /* So "if (inTransaction(td))" works */
|
|
71 inRetryableTransaction,
|
|
72 inIrrevocableTransaction
|
|
73 } _ITM_howExecuting;
|
|
74
|
|
75 /* Values to describe properties of code, passed in to beginTransaction.
|
|
76 Some of these constants are duplicated in some of the ITM_beginTransaction
|
|
77 implementations, so update those too when applying any changes. */
|
|
78 typedef enum
|
|
79 {
|
|
80 pr_instrumentedCode = 0x0001,
|
|
81 pr_uninstrumentedCode = 0x0002,
|
|
82 pr_multiwayCode = pr_instrumentedCode | pr_uninstrumentedCode,
|
|
83 /* Called pr_hasNoXMMUpdate in the Intel document, used for
|
|
84 avoiding vector register save/restore for any target. */
|
|
85 pr_hasNoVectorUpdate = 0x0004,
|
|
86 pr_hasNoAbort = 0x0008,
|
|
87 /* Not present in the Intel document, used for avoiding
|
|
88 floating point register save/restore for any target. */
|
|
89 pr_hasNoFloatUpdate = 0x0010,
|
|
90 pr_hasNoIrrevocable = 0x0020,
|
|
91 pr_doesGoIrrevocable = 0x0040,
|
|
92 pr_aWBarriersOmitted = 0x0100,
|
|
93 pr_RaRBarriersOmitted = 0x0200,
|
|
94 pr_undoLogCode = 0x0400,
|
|
95 pr_preferUninstrumented = 0x0800,
|
|
96 /* Exception blocks are not used nor supported. */
|
|
97 pr_exceptionBlock = 0x1000,
|
|
98 pr_hasElse = 0x2000,
|
|
99 pr_readOnly = 0x4000,
|
|
100 pr_hasNoSimpleReads = 0x400000,
|
|
101 /* These are not part of the ABI but used for custom HTM fast paths. See
|
|
102 ITM_beginTransaction and gtm_thread::begin_transaction. */
|
|
103 pr_HTMRetryableAbort = 0x800000,
|
|
104 pr_HTMRetriedAfterAbort = 0x1000000
|
|
105 } _ITM_codeProperties;
|
|
106
|
|
107 /* Result from startTransaction that describes what actions to take.
|
|
108 Some of these constants are duplicated in some of the ITM_beginTransaction
|
|
109 implementations, so update those too when applying any changes. */
|
|
110 typedef enum
|
|
111 {
|
|
112 a_runInstrumentedCode = 0x01,
|
|
113 a_runUninstrumentedCode = 0x02,
|
|
114 a_saveLiveVariables = 0x04,
|
|
115 a_restoreLiveVariables = 0x08,
|
|
116 a_abortTransaction = 0x10,
|
|
117 a_tryHTMFastPath = 0x20
|
|
118 } _ITM_actions;
|
|
119
|
|
120 typedef struct
|
|
121 {
|
|
122 uint32_t reserved_1;
|
|
123 uint32_t flags;
|
|
124 uint32_t reserved_2;
|
|
125 uint32_t reserved_3;
|
|
126 const char *psource;
|
|
127 } _ITM_srcLocation;
|
|
128
|
|
129 typedef void (* _ITM_userUndoFunction)(void *);
|
|
130 typedef void (* _ITM_userCommitFunction) (void *);
|
|
131
|
|
132 #define _ITM_VERSION "0.90 (Feb 29 2008)"
|
|
133 #define _ITM_VERSION_NO 90
|
|
134
|
|
135 extern int _ITM_versionCompatible (int) ITM_REGPARM;
|
|
136 extern const char * _ITM_libraryVersion (void) ITM_REGPARM;
|
|
137
|
|
138 void _ITM_error(const _ITM_srcLocation *, int errorCode)
|
|
139 ITM_REGPARM ITM_NORETURN;
|
|
140
|
|
141 extern _ITM_howExecuting _ITM_inTransaction(void) ITM_REGPARM;
|
|
142
|
|
143 typedef uint64_t _ITM_transactionId_t; /* Transaction identifier */
|
|
144 #define _ITM_noTransactionId 1 /* Id for non-transactional code. */
|
|
145
|
|
146 extern _ITM_transactionId_t _ITM_getTransactionId(void) ITM_REGPARM;
|
|
147
|
|
148 extern uint32_t _ITM_beginTransaction(uint32_t, ...) ITM_REGPARM;
|
|
149
|
|
150 extern void _ITM_abortTransaction(_ITM_abortReason) ITM_REGPARM ITM_NORETURN;
|
|
151
|
|
152 extern void _ITM_commitTransaction (void) ITM_REGPARM;
|
|
153
|
|
154 extern void _ITM_changeTransactionMode (_ITM_transactionState) ITM_REGPARM;
|
|
155
|
|
156 extern void _ITM_addUserCommitAction(_ITM_userCommitFunction,
|
|
157 _ITM_transactionId_t, void *) ITM_REGPARM;
|
|
158
|
|
159 extern void _ITM_addUserUndoAction(_ITM_userUndoFunction, void *) ITM_REGPARM;
|
|
160
|
|
161 extern void _ITM_dropReferences (void *, size_t) ITM_REGPARM ITM_PURE;
|
|
162
|
|
163 extern void *_ITM_malloc (size_t)
|
|
164 __attribute__((__malloc__)) ITM_PURE;
|
|
165
|
|
166 extern void *_ITM_calloc (size_t, size_t)
|
|
167 __attribute__((__malloc__)) ITM_PURE;
|
|
168
|
|
169 extern void _ITM_free (void *) ITM_PURE;
|
|
170
|
|
171
|
|
172 /* The following typedefs exist to make the macro expansions below work
|
|
173 properly. They are not part of any API. */
|
|
174 typedef uint8_t _ITM_TYPE_U1;
|
|
175 typedef uint16_t _ITM_TYPE_U2;
|
|
176 typedef uint32_t _ITM_TYPE_U4;
|
|
177 typedef uint64_t _ITM_TYPE_U8;
|
|
178 typedef float _ITM_TYPE_F;
|
|
179 typedef double _ITM_TYPE_D;
|
|
180 typedef long double _ITM_TYPE_E;
|
|
181 typedef float _Complex _ITM_TYPE_CF;
|
|
182 typedef double _Complex _ITM_TYPE_CD;
|
|
183 typedef long double _Complex _ITM_TYPE_CE;
|
|
184
|
|
185 #define ITM_BARRIERS(T) \
|
|
186 extern _ITM_TYPE_##T _ITM_R##T(const _ITM_TYPE_##T *) ITM_REGPARM; \
|
|
187 extern _ITM_TYPE_##T _ITM_RaR##T(const _ITM_TYPE_##T *) ITM_REGPARM; \
|
|
188 extern _ITM_TYPE_##T _ITM_RaW##T(const _ITM_TYPE_##T *) ITM_REGPARM; \
|
|
189 extern _ITM_TYPE_##T _ITM_RfW##T(const _ITM_TYPE_##T *) ITM_REGPARM; \
|
|
190 extern void _ITM_W##T (_ITM_TYPE_##T *, _ITM_TYPE_##T) ITM_REGPARM; \
|
|
191 extern void _ITM_WaR##T (_ITM_TYPE_##T *, _ITM_TYPE_##T) ITM_REGPARM; \
|
|
192 extern void _ITM_WaW##T (_ITM_TYPE_##T *, _ITM_TYPE_##T) ITM_REGPARM;
|
|
193
|
|
194 ITM_BARRIERS(U1)
|
|
195 ITM_BARRIERS(U2)
|
|
196 ITM_BARRIERS(U4)
|
|
197 ITM_BARRIERS(U8)
|
|
198 ITM_BARRIERS(F)
|
|
199 ITM_BARRIERS(D)
|
|
200 ITM_BARRIERS(E)
|
|
201 ITM_BARRIERS(CF)
|
|
202 ITM_BARRIERS(CD)
|
|
203 ITM_BARRIERS(CE)
|
|
204
|
|
205 #define ITM_LOG(T) \
|
|
206 extern void _ITM_L##T (const _ITM_TYPE_##T *) ITM_REGPARM;
|
|
207
|
|
208 ITM_LOG(U1)
|
|
209 ITM_LOG(U2)
|
|
210 ITM_LOG(U4)
|
|
211 ITM_LOG(U8)
|
|
212 ITM_LOG(F)
|
|
213 ITM_LOG(D)
|
|
214 ITM_LOG(E)
|
|
215 ITM_LOG(CF)
|
|
216 ITM_LOG(CD)
|
|
217 ITM_LOG(CE)
|
|
218
|
|
219 #if defined(__i386__) || defined(__x86_64__)
|
|
220 # ifdef __MMX__
|
|
221 typedef int _ITM_TYPE_M64 __attribute__((vector_size(8), may_alias));
|
|
222 ITM_BARRIERS(M64)
|
|
223 ITM_LOG(M64)
|
|
224 # endif
|
|
225 # ifdef __SSE__
|
|
226 typedef float _ITM_TYPE_M128 __attribute__((vector_size(16), may_alias));
|
|
227 ITM_BARRIERS(M128)
|
|
228 ITM_LOG(M128)
|
|
229 # endif
|
|
230 # ifdef __AVX__
|
|
231 typedef float _ITM_TYPE_M256 __attribute__((vector_size(32), may_alias));
|
|
232 ITM_BARRIERS(M256)
|
|
233 ITM_LOG(M256)
|
|
234 # endif
|
|
235 #endif /* i386 */
|
|
236
|
|
237 #undef ITM_BARRIERS
|
|
238 #undef ITM_LOG
|
|
239
|
|
240 extern void _ITM_LB (const void *, size_t) ITM_REGPARM;
|
|
241
|
|
242 extern void _ITM_memcpyRnWt(void *, const void *, size_t) ITM_REGPARM;
|
|
243 extern void _ITM_memcpyRnWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
244 extern void _ITM_memcpyRnWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
245 extern void _ITM_memcpyRtWn(void *, const void *, size_t) ITM_REGPARM;
|
|
246 extern void _ITM_memcpyRtWt(void *, const void *, size_t) ITM_REGPARM;
|
|
247 extern void _ITM_memcpyRtWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
248 extern void _ITM_memcpyRtWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
249 extern void _ITM_memcpyRtaRWn(void *, const void *, size_t) ITM_REGPARM;
|
|
250 extern void _ITM_memcpyRtaRWt(void *, const void *, size_t) ITM_REGPARM;
|
|
251 extern void _ITM_memcpyRtaRWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
252 extern void _ITM_memcpyRtaRWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
253 extern void _ITM_memcpyRtaWWn(void *, const void *, size_t) ITM_REGPARM;
|
|
254 extern void _ITM_memcpyRtaWWt(void *, const void *, size_t) ITM_REGPARM;
|
|
255 extern void _ITM_memcpyRtaWWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
256 extern void _ITM_memcpyRtaWWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
257
|
|
258 extern void _ITM_memmoveRnWt(void *, const void *, size_t) ITM_REGPARM;
|
|
259 extern void _ITM_memmoveRnWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
260 extern void _ITM_memmoveRnWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
261 extern void _ITM_memmoveRtWn(void *, const void *, size_t) ITM_REGPARM;
|
|
262 extern void _ITM_memmoveRtWt(void *, const void *, size_t) ITM_REGPARM;
|
|
263 extern void _ITM_memmoveRtWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
264 extern void _ITM_memmoveRtWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
265 extern void _ITM_memmoveRtaRWn(void *, const void *, size_t) ITM_REGPARM;
|
|
266 extern void _ITM_memmoveRtaRWt(void *, const void *, size_t) ITM_REGPARM;
|
|
267 extern void _ITM_memmoveRtaRWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
268 extern void _ITM_memmoveRtaRWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
269 extern void _ITM_memmoveRtaWWn(void *, const void *, size_t) ITM_REGPARM;
|
|
270 extern void _ITM_memmoveRtaWWt(void *, const void *, size_t) ITM_REGPARM;
|
|
271 extern void _ITM_memmoveRtaWWtaR(void *, const void *, size_t) ITM_REGPARM;
|
|
272 extern void _ITM_memmoveRtaWWtaW(void *, const void *, size_t) ITM_REGPARM;
|
|
273
|
|
274 extern void _ITM_memsetW(void *, int, size_t) ITM_REGPARM;
|
|
275 extern void _ITM_memsetWaR(void *, int, size_t) ITM_REGPARM;
|
|
276 extern void _ITM_memsetWaW(void *, int, size_t) ITM_REGPARM;
|
|
277
|
|
278 // ??? These are not yet in the official spec; still work-in-progress.
|
|
279
|
|
280 extern void *_ITM_getTMCloneOrIrrevocable (void *) ITM_REGPARM;
|
|
281 extern void *_ITM_getTMCloneSafe (void *) ITM_REGPARM;
|
|
282 extern void _ITM_registerTMCloneTable (void *, size_t);
|
|
283 extern void _ITM_deregisterTMCloneTable (void *);
|
|
284
|
|
285 extern void *_ITM_cxa_allocate_exception (size_t);
|
|
286 extern void _ITM_cxa_free_exception (void *exc_ptr);
|
|
287 extern void _ITM_cxa_throw (void *obj, void *tinfo, void *dest);
|
|
288 extern void *_ITM_cxa_begin_catch (void *exc_ptr);
|
|
289 extern void _ITM_cxa_end_catch (void);
|
|
290 extern void _ITM_commitTransactionEH(void *exc_ptr) ITM_REGPARM;
|
|
291
|
|
292 #ifdef __cplusplus
|
|
293 } /* extern "C" */
|
|
294 #endif
|
|
295
|
|
296 #endif /* LIBITM_H */
|