]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/intrinsic-alignment.rs
[emscripten] Disable code paths that don't work on emscripten
[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 = "netbsd",
26           target_os = "openbsd",
27           target_os = "solaris",
28           target_os = "emscripten"))]
29 mod m {
30     #[main]
31     #[cfg(target_arch = "x86")]
32     pub fn main() {
33         unsafe {
34             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
35             assert_eq!(::rusti::min_align_of::<u64>(), 4);
36         }
37     }
38
39     #[main]
40     #[cfg(not(target_arch = "x86"))]
41     pub fn main() {
42         unsafe {
43             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
44             assert_eq!(::rusti::min_align_of::<u64>(), 8);
45         }
46     }
47 }
48
49 #[cfg(target_os = "bitrig")]
50 mod m {
51     #[main]
52     #[cfg(target_arch = "x86_64")]
53     pub fn main() {
54         unsafe {
55             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
56             assert_eq!(::rusti::min_align_of::<u64>(), 8);
57         }
58     }
59 }
60
61 #[cfg(target_os = "windows")]
62 mod m {
63     #[main]
64     #[cfg(target_arch = "x86")]
65     pub fn main() {
66         unsafe {
67             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
68             assert_eq!(::rusti::min_align_of::<u64>(), 8);
69         }
70     }
71
72     #[main]
73     #[cfg(target_arch = "x86_64")]
74     pub fn main() {
75         unsafe {
76             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
77             assert_eq!(::rusti::min_align_of::<u64>(), 8);
78         }
79     }
80 }
81
82 #[cfg(target_os = "android")]
83 mod m {
84     #[main]
85     #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
86     pub fn main() {
87         unsafe {
88             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
89             assert_eq!(::rusti::min_align_of::<u64>(), 8);
90         }
91     }
92 }