rust/tests/run-make/volatile-intrinsics/main.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
616 B
Rust
Raw Normal View History

#![feature(core_intrinsics, volatile)]
2018-07-14 17:28:39 -05:00
use std::intrinsics::{
unaligned_volatile_load, unaligned_volatile_store, volatile_load, volatile_store,
};
use std::ptr::{read_volatile, write_volatile};
pub fn main() {
unsafe {
2018-07-14 17:28:39 -05:00
let mut i: isize = 1;
volatile_store(&mut i, 2);
assert_eq!(volatile_load(&i), 2);
}
unsafe {
2018-07-14 17:28:39 -05:00
let mut i: isize = 1;
unaligned_volatile_store(&mut i, 2);
assert_eq!(unaligned_volatile_load(&i), 2);
}
unsafe {
let mut i: isize = 1;
write_volatile(&mut i, 2);
assert_eq!(read_volatile(&i), 2);
}
}