2024-02-16 14:02:50 -06:00
|
|
|
//@ only-x86_64
|
2020-01-09 11:51:13 -06:00
|
|
|
use std::sync::atomic::{compiler_fence, fence, Ordering};
|
|
|
|
|
|
|
|
fn main() {
|
2020-12-02 17:16:12 -06:00
|
|
|
// Allowed ordering modes
|
2020-01-09 11:51:13 -06:00
|
|
|
fence(Ordering::Acquire);
|
|
|
|
fence(Ordering::Release);
|
|
|
|
fence(Ordering::AcqRel);
|
|
|
|
fence(Ordering::SeqCst);
|
|
|
|
|
|
|
|
compiler_fence(Ordering::Acquire);
|
|
|
|
compiler_fence(Ordering::Release);
|
|
|
|
compiler_fence(Ordering::AcqRel);
|
|
|
|
compiler_fence(Ordering::SeqCst);
|
2020-12-02 17:16:12 -06:00
|
|
|
|
|
|
|
// Disallowed ordering modes
|
|
|
|
fence(Ordering::Relaxed);
|
|
|
|
//~^ ERROR memory fences cannot have `Relaxed` ordering
|
2020-01-09 11:51:13 -06:00
|
|
|
compiler_fence(Ordering::Relaxed);
|
2020-12-02 17:16:12 -06:00
|
|
|
//~^ ERROR memory fences cannot have `Relaxed` ordering
|
2020-01-09 11:51:13 -06:00
|
|
|
}
|