2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-11-12 22:58:17 -06:00
|
|
|
// xfail-win32 #9205
|
2013-09-17 02:42:16 -05:00
|
|
|
|
2013-03-05 16:42:58 -06:00
|
|
|
pub struct Quad { a: u64, b: u64, c: u64, d: u64 }
|
|
|
|
pub struct Floats { a: f64, b: u8, c: f64 }
|
2012-03-20 18:32:25 -05:00
|
|
|
|
2013-03-05 16:42:58 -06:00
|
|
|
mod rustrt {
|
|
|
|
use super::{Floats, Quad};
|
|
|
|
|
2013-11-16 04:02:07 -06:00
|
|
|
#[link(name = "rustrt")]
|
2013-07-18 21:08:57 -05:00
|
|
|
extern {
|
2013-08-23 00:57:40 -05:00
|
|
|
pub fn rust_dbg_abi_1(q: Quad) -> Quad;
|
|
|
|
pub fn rust_dbg_abi_2(f: Floats) -> Floats;
|
2013-03-05 16:42:58 -06:00
|
|
|
}
|
2012-03-20 18:32:25 -05:00
|
|
|
}
|
|
|
|
|
2012-03-20 19:34:05 -05:00
|
|
|
fn test1() {
|
2013-01-23 18:29:31 -06:00
|
|
|
unsafe {
|
2013-01-26 00:46:32 -06:00
|
|
|
let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa_u64,
|
2013-01-23 18:29:31 -06:00
|
|
|
b: 0xbbbb_bbbb_bbbb_bbbb_u64,
|
|
|
|
c: 0xcccc_cccc_cccc_cccc_u64,
|
|
|
|
d: 0xdddd_dddd_dddd_dddd_u64 };
|
2013-08-23 00:57:40 -05:00
|
|
|
let qq = rustrt::rust_dbg_abi_1(q);
|
2013-10-21 15:08:31 -05:00
|
|
|
error!("a: {:x}", qq.a as uint);
|
|
|
|
error!("b: {:x}", qq.b as uint);
|
|
|
|
error!("c: {:x}", qq.c as uint);
|
|
|
|
error!("d: {:x}", qq.d as uint);
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(qq.a, q.c + 1u64);
|
|
|
|
assert_eq!(qq.b, q.d - 1u64);
|
|
|
|
assert_eq!(qq.c, q.a + 1u64);
|
|
|
|
assert_eq!(qq.d, q.b - 1u64);
|
2013-01-23 18:29:31 -06:00
|
|
|
}
|
2012-03-20 19:34:05 -05:00
|
|
|
}
|
2012-03-20 18:32:25 -05:00
|
|
|
|
2012-03-20 19:34:05 -05:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
fn test2() {
|
2013-01-23 18:29:31 -06:00
|
|
|
unsafe {
|
2013-01-26 00:46:32 -06:00
|
|
|
let f = Floats { a: 1.234567890e-15_f64,
|
2013-01-23 18:29:31 -06:00
|
|
|
b: 0b_1010_1010_u8,
|
|
|
|
c: 1.0987654321e-15_f64 };
|
2013-08-23 00:57:40 -05:00
|
|
|
let ff = rustrt::rust_dbg_abi_2(f);
|
2013-10-21 15:08:31 -05:00
|
|
|
error!("a: {}", ff.a as f64);
|
|
|
|
error!("b: {}", ff.b as uint);
|
|
|
|
error!("c: {}", ff.c as f64);
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(ff.a, f.c + 1.0f64);
|
|
|
|
assert_eq!(ff.b, 0xff_u8);
|
|
|
|
assert_eq!(ff.c, f.a - 1.0f64);
|
2013-01-23 18:29:31 -06:00
|
|
|
}
|
2012-03-20 19:34:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_arch = "x86")]
|
2013-04-22 21:31:54 -05:00
|
|
|
#[cfg(target_arch = "arm")]
|
2012-03-20 19:34:05 -05:00
|
|
|
fn test2() {
|
|
|
|
}
|
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() {
|
2012-03-20 19:34:05 -05:00
|
|
|
test1();
|
|
|
|
test2();
|
2013-01-23 18:29:31 -06:00
|
|
|
}
|