2020-12-02 17:16:12 -06:00
|
|
|
// FIXME: add support for `// only-atomic` to compiletest/header.rs
|
|
|
|
// only-x86_64
|
2020-01-05 18:52:15 -06:00
|
|
|
use std::sync::atomic::{AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, Ordering};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// `AtomicI8` test cases
|
|
|
|
let x = AtomicI8::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 17:16:12 -06: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-05 18:52:15 -06:00
|
|
|
// Disallowed store ordering modes
|
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
|
|
|
|
// `AtomicI16` test cases
|
|
|
|
let x = AtomicI16::new(0);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed load ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed store ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 17:16:12 -06: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-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
|
|
|
|
// `AtomicI32` test cases
|
|
|
|
let x = AtomicI32::new(0);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed load ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed store ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 17:16:12 -06: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-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
|
|
|
|
// `AtomicI64` test cases
|
|
|
|
let x = AtomicI64::new(0);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed load ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed store ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 17:16:12 -06: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-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
|
|
|
|
// `AtomicIsize` test cases
|
|
|
|
let x = AtomicIsize::new(0);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed load ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
let _ = x.load(Ordering::Acquire);
|
|
|
|
let _ = x.load(Ordering::SeqCst);
|
|
|
|
let _ = x.load(Ordering::Relaxed);
|
|
|
|
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed store ordering modes
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Release);
|
|
|
|
x.store(1, Ordering::SeqCst);
|
|
|
|
x.store(1, Ordering::Relaxed);
|
2020-12-02 17:16:12 -06: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-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::Acquire);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
x.store(1, Ordering::AcqRel);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR atomic stores cannot have `Acquire` or `AcqRel` ordering
|
2020-01-05 18:52:15 -06:00
|
|
|
}
|