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 #[rustc_safe_intrinsic]
16 pub fn min_align_of<T>() -> usize;
20 // This is the type with the questionable alignment
26 // This is the type that contains the type with the
27 // questionable alignment, for testing
35 #[cfg(any(target_os = "android",
36 target_os = "dragonfly",
37 target_os = "emscripten",
38 target_os = "freebsd",
39 target_os = "fuchsia",
40 target_os = "illumos",
44 target_os = "openbsd",
45 target_os = "solaris",
46 target_os = "vxworks"))]
48 #[cfg(target_arch = "x86")]
50 pub fn align() -> usize { 4 }
51 pub fn size() -> usize { 12 }
54 #[cfg(not(target_arch = "x86"))]
56 pub fn align() -> usize { 8 }
57 pub fn size() -> usize { 16 }
61 #[cfg(target_env = "sgx")]
63 #[cfg(target_arch = "x86_64")]
65 pub fn align() -> usize { 8 }
66 pub fn size() -> usize { 16 }
70 #[cfg(target_os = "windows")]
73 pub fn align() -> usize { 8 }
74 pub fn size() -> usize { 16 }
80 let x = Outer {c8: 22, t: Inner {c64: 44}};
82 let y = format!("{:?}", x);
84 println!("align inner = {:?}", rusti::min_align_of::<Inner>());
85 println!("size outer = {:?}", mem::size_of::<Outer>());
86 println!("y = {:?}", y);
88 // per clang/gcc the alignment of `Inner` is 4 on x86.
89 assert_eq!(rusti::min_align_of::<Inner>(), m::m::align());
91 // per clang/gcc the size of `Outer` should be 12
92 // because `Inner`s alignment was 4.
93 assert_eq!(mem::size_of::<Outer>(), m::m::size());
95 assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());