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",
42 target_os = "openbsd",
43 target_os = "solaris",
44 target_os = "vxworks"))]
46 #[cfg(target_arch = "x86")]
48 pub fn align() -> usize { 4 }
49 pub fn size() -> usize { 12 }
52 #[cfg(not(target_arch = "x86"))]
54 pub fn align() -> usize { 8 }
55 pub fn size() -> usize { 16 }
59 #[cfg(target_env = "sgx")]
61 #[cfg(target_arch = "x86_64")]
63 pub fn align() -> usize { 8 }
64 pub fn size() -> usize { 16 }
68 #[cfg(target_os = "windows")]
71 pub fn align() -> usize { 8 }
72 pub fn size() -> usize { 16 }
78 let x = Outer {c8: 22, t: Inner {c64: 44}};
80 let y = format!("{:?}", x);
82 println!("align inner = {:?}", rusti::min_align_of::<Inner>());
83 println!("size outer = {:?}", mem::size_of::<Outer>());
84 println!("y = {:?}", y);
86 // per clang/gcc the alignment of `Inner` is 4 on x86.
87 assert_eq!(rusti::min_align_of::<Inner>(), m::m::align());
89 // per clang/gcc the size of `Outer` should be 12
90 // because `Inner`s alignment was 4.
91 assert_eq!(mem::size_of::<Outer>(), m::m::size());
93 assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());