]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/rfc-1014.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / run-pass / rfc-1014.rs
CommitLineData
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
XL
10
11// ignore-wasm32-bare no libc
12
62682a34 13#![feature(libc)]
223e47cc 14
62682a34 15extern crate libc;
85aaf69f 16
92a42be0
SL
17type DWORD = u32;
18type HANDLE = *mut u8;
19
62682a34
SL
20#[cfg(windows)]
21extern "system" {
92a42be0
SL
22 fn GetStdHandle(which: DWORD) -> HANDLE;
23 fn CloseHandle(handle: HANDLE) -> i32;
62682a34 24}
223e47cc 25
62682a34
SL
26#[cfg(windows)]
27fn close_stdout() {
92a42be0
SL
28 const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
29 unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); }
62682a34
SL
30}
31
32#[cfg(not(windows))]
33fn close_stdout() {
92a42be0 34 unsafe { libc::close(1); }
62682a34
SL
35}
36
37fn main() {
38 close_stdout();
39 println!("hello world");
40}