]> git.ipfire.org Git - thirdparty/gcc.git/blame - libitm/libitm.h
[Ada] Get rid of linear searches in Lib
[thirdparty/gcc.git] / libitm / libitm.h
CommitLineData
fbd26352 1/* Copyright (C) 2008-2019 Free Software Foundation, Inc.
4c0315d0 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
36extern "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. */
53typedef enum {
54 userAbort = 1,
55 userRetry = 2,
56 TMConflict= 4,
57 exceptionBlockAbort = 8,
58 outerAbort = 16
59} _ITM_abortReason;
60
61/* Arguments to changeTransactionMode */
62typedef enum
63{
64 modeSerialIrrevocable,
65} _ITM_transactionState;
66
67/* Results from inTransaction */
68typedef enum
69{
70 outsideTransaction = 0, /* So "if (inTransaction(td))" works */
71 inRetryableTransaction,
72 inIrrevocableTransaction
73} _ITM_howExecuting;
74
f20d0394 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. */
4c0315d0 78typedef 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,
f20d0394 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
4c0315d0 105} _ITM_codeProperties;
106
f20d0394 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. */
4c0315d0 110typedef enum
111{
112 a_runInstrumentedCode = 0x01,
113 a_runUninstrumentedCode = 0x02,
114 a_saveLiveVariables = 0x04,
115 a_restoreLiveVariables = 0x08,
116 a_abortTransaction = 0x10,
f20d0394 117 a_tryHTMFastPath = 0x20
4c0315d0 118} _ITM_actions;
119
120typedef 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
129typedef void (* _ITM_userUndoFunction)(void *);
130typedef void (* _ITM_userCommitFunction) (void *);
131
132#define _ITM_VERSION "0.90 (Feb 29 2008)"
133#define _ITM_VERSION_NO 90
134
135extern int _ITM_versionCompatible (int) ITM_REGPARM;
136extern const char * _ITM_libraryVersion (void) ITM_REGPARM;
137
138void _ITM_error(const _ITM_srcLocation *, int errorCode)
139 ITM_REGPARM ITM_NORETURN;
140
141extern _ITM_howExecuting _ITM_inTransaction(void) ITM_REGPARM;
142
143typedef uint64_t _ITM_transactionId_t; /* Transaction identifier */
144#define _ITM_noTransactionId 1 /* Id for non-transactional code. */
145
146extern _ITM_transactionId_t _ITM_getTransactionId(void) ITM_REGPARM;
147
148extern uint32_t _ITM_beginTransaction(uint32_t, ...) ITM_REGPARM;
149
150extern void _ITM_abortTransaction(_ITM_abortReason) ITM_REGPARM ITM_NORETURN;
151
152extern void _ITM_commitTransaction (void) ITM_REGPARM;
153
154extern void _ITM_changeTransactionMode (_ITM_transactionState) ITM_REGPARM;
155
156extern void _ITM_addUserCommitAction(_ITM_userCommitFunction,
157 _ITM_transactionId_t, void *) ITM_REGPARM;
158
159extern void _ITM_addUserUndoAction(_ITM_userUndoFunction, void *) ITM_REGPARM;
160
4c0315d0 161extern void _ITM_dropReferences (void *, size_t) ITM_REGPARM ITM_PURE;
162
163extern void *_ITM_malloc (size_t)
164 __attribute__((__malloc__)) ITM_PURE;
165
166extern void *_ITM_calloc (size_t, size_t)
167 __attribute__((__malloc__)) ITM_PURE;
168
169extern 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. */
174typedef uint8_t _ITM_TYPE_U1;
175typedef uint16_t _ITM_TYPE_U2;
176typedef uint32_t _ITM_TYPE_U4;
177typedef uint64_t _ITM_TYPE_U8;
178typedef float _ITM_TYPE_F;
179typedef double _ITM_TYPE_D;
180typedef long double _ITM_TYPE_E;
181typedef float _Complex _ITM_TYPE_CF;
182typedef double _Complex _ITM_TYPE_CD;
183typedef 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
194ITM_BARRIERS(U1)
195ITM_BARRIERS(U2)
196ITM_BARRIERS(U4)
197ITM_BARRIERS(U8)
198ITM_BARRIERS(F)
199ITM_BARRIERS(D)
200ITM_BARRIERS(E)
201ITM_BARRIERS(CF)
202ITM_BARRIERS(CD)
203ITM_BARRIERS(CE)
204
205#define ITM_LOG(T) \
206 extern void _ITM_L##T (const _ITM_TYPE_##T *) ITM_REGPARM;
207
208ITM_LOG(U1)
209ITM_LOG(U2)
210ITM_LOG(U4)
211ITM_LOG(U8)
212ITM_LOG(F)
213ITM_LOG(D)
214ITM_LOG(E)
215ITM_LOG(CF)
216ITM_LOG(CD)
217ITM_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
7a3e0230 235#endif /* i386 */
4c0315d0 236
237#undef ITM_BARRIERS
238#undef ITM_LOG
239
240extern void _ITM_LB (const void *, size_t) ITM_REGPARM;
241
242extern void _ITM_memcpyRnWt(void *, const void *, size_t) ITM_REGPARM;
243extern void _ITM_memcpyRnWtaR(void *, const void *, size_t) ITM_REGPARM;
244extern void _ITM_memcpyRnWtaW(void *, const void *, size_t) ITM_REGPARM;
245extern void _ITM_memcpyRtWn(void *, const void *, size_t) ITM_REGPARM;
246extern void _ITM_memcpyRtWt(void *, const void *, size_t) ITM_REGPARM;
247extern void _ITM_memcpyRtWtaR(void *, const void *, size_t) ITM_REGPARM;
248extern void _ITM_memcpyRtWtaW(void *, const void *, size_t) ITM_REGPARM;
249extern void _ITM_memcpyRtaRWn(void *, const void *, size_t) ITM_REGPARM;
250extern void _ITM_memcpyRtaRWt(void *, const void *, size_t) ITM_REGPARM;
251extern void _ITM_memcpyRtaRWtaR(void *, const void *, size_t) ITM_REGPARM;
252extern void _ITM_memcpyRtaRWtaW(void *, const void *, size_t) ITM_REGPARM;
253extern void _ITM_memcpyRtaWWn(void *, const void *, size_t) ITM_REGPARM;
254extern void _ITM_memcpyRtaWWt(void *, const void *, size_t) ITM_REGPARM;
255extern void _ITM_memcpyRtaWWtaR(void *, const void *, size_t) ITM_REGPARM;
256extern void _ITM_memcpyRtaWWtaW(void *, const void *, size_t) ITM_REGPARM;
257
258extern void _ITM_memmoveRnWt(void *, const void *, size_t) ITM_REGPARM;
259extern void _ITM_memmoveRnWtaR(void *, const void *, size_t) ITM_REGPARM;
260extern void _ITM_memmoveRnWtaW(void *, const void *, size_t) ITM_REGPARM;
261extern void _ITM_memmoveRtWn(void *, const void *, size_t) ITM_REGPARM;
262extern void _ITM_memmoveRtWt(void *, const void *, size_t) ITM_REGPARM;
263extern void _ITM_memmoveRtWtaR(void *, const void *, size_t) ITM_REGPARM;
264extern void _ITM_memmoveRtWtaW(void *, const void *, size_t) ITM_REGPARM;
265extern void _ITM_memmoveRtaRWn(void *, const void *, size_t) ITM_REGPARM;
266extern void _ITM_memmoveRtaRWt(void *, const void *, size_t) ITM_REGPARM;
267extern void _ITM_memmoveRtaRWtaR(void *, const void *, size_t) ITM_REGPARM;
268extern void _ITM_memmoveRtaRWtaW(void *, const void *, size_t) ITM_REGPARM;
269extern void _ITM_memmoveRtaWWn(void *, const void *, size_t) ITM_REGPARM;
270extern void _ITM_memmoveRtaWWt(void *, const void *, size_t) ITM_REGPARM;
271extern void _ITM_memmoveRtaWWtaR(void *, const void *, size_t) ITM_REGPARM;
272extern void _ITM_memmoveRtaWWtaW(void *, const void *, size_t) ITM_REGPARM;
273
274extern void _ITM_memsetW(void *, int, size_t) ITM_REGPARM;
275extern void _ITM_memsetWaR(void *, int, size_t) ITM_REGPARM;
276extern void _ITM_memsetWaW(void *, int, size_t) ITM_REGPARM;
277
278// ??? These are not yet in the official spec; still work-in-progress.
279
280extern void *_ITM_getTMCloneOrIrrevocable (void *) ITM_REGPARM;
281extern void *_ITM_getTMCloneSafe (void *) ITM_REGPARM;
282extern void _ITM_registerTMCloneTable (void *, size_t);
283extern void _ITM_deregisterTMCloneTable (void *);
284
285extern void *_ITM_cxa_allocate_exception (size_t);
c06f419b 286extern void _ITM_cxa_free_exception (void *exc_ptr);
e0fb5552 287extern void _ITM_cxa_throw (void *obj, void *tinfo, void (*dest) (void *));
4c0315d0 288extern void *_ITM_cxa_begin_catch (void *exc_ptr);
289extern void _ITM_cxa_end_catch (void);
290extern void _ITM_commitTransactionEH(void *exc_ptr) ITM_REGPARM;
291
292#ifdef __cplusplus
293} /* extern "C" */
294#endif
295
296#endif /* LIBITM_H */