Skip to content

Commit

Permalink
Rename rterr to rtprintpanic
Browse files Browse the repository at this point in the history
  • Loading branch information
CDirkx committed May 19, 2021
1 parent 6145051 commit 4ff5ab5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion library/std/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub fn take_alloc_error_hook() -> fn(Layout) {
}

fn default_alloc_error_hook(layout: Layout) {
rterr!("memory allocation of {} bytes failed\n", layout.size());
rtprintpanic!("memory allocation of {} bytes failed\n", layout.size());
}

#[cfg(not(test))]
Expand Down
9 changes: 3 additions & 6 deletions library/std/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,15 +596,12 @@ fn rust_panic_with_hook(
if panics > 2 {
// Don't try to print the message in this case
// - perhaps that is causing the recursive panics.
rterr!("thread panicked while processing panic. aborting.\n");
rtprintpanic!("thread panicked while processing panic. aborting.\n");
} else {
// Unfortunately, this does not print a backtrace, because creating
// a `Backtrace` will allocate, which we must to avoid here.
let panicinfo = PanicInfo::internal_constructor(message, location);
rterr!(
"{}\npanicked after panic::always_abort(), aborting.\n",
panicinfo
);
rtprintpanic!("{}\npanicked after panic::always_abort(), aborting.\n", panicinfo);
}
intrinsics::abort()
}
Expand Down Expand Up @@ -637,7 +634,7 @@ fn rust_panic_with_hook(
// have limited options. Currently our preference is to
// just abort. In the future we may consider resuming
// unwinding or otherwise exiting the thread cleanly.
rterr!("thread panicked while panicking. aborting.\n");
rtprintpanic!("thread panicked while panicking. aborting.\n");
intrinsics::abort()
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod imp {
// If the faulting address is within the guard page, then we print a
// message saying so and abort.
if guard.start <= addr && addr < guard.end {
rterr!(
rtprintpanic!(
"\nthread '{}' has overflowed its stack\n",
thread::current().name().unwrap_or("<unknown>")
);
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/windows/stack_overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS) -
let code = rec.ExceptionCode;

if code == c::EXCEPTION_STACK_OVERFLOW {
rterr!(
rtprintpanic!(
"\nthread '{}' has overflowed its stack\n",
thread::current().name().unwrap_or("<unknown>")
);
Expand Down
8 changes: 6 additions & 2 deletions library/std/src/sys_common/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ pub fn cleanup() {
});
}

macro_rules! rterr {
// Prints to the "panic output", depending on the platform this may be:
// - the standard error output
// - some dedicated platform specific output
// - nothing (so this macro is a no-op)
macro_rules! rtprintpanic {
($($t:tt)*) => {
if let Some(mut out) = crate::sys::stdio::panic_output() {
let _ = crate::io::Write::write_fmt(&mut out, format_args!($($t)*));
Expand All @@ -50,7 +54,7 @@ macro_rules! rterr {
macro_rules! rtabort {
($($t:tt)*) => {
{
rterr!("fatal runtime error: {}\n", format_args!($($t)*));
rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*));
crate::sys::abort_internal();
}
}
Expand Down

0 comments on commit 4ff5ab5

Please sign in to comment.