]> git.lizzy.rs Git - rust.git/blob - src/test/ui/abi/union/union-c-interop.rs
Rollup merge of #91828 - oxalica:feat/waker-getters, r=dtolnay
[rust.git] / src / test / ui / abi / union / union-c-interop.rs
1 // run-pass
2 #![allow(non_snake_case)]
3
4 // ignore-wasm32-bare no libc to test ffi with
5
6 #[derive(Clone, Copy)]
7 #[repr(C)]
8 struct LARGE_INTEGER_U {
9     LowPart: u32,
10     HighPart: u32,
11 }
12
13 #[derive(Clone, Copy)]
14 #[repr(C)]
15 union LARGE_INTEGER {
16   __unnamed__: LARGE_INTEGER_U,
17   u: LARGE_INTEGER_U,
18   QuadPart: u64,
19 }
20
21 #[link(name = "rust_test_helpers", kind = "static")]
22 extern "C" {
23     fn increment_all_parts(_: LARGE_INTEGER) -> LARGE_INTEGER;
24 }
25
26 fn main() {
27     unsafe {
28         let mut li = LARGE_INTEGER { QuadPart: 0 };
29         let li_c = increment_all_parts(li);
30         li.__unnamed__.LowPart += 1;
31         li.__unnamed__.HighPart += 1;
32         li.u.LowPart += 1;
33         li.u.HighPart += 1;
34         li.QuadPart += 1;
35         assert_eq!(li.QuadPart, li_c.QuadPart);
36     }
37 }