2016-02-19 17:40:36 +00:00
|
|
|
#![feature(core_intrinsics, volatile)]
|
2015-03-06 02:33:58 +00:00
|
|
|
|
2018-07-14 22:28:39 +00:00
|
|
|
use std::intrinsics::{
|
|
|
|
unaligned_volatile_load, unaligned_volatile_store, volatile_load, volatile_store,
|
|
|
|
};
|
2016-02-19 17:40:36 +00:00
|
|
|
use std::ptr::{read_volatile, write_volatile};
|
2013-12-28 14:01:53 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
unsafe {
|
2018-07-14 22:28:39 +00:00
|
|
|
let mut i: isize = 1;
|
2013-12-28 14:01:53 +00:00
|
|
|
volatile_store(&mut i, 2);
|
|
|
|
assert_eq!(volatile_load(&i), 2);
|
|
|
|
}
|
2016-02-19 17:40:36 +00:00
|
|
|
unsafe {
|
2018-07-14 22:28:39 +00: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;
|
2016-02-19 17:40:36 +00:00
|
|
|
write_volatile(&mut i, 2);
|
|
|
|
assert_eq!(read_volatile(&i), 2);
|
|
|
|
}
|
2013-12-28 14:01:53 +00:00
|
|
|
}
|