]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/rfcs/rfc-1014.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / run-pass / rfcs / rfc-1014.rs
1 // Copyright 2015 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
11 // run-pass
12 #![allow(dead_code)]
13 // ignore-cloudabi stdout does not map to file descriptor 1 by default
14 // ignore-wasm32-bare no libc
15
16 #![feature(libc)]
17
18 extern crate libc;
19
20 type DWORD = u32;
21 type HANDLE = *mut u8;
22
23 #[cfg(windows)]
24 extern "system" {
25 fn GetStdHandle(which: DWORD) -> HANDLE;
26 fn CloseHandle(handle: HANDLE) -> i32;
27 }
28
29 #[cfg(windows)]
30 fn close_stdout() {
31 const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
32 unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); }
33 }
34
35 #[cfg(not(windows))]
36 fn close_stdout() {
37 unsafe { libc::close(1); }
38 }
39
40 fn main() {
41 close_stdout();
42 println!("hello world");
43 }