Auto merge of #31761 - Amanieu:volatile, r=alexcrichton

Tracking issue: #31756
RFC: rust-lang/rfcs#1467

I've made these unstable for now. Should they be stabilized straight away since we've had plenty of experience with people using the unstable intrinsics?
This commit is contained in:
bors 2016-02-21 00:56:08 +00:00
commit a2fb48e9f7
2 changed files with 55 additions and 1 deletions

View file

@ -8,9 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(core_intrinsics)]
#![feature(core_intrinsics, volatile)]
use std::intrinsics::{volatile_load, volatile_store};
use std::ptr::{read_volatile, write_volatile};
pub fn main() {
unsafe {
@ -18,4 +19,9 @@ pub fn main() {
volatile_store(&mut i, 2);
assert_eq!(volatile_load(&i), 2);
}
unsafe {
let mut i : isize = 1;
write_volatile(&mut i, 2);
assert_eq!(read_volatile(&i), 2);
}
}