From: Elle Rhumsaa <[email protected]>
---
.../rust/execute/torture/atomic_exchange.rs | 121 +++++++++---------
1 file changed, 58 insertions(+), 63 deletions(-)
diff --git a/gcc/testsuite/rust/execute/torture/atomic_exchange.rs
b/gcc/testsuite/rust/execute/torture/atomic_exchange.rs
index 569504f6a30c..489413869811 100644
--- a/gcc/testsuite/rust/execute/torture/atomic_exchange.rs
+++ b/gcc/testsuite/rust/execute/torture/atomic_exchange.rs
@@ -1,25 +1,23 @@
#![feature(no_core)]
#![no_core]
-
#![feature(intrinsics)]
-
#![feature(lang_items)]
#[lang = "sized"]
pub trait Sized {}
#[lang = "clone"]
-pub trait Clone : Sized
-{
- fn clone (&self)->Self;
+pub trait Clone: Sized {
+ fn clone(&self) -> Self;
- fn clone_from (&mut self, source : &Self) { *self = source.clone () }
+ fn clone_from(&mut self, source: &Self) {
+ *self = source.clone()
+ }
}
-mod impls
-{
- use super::Clone;
+mod impls {
+ use super::Clone;
- macro_rules !impl_clone
+ macro_rules !impl_clone
{
($ ($t : ty) *) =>
{
@@ -33,80 +31,77 @@ mod impls
}
}
- impl_clone !
- {
- usize u8 u16 u32 u64 // u128
- isize i8 i16 i32 i64 // i128
- f32 f64 bool char
- }
+ impl_clone! {
+ usize u8 u16 u32 u64 // u128
+ isize i8 i16 i32 i64 // i128
+ f32 f64 bool char
+ }
}
#[lang = "copy"]
-pub trait Copy : Clone
-{
- // Empty.
+pub trait Copy: Clone {
+ // Empty.
}
-mod copy_impls
-{
- use super::Copy;
+mod copy_impls {
+ use super::Copy;
- macro_rules !impl_copy
+ macro_rules !impl_copy
{
($ ($t : ty) *) => {$ (impl Copy for $t{}) * }
}
- impl_copy !
- {
- usize u8 u16 u32 u64 // u128
- isize i8 i16 i32 i64 // i128
- f32 f64 bool char
- }
+ impl_copy! {
+ usize u8 u16 u32 u64 // u128
+ isize i8 i16 i32 i64 // i128
+ f32 f64 bool char
+ }
}
extern "rust-intrinsic" {
-pub fn atomic_exchange_seqcst<T : Copy> (dst : *mut T, val : T) -> T;
-pub fn atomic_exchange_release<T : Copy> (dst : *mut T, val : T) -> T;
-pub fn atomic_exchange_relaxed<T : Copy> (dst : *mut T, val : T) -> T;
-pub fn atomic_exchange_unordered<T : Copy> (dst : *mut T, val : T) -> T;
+ pub fn atomic_exchange_seqcst<T: Copy>(dst: *mut T, val: T) -> T;
+ pub fn atomic_exchange_release<T: Copy>(dst: *mut T, val: T) -> T;
+ pub fn atomic_exchange_relaxed<T: Copy>(dst: *mut T, val: T) -> T;
+ pub fn atomic_exchange_unordered<T: Copy>(dst: *mut T, val: T) -> T;
}
-fn
-main () -> u32
-{
- let mut dst = 15u32;
- let init = dst;
- let one;
- let two;
- let three;
- let four;
-
- unsafe
- {
- let mut ret = atomic_exchange_seqcst (&mut dst, 1);
- one = dst;
+fn main() -> u32 {
+ let mut dst = 15u32;
+ let init = dst;
+ let one;
+ let two;
+ let three;
+ let four;
- if ret
- != init { return ret; }
+ unsafe {
+ let mut ret = atomic_exchange_seqcst(&mut dst, 1);
+ one = dst;
- ret = atomic_exchange_release (&mut dst, 2);
- two = dst;
+ if ret != init {
+ return ret;
+ }
- if ret
- != one { return ret; }
+ ret = atomic_exchange_release(&mut dst, 2);
+ two = dst;
- ret = atomic_exchange_relaxed (&mut dst, 3);
- three = dst;
+ if ret != one {
+ return ret;
+ }
- if ret
- != two { return ret; }
+ ret = atomic_exchange_relaxed(&mut dst, 3);
+ three = dst;
- ret = atomic_exchange_unordered (&mut dst, 4);
- four = dst;
+ if ret != two {
+ return ret;
+ }
- if ret
- != three { return ret; }
- }
+ ret = atomic_exchange_unordered(&mut dst, 4);
+ four = dst;
+
+ if ret != three {
+ return ret;
+ }
+ }
- (four + three + two + one) - 10
+ (four + three + two + one) - 10
}
--
2.54.0