]> git.lizzy.rs Git - rust.git/blob - tests/ui/intrinsics/intrinsic-alignment.rs
Auto merge of #106975 - tmiasko:basic-blocks-cache, r=cjgillot
[rust.git] / tests / ui / intrinsics / intrinsic-alignment.rs
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" {
8         pub fn pref_align_of<T>() -> usize;
9         #[rustc_safe_intrinsic]
10         pub fn min_align_of<T>() -> usize;
11     }
12 }
13
14 #[cfg(any(target_os = "android",
15           target_os = "dragonfly",
16           target_os = "emscripten",
17           target_os = "freebsd",
18           target_os = "fuchsia",
19           target_os = "illumos",
20           target_os = "linux",
21           target_os = "macos",
22           target_os = "netbsd",
23           target_os = "openbsd",
24           target_os = "solaris",
25           target_os = "vxworks"))]
26 mod m {
27     #[cfg(target_arch = "x86")]
28     pub fn main() {
29         unsafe {
30             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
31             assert_eq!(::rusti::min_align_of::<u64>(), 4);
32         }
33     }
34
35     #[cfg(not(target_arch = "x86"))]
36     pub fn main() {
37         unsafe {
38             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
39             assert_eq!(::rusti::min_align_of::<u64>(), 8);
40         }
41     }
42 }
43
44 #[cfg(target_env = "sgx")]
45 mod m {
46     #[cfg(target_arch = "x86_64")]
47     pub fn main() {
48         unsafe {
49             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
50             assert_eq!(::rusti::min_align_of::<u64>(), 8);
51         }
52     }
53 }
54
55 #[cfg(target_os = "windows")]
56 mod m {
57     pub fn main() {
58         unsafe {
59             assert_eq!(::rusti::pref_align_of::<u64>(), 8);
60             assert_eq!(::rusti::min_align_of::<u64>(), 8);
61         }
62     }
63 }
64
65 fn main() {
66     m::main();
67 }