]> git.proxmox.com Git - rustc.git/blame - src/test/run-make/volatile-intrinsics/main.rs
New upstream version 1.25.0+dfsg1
[rustc.git] / src / test / run-make / volatile-intrinsics / main.rs
CommitLineData
223e47cc
LB
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
7453a54e 11#![feature(core_intrinsics, volatile)]
c34b1796 12
1a4d82fc 13use std::intrinsics::{volatile_load, volatile_store};
7453a54e 14use std::ptr::{read_volatile, write_volatile};
223e47cc
LB
15
16pub fn main() {
1a4d82fc 17 unsafe {
c34b1796 18 let mut i : isize = 1;
1a4d82fc
JJ
19 volatile_store(&mut i, 2);
20 assert_eq!(volatile_load(&i), 2);
21 }
7453a54e
SL
22 unsafe {
23 let mut i : isize = 1;
24 write_volatile(&mut i, 2);
25 assert_eq!(read_volatile(&i), 2);
26 }
223e47cc 27}