2020-12-02 23:16:12 +00:00
|
|
|
// only-x86_64
|
2020-01-06 00:52:15 +00:00
|
|
|
use std::sync::atomic::{AtomicU16, AtomicU32, AtomicU64, AtomicU8, AtomicUsize, Ordering};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// `AtomicU8` test cases
|
|
|
|
let x = AtomicU8::new(0);
|
|
|
|
|
|
|
|
// Allowed load ordering modes
|
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
|
|
|
// Allowed store ordering modes
|
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Disallowed load ordering modes
|
|
|
|
let _ = x.load(Ordering::Release);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
let _ = x.load(Ordering::AcqRel);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
|
2020-01-06 00:52:15 +00:00
|
|
|
// Disallowed store ordering modes
|
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
|
|
|
|
// `AtomicU16` test cases
|
|
|
|
let x = AtomicU16::new(0);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed load ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 23:16:12 +00:00
|
|
|
|
|
|
|
// Disallowed load ordering modes
|
|
|
|
let _ = x.load(Ordering::Release);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
let _ = x.load(Ordering::AcqRel);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
|
|
|
|
// Disallowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
|
|
|
|
// `AtomicU32` test cases
|
|
|
|
let x = AtomicU32::new(0);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed load ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 23:16:12 +00:00
|
|
|
|
|
|
|
// Disallowed load ordering modes
|
|
|
|
let _ = x.load(Ordering::Release);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
let _ = x.load(Ordering::AcqRel);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
|
|
|
|
// Disallowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
|
|
|
|
// `AtomicU64` test cases
|
|
|
|
let x = AtomicU64::new(0);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed load ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 23:16:12 +00:00
|
|
|
|
|
|
|
// Disallowed load ordering modes
|
|
|
|
let _ = x.load(Ordering::Release);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
let _ = x.load(Ordering::AcqRel);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
|
|
|
|
// Disallowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
|
|
|
|
// `AtomicUsize` test cases
|
|
|
|
let x = AtomicUsize::new(0);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed load ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 23:16:12 +00:00
|
|
|
// Allowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 23:16:12 +00:00
|
|
|
|
|
|
|
// Disallowed load ordering modes
|
|
|
|
let _ = x.load(Ordering::Release);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
let _ = x.load(Ordering::AcqRel);
|
|
|
|
//~^ ERROR atomic loads cannot have `Release` or `AcqRel` ordering
|
|
|
|
|
|
|
|
// Disallowed store ordering modes
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 23:16:12 +00:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-06 00:52:15 +00:00
|
|
|
}
|