summaryrefslogtreecommitdiffstats
path: root/tests/run-make/volatile-intrinsics/main.rs
blob: 4295d95f3f39813b5eba6cadc762d2aac8ee10f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#![feature(core_intrinsics, volatile)]

use std::intrinsics::{
    unaligned_volatile_load, unaligned_volatile_store, volatile_load, volatile_store,
};
use std::ptr::{read_volatile, write_volatile};

pub fn main() {
    unsafe {
        let mut i: isize = 1;
        volatile_store(&mut i, 2);
        assert_eq!(volatile_load(&i), 2);
    }
    unsafe {
        let mut i: isize = 1;
        unaligned_volatile_store(&mut i, 2);
        assert_eq!(unaligned_volatile_load(&i), 2);
    }
    unsafe {
        let mut i: isize = 1;
        write_volatile(&mut i, 2);
        assert_eq!(read_volatile(&i), 2);
    }
}