3 #![allow(unused_unsafe)]
4 // ignore-wasm32-bare seems unimportant to test
8 #![feature(intrinsics)]
13 extern "rust-intrinsic" {
14 pub fn pref_align_of<T>() -> usize;
15 pub fn min_align_of<T>() -> usize;
19 // This is the type with the questionable alignment
25 // This is the type that contains the type with the
26 // questionable alignment, for testing
34 #[cfg(any(target_os = "android",
35 target_os = "dragonfly",
36 target_os = "emscripten",
37 target_os = "freebsd",
38 target_os = "fuchsia",
39 target_os = "illumos",
43 target_os = "openbsd",
44 target_os = "solaris",
45 target_os = "vxworks"))]
47 #[cfg(target_arch = "x86")]
49 pub fn align() -> usize { 4 }
50 pub fn size() -> usize { 12 }
53 #[cfg(not(target_arch = "x86"))]
55 pub fn align() -> usize { 8 }
56 pub fn size() -> usize { 16 }
60 #[cfg(target_env = "sgx")]
62 #[cfg(target_arch = "x86_64")]
64 pub fn align() -> usize { 8 }
65 pub fn size() -> usize { 16 }
69 #[cfg(target_os = "windows")]
72 pub fn align() -> usize { 8 }
73 pub fn size() -> usize { 16 }
79 let x = Outer {c8: 22, t: Inner {c64: 44}};
81 let y = format!("{:?}", x);
83 println!("align inner = {:?}", rusti::min_align_of::<Inner>());
84 println!("size outer = {:?}", mem::size_of::<Outer>());
85 println!("y = {:?}", y);
87 // per clang/gcc the alignment of `Inner` is 4 on x86.
88 assert_eq!(rusti::min_align_of::<Inner>(), m::m::align());
90 // per clang/gcc the size of `Outer` should be 12
91 // because `Inner`s alignment was 4.
92 assert_eq!(mem::size_of::<Outer>(), m::m::size());
94 assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());