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