]>
Commit | Line | Data |
---|---|---|
532ac7d7 XL |
1 | use crate::fmt; |
2 | use crate::io::prelude::*; | |
3 | use crate::sys::stdio::panic_output; | |
4 | use crate::thread; | |
1a4d82fc | 5 | |
532ac7d7 | 6 | pub 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 | 17 | pub fn abort(args: fmt::Arguments<'_>) -> ! { |
9cc50fc6 | 18 | dumb_print(format_args!("fatal runtime error: {}\n", args)); |
60c5eb7d XL |
19 | unsafe { |
20 | crate::sys::abort_internal(); | |
21 | } | |
1a4d82fc JJ |
22 | } |
23 | ||
e9174d1e | 24 | #[allow(dead_code)] // stack overflow detection not enabled on all platforms |
1a4d82fc | 25 | pub unsafe fn report_overflow() { |
60c5eb7d XL |
26 | dumb_print(format_args!( |
27 | "\nthread '{}' has overflowed its stack\n", | |
28 | thread::current().name().unwrap_or("<unknown>") | |
29 | )); | |
1a4d82fc | 30 | } |