mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 00:24:52 +00:00
Add tests for read_volatile and write_volatile
This commit is contained in:
parent
7ae4ee80d1
commit
3b67e467b2
|
@ -8,9 +8,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics, volatile)]
|
||||||
|
|
||||||
use std::intrinsics::{volatile_load, volatile_store};
|
use std::intrinsics::{volatile_load, volatile_store};
|
||||||
|
use std::ptr::{read_volatile, write_volatile};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -18,4 +19,9 @@ pub fn main() {
|
||||||
volatile_store(&mut i, 2);
|
volatile_store(&mut i, 2);
|
||||||
assert_eq!(volatile_load(&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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue