]>
Commit | Line | Data |
---|---|---|
b7449926 XL |
1 | // run-pass |
2 | #![allow(improper_ctypes)] | |
3 | ||
abe05a73 XL |
4 | // ignore-wasm32-bare no libc for ffi testing |
5 | ||
970d7e83 LB |
6 | // Test a foreign function that accepts and returns a struct |
7 | // by value. | |
223e47cc | 8 | |
c34b1796 | 9 | #[derive(Copy, Clone, PartialEq, Debug)] |
1a4d82fc | 10 | pub struct TwoU8s { |
5869c6ff XL |
11 | one: u8, |
12 | two: u8, | |
970d7e83 LB |
13 | } |
14 | ||
476ff2be | 15 | #[link(name = "rust_test_helpers", kind = "static")] |
5869c6ff | 16 | extern "C" { |
970d7e83 | 17 | pub fn rust_dbg_extern_identity_TwoU8s(v: TwoU8s) -> TwoU8s; |
223e47cc LB |
18 | } |
19 | ||
20 | pub fn main() { | |
970d7e83 | 21 | unsafe { |
5869c6ff | 22 | let x = TwoU8s { one: 22, two: 23 }; |
970d7e83 LB |
23 | let y = rust_dbg_extern_identity_TwoU8s(x); |
24 | assert_eq!(x, y); | |
25 | } | |
223e47cc | 26 | } |