2015-06-09 23:39:36 -05:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
2017-10-22 22:01:00 -05:00
|
|
|
|
2018-01-02 07:11:41 -06:00
|
|
|
// ignore-cloudabi stdout does not map to file descriptor 1 by default
|
2017-10-22 22:01:00 -05:00
|
|
|
// ignore-wasm32-bare no libc
|
|
|
|
|
2015-06-09 23:39:36 -05:00
|
|
|
#![feature(libc)]
|
|
|
|
|
|
|
|
extern crate libc;
|
|
|
|
|
2015-11-02 18:23:22 -06:00
|
|
|
type DWORD = u32;
|
|
|
|
type HANDLE = *mut u8;
|
|
|
|
|
2015-06-09 23:39:36 -05:00
|
|
|
#[cfg(windows)]
|
|
|
|
extern "system" {
|
2015-11-02 18:23:22 -06:00
|
|
|
fn GetStdHandle(which: DWORD) -> HANDLE;
|
|
|
|
fn CloseHandle(handle: HANDLE) -> i32;
|
2015-06-09 23:39:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
fn close_stdout() {
|
2015-11-02 18:23:22 -06:00
|
|
|
const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
|
|
|
|
unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); }
|
2015-06-09 23:39:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
fn close_stdout() {
|
2015-11-02 18:23:22 -06:00
|
|
|
unsafe { libc::close(1); }
|
2015-06-09 23:39:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
close_stdout();
|
|
|
|
println!("hello world");
|
|
|
|
}
|