]>
Commit | Line | Data |
---|---|---|
85aaf69f | 1 | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT |
223e47cc LB |
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 | ||
223e47cc | 13 | // GetLastError doesn't seem to work with stack switching |
223e47cc | 14 | |
1a4d82fc JJ |
15 | #[cfg(windows)] |
16 | mod kernel32 { | |
17 | extern "system" { | |
c34b1796 AL |
18 | pub fn SetLastError(err: usize); |
19 | pub fn GetLastError() -> usize; | |
1a4d82fc | 20 | } |
223e47cc LB |
21 | } |
22 | ||
23 | ||
1a4d82fc | 24 | #[cfg(windows)] |
223e47cc LB |
25 | pub fn main() { |
26 | unsafe { | |
c34b1796 | 27 | let expected = 1234; |
223e47cc LB |
28 | kernel32::SetLastError(expected); |
29 | let actual = kernel32::GetLastError(); | |
1a4d82fc | 30 | println!("actual = {}", actual); |
970d7e83 | 31 | assert_eq!(expected, actual); |
223e47cc LB |
32 | } |
33 | } | |
34 | ||
1a4d82fc JJ |
35 | #[cfg(any(target_os = "macos", |
36 | target_os = "linux", | |
37 | target_os = "freebsd", | |
38 | target_os = "dragonfly", | |
c34b1796 | 39 | target_os = "bitrig", |
c1a9b12d | 40 | target_os = "netbsd", |
85aaf69f | 41 | target_os = "openbsd", |
7453a54e SL |
42 | target_os = "android", |
43 | target_os = "solaris", | |
44 | target_os = "emscripten"))] | |
223e47cc | 45 | pub fn main() { } |