2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-08-31 13:51:35 +00:00
|
|
|
#![allow(improper_ctypes)]
|
|
|
|
|
2017-10-23 03:01:00 +00:00
|
|
|
// ignore-wasm32-bare no libc for ffi testing
|
|
|
|
|
2013-04-02 00:47:38 +00:00
|
|
|
// Test a foreign function that accepts and returns a struct
|
|
|
|
// by value.
|
|
|
|
|
2015-03-30 13:38:27 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
2014-09-19 19:30:07 +00:00
|
|
|
pub struct TwoU32s {
|
2020-09-01 21:12:52 +00:00
|
|
|
one: u32,
|
|
|
|
two: u32,
|
2013-04-02 00:47:38 +00:00
|
|
|
}
|
|
|
|
|
2016-11-24 00:09:51 +00:00
|
|
|
#[link(name = "rust_test_helpers", kind = "static")]
|
2020-09-01 21:12:52 +00:00
|
|
|
extern "C" {
|
2013-04-02 00:47:38 +00:00
|
|
|
pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
unsafe {
|
2020-09-01 21:12:52 +00:00
|
|
|
let x = TwoU32s { one: 22, two: 23 };
|
2013-04-02 00:47:38 +00:00
|
|
|
let y = rust_dbg_extern_identity_TwoU32s(x);
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(x, y);
|
2013-04-02 00:47:38 +00:00
|
|
|
}
|
|
|
|
}
|