annotate libitm/libitm.h @ 158:494b0b89df80 default tip

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