]>
Commit | Line | Data |
---|---|---|
1a4d82fc | 1 | // Copyright 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. | |
abe05a73 | 10 | |
b7449926 | 11 | // run-pass |
2c00a5a8 | 12 | // ignore-cloudabi stdout does not map to file descriptor 1 by default |
abe05a73 XL |
13 | // ignore-wasm32-bare no libc |
14 | ||
62682a34 | 15 | #![feature(libc)] |
223e47cc | 16 | |
62682a34 | 17 | extern crate libc; |
85aaf69f | 18 | |
92a42be0 SL |
19 | type DWORD = u32; |
20 | type HANDLE = *mut u8; | |
21 | ||
62682a34 SL |
22 | #[cfg(windows)] |
23 | extern "system" { | |
92a42be0 SL |
24 | fn GetStdHandle(which: DWORD) -> HANDLE; |
25 | fn CloseHandle(handle: HANDLE) -> i32; | |
62682a34 | 26 | } |
223e47cc | 27 | |
62682a34 SL |
28 | #[cfg(windows)] |
29 | fn close_stdout() { | |
92a42be0 SL |
30 | const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; |
31 | unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); } | |
62682a34 SL |
32 | } |
33 | ||
34 | #[cfg(not(windows))] | |
35 | fn close_stdout() { | |
92a42be0 | 36 | unsafe { libc::close(1); } |
62682a34 SL |
37 | } |
38 | ||
39 | fn main() { | |
40 | close_stdout(); | |
41 | println!("hello world"); | |
42 | } |