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