@@ -19,50 +19,50 @@ use stdarch_test::assert_instr;
19
19
20
20
extern "C" {
21
21
#[ link_name = "llvm.aarch64.tstart" ]
22
- fn aarch64_tstart ( ) -> i32 ;
22
+ fn aarch64_tstart ( ) -> i64 ;
23
23
#[ link_name = "llvm.aarch64.tcommit" ]
24
24
fn aarch64_tcommit ( ) -> ( ) ;
25
25
#[ link_name = "llvm.aarch64.tcancel" ]
26
26
fn aarch64_tcancel ( imm0 : i64 ) -> ( ) ;
27
27
#[ link_name = "llvm.aarch64.ttest" ]
28
- fn aarch64_ttest ( ) -> i32 ;
28
+ fn aarch64_ttest ( ) -> i64 ;
29
29
}
30
30
31
31
/// Transaction successfully started.
32
- pub const _TMSTART_SUCCESS: u32 = 0x00_u32 ;
32
+ pub const _TMSTART_SUCCESS: i64 = 0x00_i64 ;
33
33
34
34
/// Extraction mask for failure reason
35
- pub const _TMFAILURE_REASON: u32 = 0x00007FFF_u32 ;
35
+ pub const _TMFAILURE_REASON: i64 = 0x00007FFF_i64 ;
36
36
37
37
/// Transaction retry is possible.
38
- pub const _TMFAILURE_RTRY: u32 = 1 << 15 ;
38
+ pub const _TMFAILURE_RTRY: i64 = 1 << 15 ;
39
39
40
40
/// Transaction executed a TCANCEL instruction
41
- pub const _TMFAILURE_CNCL: u32 = 1 << 16 ;
41
+ pub const _TMFAILURE_CNCL: i64 = 1 << 16 ;
42
42
43
43
/// Transaction aborted because a conflict occurred
44
- pub const _TMFAILURE_MEM: u32 = 1 << 17 ;
44
+ pub const _TMFAILURE_MEM: i64 = 1 << 17 ;
45
45
46
46
/// Fallback error type for any other reason
47
- pub const _TMFAILURE_IMP: u32 = 1 << 18 ;
47
+ pub const _TMFAILURE_IMP: i64 = 1 << 18 ;
48
48
49
49
/// Transaction aborted because a non-permissible operation was attempted
50
- pub const _TMFAILURE_ERR: u32 = 1 << 19 ;
50
+ pub const _TMFAILURE_ERR: i64 = 1 << 19 ;
51
51
52
52
/// Transaction aborted due to read or write set limit was exceeded
53
- pub const _TMFAILURE_SIZE: u32 = 1 << 20 ;
53
+ pub const _TMFAILURE_SIZE: i64 = 1 << 20 ;
54
54
55
55
/// Transaction aborted due to transactional nesting level was exceeded
56
- pub const _TMFAILURE_NEST: u32 = 1 << 21 ;
56
+ pub const _TMFAILURE_NEST: i64 = 1 << 21 ;
57
57
58
58
/// Transaction aborted due to a debug trap.
59
- pub const _TMFAILURE_DBG: u32 = 1 << 22 ;
59
+ pub const _TMFAILURE_DBG: i64 = 1 << 22 ;
60
60
61
61
/// Transaction failed from interrupt
62
- pub const _TMFAILURE_INT: u32 = 1 << 23 ;
62
+ pub const _TMFAILURE_INT: i64 = 1 << 23 ;
63
63
64
64
/// Indicates a TRIVIAL version of TM is available
65
- pub const _TMFAILURE_TRIVIAL: u32 = 1 << 24 ;
65
+ pub const _TMFAILURE_TRIVIAL: i64 = 1 << 24 ;
66
66
67
67
/// Starts a new transaction. When the transaction starts successfully the return value is 0.
68
68
/// If the transaction fails, all state modifications are discarded and a cause of the failure
@@ -72,7 +72,7 @@ pub const _TMFAILURE_TRIVIAL: u32 = 1 << 24;
72
72
#[ inline]
73
73
#[ target_feature( enable = "tme" ) ]
74
74
#[ cfg_attr( test, assert_instr( tstart) ) ]
75
- pub unsafe fn __tstart ( ) -> u32 {
75
+ pub unsafe fn __tstart ( ) -> i64 {
76
76
aarch64_tstart ( ) as _
77
77
}
78
78
@@ -95,7 +95,7 @@ pub unsafe fn __tcommit() {
95
95
#[ target_feature( enable = "tme" ) ]
96
96
#[ cfg_attr( test, assert_instr( tcancel, imm0 = 0x0 ) ) ]
97
97
#[ rustc_args_required_const( 0 ) ]
98
- pub unsafe fn __tcancel ( imm0 : u32 ) {
98
+ pub unsafe fn __tcancel ( imm0 : i64 ) {
99
99
macro_rules! call {
100
100
( $imm0: expr) => {
101
101
aarch64_tcancel( $imm0)
@@ -111,7 +111,7 @@ pub unsafe fn __tcancel(imm0: u32) {
111
111
#[ inline]
112
112
#[ target_feature( enable = "tme" ) ]
113
113
#[ cfg_attr( test, assert_instr( ttest) ) ]
114
- pub unsafe fn __ttest ( ) -> u32 {
114
+ pub unsafe fn __ttest ( ) -> i64 {
115
115
aarch64_ttest ( ) as _
116
116
}
117
117
@@ -121,14 +121,16 @@ mod tests {
121
121
122
122
use crate :: core_arch:: aarch64:: * ;
123
123
124
+ const CANCEL_CODE : i64 = ( 0 | ( 0x123 & _TMFAILURE_REASON) as i64 ) as i64 ;
125
+
124
126
#[ simd_test( enable = "tme" ) ]
125
127
unsafe fn test_tstart ( ) {
126
128
let mut x = 0 ;
127
129
for i in 0 ..10 {
128
130
let code = tme:: __tstart ( ) ;
129
131
if code == _TMSTART_SUCCESS {
130
132
x += 1 ;
131
- assert_eq ! ( x, i+ 1 ) ;
133
+ assert_eq ! ( x, i + 1 ) ;
132
134
break ;
133
135
}
134
136
assert_eq ! ( x, 0 ) ;
@@ -142,25 +144,23 @@ mod tests {
142
144
let code = tme:: __tstart ( ) ;
143
145
if code == _TMSTART_SUCCESS {
144
146
x += 1 ;
145
- assert_eq ! ( x, i+ 1 ) ;
147
+ assert_eq ! ( x, i + 1 ) ;
146
148
tme:: __tcommit ( ) ;
147
149
}
148
- assert_eq ! ( x, i+ 1 ) ;
150
+ assert_eq ! ( x, i + 1 ) ;
149
151
}
150
152
}
151
153
152
154
#[ simd_test( enable = "tme" ) ]
153
155
unsafe fn test_tcancel ( ) {
154
- let reason = 0x123 ;
155
- let cancel_code = ( 0 | ( reason & _TMFAILURE_REASON) as i32 ) as u32 ;
156
156
let mut x = 0 ;
157
157
158
158
for i in 0 ..10 {
159
159
let code = tme:: __tstart ( ) ;
160
160
if code == _TMSTART_SUCCESS {
161
161
x += 1 ;
162
- assert_eq ! ( x, i+ 1 ) ;
163
- tme:: __tcancel ( cancel_code ) ;
162
+ assert_eq ! ( x, i + 1 ) ;
163
+ tme:: __tcancel ( CANCEL_CODE ) ;
164
164
break ;
165
165
}
166
166
}
@@ -170,14 +170,12 @@ mod tests {
170
170
171
171
#[ simd_test( enable = "tme" ) ]
172
172
unsafe fn test_ttest ( ) {
173
- let reason = 0x123 ;
174
- let cancel_code = ( 0 | ( reason & _TMFAILURE_REASON) as i32 ) as u32 ;
175
173
for _ in 0 ..10 {
176
174
let code = tme:: __tstart ( ) ;
177
175
if code == _TMSTART_SUCCESS {
178
176
if tme:: __ttest ( ) == 2 {
179
- tme:: __tcancel ( cancel_code ) ;
180
- break ;
177
+ tme:: __tcancel ( CANCEL_CODE ) ;
178
+ break ;
181
179
}
182
180
}
183
181
}
0 commit comments