]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/intrinsic-alignment.rs
Rollup merge of #24247 - steveklabnik:update_variable_bindings, r=huonw
[rust.git] / src / test / run-pass / intrinsic-alignment.rs
1 // Copyright 2012-2015 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
11
12 #![feature(intrinsics, main)]
13
14 mod rusti {
15     extern "rust-intrinsic" {
16         pub fn pref_align_of<T>() -> usize;
17         pub fn min_align_of<T>() -> usize;
18     }
19 }
20
21 #[cfg(any(target_os = "linux",
22           target_os = "macos",
23           target_os = "freebsd",
24           target_os = "dragonfly",
25           target_os = "openbsd"))]
26 mod m {
27     #[main]
28     #[cfg(target_arch = "x86")]
29     pub fn main() {
30         unsafe {
31             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
32             assert_eq!(::rusti::min_align_of::<u64>(), 4);
33         }
34     }
35
36     #[main]
37     #[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))]
38     pub fn main() {
39         unsafe {
40             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
41             assert_eq!(::rusti::min_align_of::<u64>(), 8);
42         }
43     }
44 }
45
46 #[cfg(target_os = "bitrig")]
47 mod m {
48     #[main]
49     #[cfg(target_arch = "x86_64")]
50     pub fn main() {
51         unsafe {
52             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
53             assert_eq!(::rusti::min_align_of::<u64>(), 8);
54         }
55     }
56 }
57
58 #[cfg(target_os = "windows")]
59 mod m {
60     #[main]
61     #[cfg(target_arch = "x86")]
62     pub fn main() {
63         unsafe {
64             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
65             assert_eq!(::rusti::min_align_of::<u64>(), 8);
66         }
67     }
68
69     #[main]
70     #[cfg(target_arch = "x86_64")]
71     pub fn main() {
72         unsafe {
73             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
74             assert_eq!(::rusti::min_align_of::<u64>(), 8);
75         }
76     }
77 }
78
79 #[cfg(target_os = "android")]
80 mod m {
81     #[main]
82     #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
83     pub fn main() {
84         unsafe {
85             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
86             assert_eq!(::rusti::min_align_of::<u64>(), 8);
87         }
88     }
89 }