1 // Copyright 2013 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.
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.
13 use sys::stdio::{Stderr, stderr_prints_nothing};
16 pub fn dumb_print(args: fmt::Arguments) {
17 if stderr_prints_nothing() {
20 let _ = Stderr::new().map(|mut stderr| stderr.write_fmt(args));
23 // Other platforms should use the appropriate platform-specific mechanism for
24 // aborting the process. If no platform-specific mechanism is available,
25 // ::intrinsics::abort() may be used instead. The above implementations cover
26 // all targets currently supported by libstd.
28 pub fn abort(args: fmt::Arguments) -> ! {
29 dumb_print(format_args!("fatal runtime error: {}\n", args));
30 unsafe { ::sys::abort_internal(); }
33 #[allow(dead_code)] // stack overflow detection not enabled on all platforms
34 pub unsafe fn report_overflow() {
35 dumb_print(format_args!("\nthread '{}' has overflowed its stack\n",
36 thread::current().name().unwrap_or("<unknown>")));