]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/intrinsic-alignment.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / run-pass / intrinsic-alignment.rs
CommitLineData
1a4d82fc 1// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
223e47cc
LB
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
abe05a73 11// ignore-wasm32-bare seems not important to test here
c34b1796 12
85aaf69f 13#![feature(intrinsics, main)]
223e47cc
LB
14
15mod rusti {
1a4d82fc 16 extern "rust-intrinsic" {
c34b1796
AL
17 pub fn pref_align_of<T>() -> usize;
18 pub fn min_align_of<T>() -> usize;
223e47cc
LB
19 }
20}
21
1a4d82fc
JJ
22#[cfg(any(target_os = "linux",
23 target_os = "macos",
24 target_os = "freebsd",
85aaf69f 25 target_os = "dragonfly",
c1a9b12d 26 target_os = "netbsd",
7453a54e 27 target_os = "openbsd",
5bcae85e
SL
28 target_os = "solaris",
29 target_os = "emscripten"))]
223e47cc 30mod m {
970d7e83 31 #[main]
223e47cc
LB
32 #[cfg(target_arch = "x86")]
33 pub fn main() {
34 unsafe {
c34b1796
AL
35 assert_eq!(::rusti::pref_align_of::<u64>(), 8);
36 assert_eq!(::rusti::min_align_of::<u64>(), 4);
223e47cc
LB
37 }
38 }
39
970d7e83 40 #[main]
9cc50fc6 41 #[cfg(not(target_arch = "x86"))]
223e47cc
LB
42 pub fn main() {
43 unsafe {
c34b1796
AL
44 assert_eq!(::rusti::pref_align_of::<u64>(), 8);
45 assert_eq!(::rusti::min_align_of::<u64>(), 8);
46 }
47 }
48}
49
50#[cfg(target_os = "bitrig")]
51mod m {
52 #[main]
53 #[cfg(target_arch = "x86_64")]
54 pub fn main() {
55 unsafe {
56 assert_eq!(::rusti::pref_align_of::<u64>(), 8);
57 assert_eq!(::rusti::min_align_of::<u64>(), 8);
223e47cc
LB
58 }
59 }
60}
61
1a4d82fc 62#[cfg(target_os = "windows")]
223e47cc 63mod m {
970d7e83 64 #[main]
223e47cc
LB
65 #[cfg(target_arch = "x86")]
66 pub fn main() {
67 unsafe {
c34b1796
AL
68 assert_eq!(::rusti::pref_align_of::<u64>(), 8);
69 assert_eq!(::rusti::min_align_of::<u64>(), 8);
970d7e83
LB
70 }
71 }
1a4d82fc
JJ
72
73 #[main]
74 #[cfg(target_arch = "x86_64")]
75 pub fn main() {
76 unsafe {
c34b1796
AL
77 assert_eq!(::rusti::pref_align_of::<u64>(), 8);
78 assert_eq!(::rusti::min_align_of::<u64>(), 8);
1a4d82fc
JJ
79 }
80 }
970d7e83
LB
81}
82
83#[cfg(target_os = "android")]
84mod m {
85 #[main]
85aaf69f 86 #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
970d7e83
LB
87 pub fn main() {
88 unsafe {
c34b1796
AL
89 assert_eq!(::rusti::pref_align_of::<u64>(), 8);
90 assert_eq!(::rusti::min_align_of::<u64>(), 8);
223e47cc
LB
91 }
92 }
93}