@@ -19,50 +19,50 @@ use stdarch_test::assert_instr;
1919
2020extern "C" {
2121 #[ link_name = "llvm.aarch64.tstart" ]
22- fn aarch64_tstart ( ) -> i32 ;
22+ fn aarch64_tstart ( ) -> u64 ;
2323 #[ link_name = "llvm.aarch64.tcommit" ]
2424 fn aarch64_tcommit ( ) -> ( ) ;
2525 #[ link_name = "llvm.aarch64.tcancel" ]
26- fn aarch64_tcancel ( imm0 : i64 ) -> ( ) ;
26+ fn aarch64_tcancel ( imm0 : u64 ) -> ( ) ;
2727 #[ link_name = "llvm.aarch64.ttest" ]
28- fn aarch64_ttest ( ) -> i32 ;
28+ fn aarch64_ttest ( ) -> u64 ;
2929}
3030
3131/// Transaction successfully started.
32- pub const _TMSTART_SUCCESS: u32 = 0x00_u32 ;
32+ pub const _TMSTART_SUCCESS: u64 = 0x00_u64 ;
3333
3434/// Extraction mask for failure reason
35- pub const _TMFAILURE_REASON: u32 = 0x00007FFF_u32 ;
35+ pub const _TMFAILURE_REASON: u64 = 0x00007FFF_u64 ;
3636
3737/// Transaction retry is possible.
38- pub const _TMFAILURE_RTRY: u32 = 1 << 15 ;
38+ pub const _TMFAILURE_RTRY: u64 = 1 << 15 ;
3939
4040/// Transaction executed a TCANCEL instruction
41- pub const _TMFAILURE_CNCL: u32 = 1 << 16 ;
41+ pub const _TMFAILURE_CNCL: u64 = 1 << 16 ;
4242
4343/// Transaction aborted because a conflict occurred
44- pub const _TMFAILURE_MEM: u32 = 1 << 17 ;
44+ pub const _TMFAILURE_MEM: u64 = 1 << 17 ;
4545
4646/// Fallback error type for any other reason
47- pub const _TMFAILURE_IMP: u32 = 1 << 18 ;
47+ pub const _TMFAILURE_IMP: u64 = 1 << 18 ;
4848
4949/// Transaction aborted because a non-permissible operation was attempted
50- pub const _TMFAILURE_ERR: u32 = 1 << 19 ;
50+ pub const _TMFAILURE_ERR: u64 = 1 << 19 ;
5151
5252/// Transaction aborted due to read or write set limit was exceeded
53- pub const _TMFAILURE_SIZE: u32 = 1 << 20 ;
53+ pub const _TMFAILURE_SIZE: u64 = 1 << 20 ;
5454
5555/// Transaction aborted due to transactional nesting level was exceeded
56- pub const _TMFAILURE_NEST: u32 = 1 << 21 ;
56+ pub const _TMFAILURE_NEST: u64 = 1 << 21 ;
5757
5858/// Transaction aborted due to a debug trap.
59- pub const _TMFAILURE_DBG: u32 = 1 << 22 ;
59+ pub const _TMFAILURE_DBG: u64 = 1 << 22 ;
6060
6161/// Transaction failed from interrupt
62- pub const _TMFAILURE_INT: u32 = 1 << 23 ;
62+ pub const _TMFAILURE_INT: u64 = 1 << 23 ;
6363
6464/// Indicates a TRIVIAL version of TM is available
65- pub const _TMFAILURE_TRIVIAL: u32 = 1 << 24 ;
65+ pub const _TMFAILURE_TRIVIAL: u64 = 1 << 24 ;
6666
6767/// Starts a new transaction. When the transaction starts successfully the return value is 0.
6868/// 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;
7272#[ inline]
7373#[ target_feature( enable = "tme" ) ]
7474#[ cfg_attr( test, assert_instr( tstart) ) ]
75- pub unsafe fn __tstart ( ) -> u32 {
75+ pub unsafe fn __tstart ( ) -> u64 {
7676 aarch64_tstart ( ) as _
7777}
7878
@@ -95,7 +95,7 @@ pub unsafe fn __tcommit() {
9595#[ target_feature( enable = "tme" ) ]
9696#[ cfg_attr( test, assert_instr( tcancel, imm0 = 0x0 ) ) ]
9797#[ rustc_args_required_const( 0 ) ]
98- pub unsafe fn __tcancel ( imm0 : u32 ) {
98+ pub unsafe fn __tcancel ( imm0 : u64 ) {
9999 macro_rules! call {
100100 ( $imm0: expr) => {
101101 aarch64_tcancel( $imm0)
@@ -111,7 +111,7 @@ pub unsafe fn __tcancel(imm0: u32) {
111111#[ inline]
112112#[ target_feature( enable = "tme" ) ]
113113#[ cfg_attr( test, assert_instr( ttest) ) ]
114- pub unsafe fn __ttest ( ) -> u32 {
114+ pub unsafe fn __ttest ( ) -> u64 {
115115 aarch64_ttest ( ) as _
116116}
117117
@@ -121,14 +121,16 @@ mod tests {
121121
122122 use crate :: core_arch:: aarch64:: * ;
123123
124+ const CANCEL_CODE : u64 = ( 0 | ( 0x123 & _TMFAILURE_REASON) as i64 ) as u64 ;
125+
124126 #[ simd_test( enable = "tme" ) ]
125127 unsafe fn test_tstart ( ) {
126128 let mut x = 0 ;
127129 for i in 0 ..10 {
128130 let code = tme:: __tstart ( ) ;
129131 if code == _TMSTART_SUCCESS {
130132 x += 1 ;
131- assert_eq ! ( x, i+ 1 ) ;
133+ assert_eq ! ( x, i + 1 ) ;
132134 break ;
133135 }
134136 assert_eq ! ( x, 0 ) ;
@@ -142,25 +144,23 @@ mod tests {
142144 let code = tme:: __tstart ( ) ;
143145 if code == _TMSTART_SUCCESS {
144146 x += 1 ;
145- assert_eq ! ( x, i+ 1 ) ;
147+ assert_eq ! ( x, i + 1 ) ;
146148 tme:: __tcommit ( ) ;
147149 }
148- assert_eq ! ( x, i+ 1 ) ;
150+ assert_eq ! ( x, i + 1 ) ;
149151 }
150152 }
151153
152154 #[ simd_test( enable = "tme" ) ]
153155 unsafe fn test_tcancel ( ) {
154- let reason = 0x123 ;
155- let cancel_code = ( 0 | ( reason & _TMFAILURE_REASON) as i32 ) as u32 ;
156156 let mut x = 0 ;
157157
158158 for i in 0 ..10 {
159159 let code = tme:: __tstart ( ) ;
160160 if code == _TMSTART_SUCCESS {
161161 x += 1 ;
162- assert_eq ! ( x, i+ 1 ) ;
163- tme:: __tcancel ( cancel_code ) ;
162+ assert_eq ! ( x, i + 1 ) ;
163+ tme:: __tcancel ( CANCEL_CODE ) ;
164164 break ;
165165 }
166166 }
@@ -170,14 +170,12 @@ mod tests {
170170
171171 #[ simd_test( enable = "tme" ) ]
172172 unsafe fn test_ttest ( ) {
173- let reason = 0x123 ;
174- let cancel_code = ( 0 | ( reason & _TMFAILURE_REASON) as i32 ) as u32 ;
175173 for _ in 0 ..10 {
176174 let code = tme:: __tstart ( ) ;
177175 if code == _TMSTART_SUCCESS {
178176 if tme:: __ttest ( ) == 2 {
179- tme:: __tcancel ( cancel_code ) ;
180- break ;
177+ tme:: __tcancel ( CANCEL_CODE ) ;
178+ break ;
181179 }
182180 }
183181 }
0 commit comments