1 // Copyright 2016 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.
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.
11 // write_volatile causes an LLVM assert with composite types
14 use std
::ptr
::{read_volatile, write_volatile}
;
16 #[derive(Debug, Eq, PartialEq)]
18 #[derive(Debug, Eq, PartialEq)]
20 #[derive(Debug, Eq, PartialEq)]
22 #[derive(Debug, Eq, PartialEq)]
24 #[derive(Debug, Eq, PartialEq)]
30 write_volatile(&mut x
, 1);
31 assert_eq
!(read_volatile(&x
), 1);
35 write_volatile(&mut x
, 1);
36 assert_eq
!(read_volatile(&x
), 1);
40 write_volatile(&mut x
, A(1));
41 assert_eq
!(read_volatile(&x
), A(1));
45 write_volatile(&mut x
, B(1));
46 assert_eq
!(read_volatile(&x
), B(1));
50 write_volatile(&mut x
, C(1, 1));
51 assert_eq
!(read_volatile(&x
), C(1, 1));
52 assert_eq
!(x
, C(1, 1));
55 write_volatile(&mut x
, D(1, 1));
56 assert_eq
!(read_volatile(&x
), D(1, 1));
57 assert_eq
!(x
, D(1, 1));
59 let mut x
= E([0; 32]);
60 write_volatile(&mut x
, E([1; 32]));
61 assert_eq
!(read_volatile(&x
), E([1; 32]));
62 assert_eq
!(x
, E([1; 32]));