3 // ignore-wasm32-bare no libc to test ffi with
15 #[derive(Copy, Clone)]
23 #[derive(Copy, Clone)]
24 pub struct CharCharDouble
{
31 #[derive(Copy, Clone)]
32 pub struct CharCharFloat
{
39 use super::{CharCharDouble, CharCharFloat, Floats, Quad}
;
41 #[link(name = "rust_test_helpers", kind = "static")]
43 pub fn rust_dbg_abi_1(q
: Quad
) -> Quad
;
44 pub fn rust_dbg_abi_2(f
: Floats
) -> Floats
;
45 pub fn rust_dbg_abi_3(a
: CharCharDouble
) -> CharCharDouble
;
46 pub fn rust_dbg_abi_4(a
: CharCharFloat
) -> CharCharFloat
;
53 a
: 0xaaaa_aaaa_aaaa_aaaa,
54 b
: 0xbbbb_bbbb_bbbb_bbbb,
55 c
: 0xcccc_cccc_cccc_cccc,
56 d
: 0xdddd_dddd_dddd_dddd,
58 let qq
= rustrt
::rust_dbg_abi_1(q
);
59 println
!("a: {:x}", qq
.a
as usize);
60 println
!("b: {:x}", qq
.b
as usize);
61 println
!("c: {:x}", qq
.c
as usize);
62 println
!("d: {:x}", qq
.d
as usize);
63 assert_eq
!(qq
.a
, q
.c
+ 1);
64 assert_eq
!(qq
.b
, q
.d
- 1);
65 assert_eq
!(qq
.c
, q
.a
+ 1);
66 assert_eq
!(qq
.d
, q
.b
- 1);
70 #[cfg(target_pointer_width = "64")]
73 let f
= Floats { a: 1.234567890e-15_f64, b: 0b_1010_1010, c: 1.0987654321e-15_f64 }
;
74 let ff
= rustrt
::rust_dbg_abi_2(f
);
75 println
!("a: {}", ff
.a
as f64);
76 println
!("b: {}", ff
.b
as usize);
77 println
!("c: {}", ff
.c
as f64);
78 assert_eq
!(ff
.a
, f
.c
+ 1.0f64);
79 assert_eq
!(ff
.b
, 0xff);
80 assert_eq
!(ff
.c
, f
.a
- 1.0f64);
84 #[cfg(target_pointer_width = "32")]
87 #[cfg(target_pointer_width = "64")]
90 let a
= CharCharDouble { a: 1, b: 2, c: 3. }
;
91 let b
= rustrt
::rust_dbg_abi_3(a
);
92 println
!("a: {}", b
.a
);
93 println
!("b: {}", b
.b
);
94 println
!("c: {}", b
.c
);
95 assert_eq
!(b
.a
, a
.a
+ 1);
96 assert_eq
!(b
.b
, a
.b
- 1);
97 assert_eq
!(b
.c
, a
.c
+ 1.0);
101 #[cfg(target_pointer_width = "32")]
106 let a
= CharCharFloat { a: 1, b: 2, c: 3. }
;
107 let b
= rustrt
::rust_dbg_abi_4(a
);
108 println
!("a: {}", b
.a
);
109 println
!("b: {}", b
.b
);
110 println
!("c: {}", b
.c
);
111 assert_eq
!(b
.a
, a
.a
+ 1);
112 assert_eq
!(b
.b
, a
.b
- 1);
113 assert_eq
!(b
.c
, a
.c
+ 1.0);