]> git.proxmox.com Git - rustc.git/blame - library/std/src/sys_common/util.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / library / std / src / sys_common / util.rs
CommitLineData
532ac7d7
XL
1use crate::fmt;
2use crate::io::prelude::*;
3use crate::sys::stdio::panic_output;
4use crate::thread;
1a4d82fc 5
532ac7d7 6pub fn dumb_print(args: fmt::Arguments<'_>) {
0731742a
XL
7 if let Some(mut out) = panic_output() {
8 let _ = out.write_fmt(args);
83c7162d 9 }
1a4d82fc
JJ
10}
11
3157f602
XL
12// Other platforms should use the appropriate platform-specific mechanism for
13// aborting the process. If no platform-specific mechanism is available,
532ac7d7 14// crate::intrinsics::abort() may be used instead. The above implementations cover
3157f602
XL
15// all targets currently supported by libstd.
16
532ac7d7 17pub fn abort(args: fmt::Arguments<'_>) -> ! {
9cc50fc6 18 dumb_print(format_args!("fatal runtime error: {}\n", args));
f9f354fc 19 crate::sys::abort_internal();
1a4d82fc
JJ
20}
21
e9174d1e 22#[allow(dead_code)] // stack overflow detection not enabled on all platforms
1a4d82fc 23pub unsafe fn report_overflow() {
60c5eb7d
XL
24 dumb_print(format_args!(
25 "\nthread '{}' has overflowed its stack\n",
26 thread::current().name().unwrap_or("<unknown>")
27 ));
1a4d82fc 28}