1 // run-pass
2 // ignore-wasm32-bare seems not important to test here
3 
4 #![feature(intrinsics)]
5 
6 mod rusti {
7     extern "rust-intrinsic" {
pref_align_of<T>() -> usize8         pub fn pref_align_of<T>() -> usize;
min_align_of<T>() -> usize9         pub fn min_align_of<T>() -> usize;
10     }
11 }
12 
13 #[cfg(any(target_os = "android",
14           target_os = "dragonfly",
15           target_os = "emscripten",
16           target_os = "freebsd",
17           target_os = "fuchsia",
18           target_os = "illumos",
19           target_os = "linux",
20           target_os = "macos",
21           target_os = "netbsd",
22           target_os = "openbsd",
23           target_os = "solaris",
24           target_os = "vxworks"))]
25 mod m {
26     #[cfg(target_arch = "x86")]
main()27     pub fn main() {
28         unsafe {
29             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
30             assert_eq!(::rusti::min_align_of::<u64>(), 4);
31         }
32     }
33 
34     #[cfg(not(target_arch = "x86"))]
main()35     pub fn main() {
36         unsafe {
37             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
38             assert_eq!(::rusti::min_align_of::<u64>(), 8);
39         }
40     }
41 }
42 
43 #[cfg(target_env = "sgx")]
44 mod m {
45     #[cfg(target_arch = "x86_64")]
main()46     pub fn main() {
47         unsafe {
48             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
49             assert_eq!(::rusti::min_align_of::<u64>(), 8);
50         }
51     }
52 }
53 
54 #[cfg(target_os = "windows")]
55 mod m {
main()56     pub fn main() {
57         unsafe {
58             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
59             assert_eq!(::rusti::min_align_of::<u64>(), 8);
60         }
61     }
62 }
63 
main()64 fn main() {
65     m::main();
66 }
67