From 642c3c1b7914567d8b3114233d04119c95d21674 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Wed, 17 Apr 2024 17:52:03 +0100 Subject: [PATCH] Better comments around the panic handler --- agb/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agb/src/lib.rs b/agb/src/lib.rs index cb8f83dc..0954d778 100644 --- a/agb/src/lib.rs +++ b/agb/src/lib.rs @@ -214,11 +214,15 @@ fn panic_implementation(info: &core::panic::PanicInfo) -> ! { loop {} } +// If we panic during the panic handler, then there isn't much we can do any more. So this code +// just infinite loops halting the CPU. fn avoid_double_panic() { static IS_PANICKING: portable_atomic::AtomicBool = portable_atomic::AtomicBool::new(false); + if IS_PANICKING.load(portable_atomic::Ordering::SeqCst) { - // we panicked during the panic handler, so not much we can do here - loop {} + loop { + syscall::halt(); + } } else { IS_PANICKING.store(true, portable_atomic::Ordering::SeqCst); }