]>
Commit | Line | Data |
---|---|---|
9e0c209e SL |
1 | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
abe05a73 XL |
11 | // ignore-wasm32-bare no libc to test ffi with |
12 | ||
9e0c209e SL |
13 | #[derive(Clone, Copy)] |
14 | #[repr(C)] | |
15 | struct LARGE_INTEGER_U { | |
16 | LowPart: u32, | |
17 | HighPart: u32, | |
18 | } | |
19 | ||
20 | #[derive(Clone, Copy)] | |
21 | #[repr(C)] | |
22 | union LARGE_INTEGER { | |
23 | __unnamed__: LARGE_INTEGER_U, | |
24 | u: LARGE_INTEGER_U, | |
25 | QuadPart: u64, | |
26 | } | |
27 | ||
476ff2be | 28 | #[link(name = "rust_test_helpers", kind = "static")] |
9e0c209e SL |
29 | extern "C" { |
30 | fn increment_all_parts(_: LARGE_INTEGER) -> LARGE_INTEGER; | |
31 | } | |
32 | ||
33 | fn main() { | |
34 | unsafe { | |
35 | let mut li = LARGE_INTEGER { QuadPart: 0 }; | |
36 | let li_c = increment_all_parts(li); | |
37 | li.__unnamed__.LowPart += 1; | |
38 | li.__unnamed__.HighPart += 1; | |
39 | li.u.LowPart += 1; | |
40 | li.u.HighPart += 1; | |
41 | li.QuadPart += 1; | |
42 | assert_eq!(li.QuadPart, li_c.QuadPart); | |
43 | } | |
44 | } |