mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
cf6d6050f7
* The WASI targets deal with the `main` symbol a bit differently than native so some `codegen` and `assembly` tests have been ignored. * All `ignore-emscripten` directives have been updated to `ignore-wasm32` to be more clear that all wasm targets are ignored and it's not just Emscripten. * Most `ignore-wasm32-bare` directives are now gone. * Some ignore directives for wasm were switched to `needs-unwind` instead. * Many `ignore-wasm32*` directives are removed as the tests work with WASI as opposed to `wasm32-unknown-unknown`.
29 lines
613 B
Rust
29 lines
613 B
Rust
//@ run-pass
|
|
#![allow(improper_ctypes, improper_ctypes_definitions)]
|
|
|
|
#[derive(Copy, Clone)]
|
|
pub struct S {
|
|
x: u64,
|
|
y: u64,
|
|
z: u64,
|
|
}
|
|
|
|
#[link(name = "rust_test_helpers", kind = "static")]
|
|
extern "C" {
|
|
pub fn get_x(x: S) -> u64;
|
|
pub fn get_y(x: S) -> u64;
|
|
pub fn get_z(x: S) -> u64;
|
|
}
|
|
|
|
#[inline(never)]
|
|
fn indirect_call(func: unsafe extern "C" fn(s: S) -> u64, s: S) -> u64 {
|
|
unsafe { func(s) }
|
|
}
|
|
|
|
fn main() {
|
|
let s = S { x: 1, y: 2, z: 3 };
|
|
assert_eq!(s.x, indirect_call(get_x, s));
|
|
assert_eq!(s.y, indirect_call(get_y, s));
|
|
assert_eq!(s.z, indirect_call(get_z, s));
|
|
}
|