Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 1 | /*===---- htmxlintrin.h - XL compiler HTM execution intrinsics-------------===*\ |
| 2 | * |
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | * of this software and associated documentation files (the "Software"), to deal |
| 5 | * in the Software without restriction, including without limitation the rights |
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | * copies of the Software, and to permit persons to whom the Software is |
| 8 | * furnished to do so, subject to the following conditions: |
| 9 | * |
| 10 | * The above copyright notice and this permission notice shall be included in |
| 11 | * all copies or substantial portions of the Software. |
| 12 | * |
| 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | * THE SOFTWARE. |
| 20 | * |
| 21 | \*===----------------------------------------------------------------------===*/ |
| 22 | |
| 23 | #ifndef __HTMXLINTRIN_H |
| 24 | #define __HTMXLINTRIN_H |
| 25 | |
| 26 | #ifndef __HTM__ |
| 27 | #error "HTM instruction set not enabled" |
| 28 | #endif |
| 29 | |
| 30 | #include <htmintrin.h> |
| 31 | |
| 32 | #ifdef __powerpc__ |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
Eric Christopher | 5ba576f | 2017-03-20 22:31:33 +0000 | [diff] [blame] | 38 | #define _TEXASR_PTR(TM_BUF) ((texasr_t *)((char *)(TM_BUF) + 0)) |
| 39 | #define _TEXASRU_PTR(TM_BUF) ((texasru_t *)((char *)(TM_BUF) + 0)) |
| 40 | #define _TEXASRL_PTR(TM_BUF) ((texasrl_t *)((char *)(TM_BUF) + 4)) |
| 41 | #define _TFIAR_PTR(TM_BUF) ((tfiar_t *)((char *)(TM_BUF) + 8)) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 42 | |
| 43 | typedef char TM_buff_type[16]; |
| 44 | |
Sean Silva | e4c3760 | 2015-09-12 02:55:19 +0000 | [diff] [blame] | 45 | /* This macro can be used to determine whether a transaction was successfully |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 46 | started from the __TM_begin() and __TM_simple_begin() intrinsic functions |
| 47 | below. */ |
| 48 | #define _HTM_TBEGIN_STARTED 1 |
| 49 | |
| 50 | extern __inline long |
| 51 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
| 52 | __TM_simple_begin (void) |
| 53 | { |
| 54 | if (__builtin_expect (__builtin_tbegin (0), 1)) |
| 55 | return _HTM_TBEGIN_STARTED; |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | extern __inline long |
| 60 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 61 | __TM_begin (void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 62 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 63 | *_TEXASRL_PTR (__TM_buff) = 0; |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 64 | if (__builtin_expect (__builtin_tbegin (0), 1)) |
| 65 | return _HTM_TBEGIN_STARTED; |
| 66 | #ifdef __powerpc64__ |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 67 | *_TEXASR_PTR (__TM_buff) = __builtin_get_texasr (); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 68 | #else |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 69 | *_TEXASRU_PTR (__TM_buff) = __builtin_get_texasru (); |
| 70 | *_TEXASRL_PTR (__TM_buff) = __builtin_get_texasr (); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 71 | #endif |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 72 | *_TFIAR_PTR (__TM_buff) = __builtin_get_tfiar (); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | extern __inline long |
| 77 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
| 78 | __TM_end (void) |
| 79 | { |
| 80 | if (__builtin_expect (__builtin_tend (0), 1)) |
| 81 | return 1; |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | extern __inline void |
| 86 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
| 87 | __TM_abort (void) |
| 88 | { |
| 89 | __builtin_tabort (0); |
| 90 | } |
| 91 | |
| 92 | extern __inline void |
| 93 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 94 | __TM_named_abort (unsigned char const __code) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 95 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 96 | __builtin_tabort (__code); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | extern __inline void |
| 100 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
| 101 | __TM_resume (void) |
| 102 | { |
| 103 | __builtin_tresume (); |
| 104 | } |
| 105 | |
| 106 | extern __inline void |
| 107 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
| 108 | __TM_suspend (void) |
| 109 | { |
| 110 | __builtin_tsuspend (); |
| 111 | } |
| 112 | |
| 113 | extern __inline long |
| 114 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 115 | __TM_is_user_abort (void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 116 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 117 | texasru_t texasru = *_TEXASRU_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 118 | return _TEXASRU_ABORT (texasru); |
| 119 | } |
| 120 | |
| 121 | extern __inline long |
| 122 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 123 | __TM_is_named_user_abort (void* const __TM_buff, unsigned char *__code) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 124 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 125 | texasru_t texasru = *_TEXASRU_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 126 | |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 127 | *__code = _TEXASRU_FAILURE_CODE (texasru); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 128 | return _TEXASRU_ABORT (texasru); |
| 129 | } |
| 130 | |
| 131 | extern __inline long |
| 132 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 133 | __TM_is_illegal (void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 134 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 135 | texasru_t texasru = *_TEXASRU_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 136 | return _TEXASRU_DISALLOWED (texasru); |
| 137 | } |
| 138 | |
| 139 | extern __inline long |
| 140 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 141 | __TM_is_footprint_exceeded (void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 142 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 143 | texasru_t texasru = *_TEXASRU_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 144 | return _TEXASRU_FOOTPRINT_OVERFLOW (texasru); |
| 145 | } |
| 146 | |
| 147 | extern __inline long |
| 148 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 149 | __TM_nesting_depth (void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 150 | { |
| 151 | texasrl_t texasrl; |
| 152 | |
| 153 | if (_HTM_STATE (__builtin_ttest ()) == _HTM_NONTRANSACTIONAL) |
| 154 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 155 | texasrl = *_TEXASRL_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 156 | if (!_TEXASR_FAILURE_SUMMARY (texasrl)) |
| 157 | texasrl = 0; |
| 158 | } |
| 159 | else |
| 160 | texasrl = (texasrl_t) __builtin_get_texasr (); |
| 161 | |
| 162 | return _TEXASR_TRANSACTION_LEVEL (texasrl); |
| 163 | } |
| 164 | |
| 165 | extern __inline long |
| 166 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 167 | __TM_is_nested_too_deep(void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 168 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 169 | texasru_t texasru = *_TEXASRU_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 170 | return _TEXASRU_NESTING_OVERFLOW (texasru); |
| 171 | } |
| 172 | |
| 173 | extern __inline long |
| 174 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 175 | __TM_is_conflict(void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 176 | { |
Eric Christopher | 5ba576f | 2017-03-20 22:31:33 +0000 | [diff] [blame] | 177 | texasru_t texasru = *_TEXASRU_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 178 | /* Return TEXASR bits 11 (Self-Induced Conflict) through |
| 179 | 14 (Translation Invalidation Conflict). */ |
| 180 | return (_TEXASRU_EXTRACT_BITS (texasru, 14, 4)) ? 1 : 0; |
| 181 | } |
| 182 | |
| 183 | extern __inline long |
| 184 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 185 | __TM_is_failure_persistent(void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 186 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 187 | texasru_t texasru = *_TEXASRU_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 188 | return _TEXASRU_FAILURE_PERSISTENT (texasru); |
| 189 | } |
| 190 | |
| 191 | extern __inline long |
| 192 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 193 | __TM_failure_address(void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 194 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 195 | return *_TFIAR_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | extern __inline long long |
| 199 | __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 200 | __TM_failure_code(void* const __TM_buff) |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 201 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 202 | return *_TEXASR_PTR (__TM_buff); |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | #ifdef __cplusplus |
| 206 | } |
| 207 | #endif |
| 208 | |
| 209 | #endif /* __powerpc__ */ |
| 210 | |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 211 | #ifdef __s390__ |
| 212 | |
| 213 | #include <stdint.h> |
| 214 | |
| 215 | /* These intrinsics are being made available for compatibility with |
| 216 | the IBM XL compiler. For documentation please see the "z/OS XL |
| 217 | C/C++ Programming Guide" publically available on the web. */ |
| 218 | |
| 219 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
| 220 | __TM_simple_begin () |
| 221 | { |
| 222 | return __builtin_tbegin_nofloat (0); |
| 223 | } |
| 224 | |
| 225 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 226 | __TM_begin (void* const __tdb) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 227 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 228 | return __builtin_tbegin_nofloat (__tdb); |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
| 232 | __TM_end () |
| 233 | { |
| 234 | return __builtin_tend (); |
| 235 | } |
| 236 | |
| 237 | static __inline void __attribute__((__always_inline__)) |
| 238 | __TM_abort () |
| 239 | { |
| 240 | return __builtin_tabort (_HTM_FIRST_USER_ABORT_CODE); |
| 241 | } |
| 242 | |
| 243 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 244 | __TM_named_abort (unsigned char const __code) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 245 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 246 | return __builtin_tabort ((int)_HTM_FIRST_USER_ABORT_CODE + __code); |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | static __inline void __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 250 | __TM_non_transactional_store (void* const __addr, long long const __value) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 251 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 252 | __builtin_non_tx_store ((uint64_t*)__addr, (uint64_t)__value); |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 256 | __TM_nesting_depth (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 257 | { |
| 258 | int depth = __builtin_tx_nesting_depth (); |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 259 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 260 | |
| 261 | if (depth != 0) |
| 262 | return depth; |
| 263 | |
| 264 | if (tdb->format != 1) |
| 265 | return 0; |
| 266 | return tdb->nesting_depth; |
| 267 | } |
| 268 | |
| 269 | /* Transaction failure diagnostics */ |
| 270 | |
| 271 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 272 | __TM_is_user_abort (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 273 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 274 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 275 | |
| 276 | if (tdb->format != 1) |
| 277 | return 0; |
| 278 | |
| 279 | return !!(tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE); |
| 280 | } |
| 281 | |
| 282 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 283 | __TM_is_named_user_abort (void* const __tdb_ptr, unsigned char* __code) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 284 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 285 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 286 | |
| 287 | if (tdb->format != 1) |
| 288 | return 0; |
| 289 | |
| 290 | if (tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE) |
| 291 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 292 | *__code = tdb->abort_code - _HTM_FIRST_USER_ABORT_CODE; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 293 | return 1; |
| 294 | } |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 299 | __TM_is_illegal (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 300 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 301 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 302 | |
| 303 | return (tdb->format == 1 |
| 304 | && (tdb->abort_code == 4 /* unfiltered program interruption */ |
| 305 | || tdb->abort_code == 11 /* restricted instruction */)); |
| 306 | } |
| 307 | |
| 308 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 309 | __TM_is_footprint_exceeded (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 310 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 311 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 312 | |
| 313 | return (tdb->format == 1 |
| 314 | && (tdb->abort_code == 7 /* fetch overflow */ |
| 315 | || tdb->abort_code == 8 /* store overflow */)); |
| 316 | } |
| 317 | |
| 318 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 319 | __TM_is_nested_too_deep (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 320 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 321 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 322 | |
| 323 | return tdb->format == 1 && tdb->abort_code == 13; /* depth exceeded */ |
| 324 | } |
| 325 | |
| 326 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 327 | __TM_is_conflict (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 328 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 329 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 330 | |
| 331 | return (tdb->format == 1 |
| 332 | && (tdb->abort_code == 9 /* fetch conflict */ |
| 333 | || tdb->abort_code == 10 /* store conflict */)); |
| 334 | } |
| 335 | |
| 336 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 337 | __TM_is_failure_persistent (long const __result) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 338 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 339 | return __result == _HTM_TBEGIN_PERSISTENT; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 343 | __TM_failure_address (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 344 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 345 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 346 | return tdb->atia; |
| 347 | } |
| 348 | |
| 349 | static __inline long __attribute__((__always_inline__, __nodebug__)) |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 350 | __TM_failure_code (void* const __tdb_ptr) |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 351 | { |
Eric Christopher | 39a84d0 | 2016-02-12 02:22:53 +0000 | [diff] [blame] | 352 | struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; |
Ulrich Weigand | 3a610eb | 2015-04-01 12:54:25 +0000 | [diff] [blame] | 353 | |
| 354 | return tdb->abort_code; |
| 355 | } |
| 356 | |
| 357 | #endif /* __s390__ */ |
| 358 | |
Kit Barton | 8246f28 | 2015-03-25 19:41:41 +0000 | [diff] [blame] | 359 | #endif /* __HTMXLINTRIN_H */ |