@@ -98,11 +98,12 @@ cfg_if::cfg_if! {
9898 not( all( target_vendor = "apple" , not( target_os = "watchos" ) ) ) ,
9999 not( target_os = "netbsd" ) ,
100100 ) ) ] {
101- // ARM EHABI personality routine.
102- // https://web.archive.org/web/20190728160938/https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
103- //
104- // Apple 32-bit ARM (but not watchOS) uses the default routine instead
105- // since it uses SjLj unwinding.
101+ /// personality fn called by [ARM EHABI][armeabi-eh]
102+ ///
103+ /// Apple 32-bit ARM (but not watchOS) uses the default routine instead
104+ /// since it uses "setjmp-longjmp" unwinding.
105+ ///
106+ /// [armeabi-eh]: https://web.archive.org/web/20190728160938/https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
106107 #[ lang = "eh_personality" ]
107108 unsafe extern "C" fn rust_eh_personality(
108109 state: uw:: _Unwind_State,
@@ -198,8 +199,8 @@ cfg_if::cfg_if! {
198199 }
199200 }
200201 } else {
201- // Default personality routine, which is used directly on most targets
202- // and indirectly on Windows x86_64 via SEH.
202+ /// Default personality routine, which is used directly on most targets
203+ /// and indirectly on Windows x86_64 and AArch64 via SEH.
203204 unsafe extern "C" fn rust_eh_personality_impl(
204205 version: c_int,
205206 actions: uw:: _Unwind_Action,
@@ -244,8 +245,12 @@ cfg_if::cfg_if! {
244245
245246 cfg_if:: cfg_if! {
246247 if #[ cfg( all( windows, any( target_arch = "aarch64" , target_arch = "x86_64" ) , target_env = "gnu" ) ) ] {
247- // On x86_64 MinGW targets, the unwinding mechanism is SEH however the unwind
248- // handler data (aka LSDA) uses GCC-compatible encoding.
248+ /// personality fn called by [Windows Structured Exception Handling][windows-eh]
249+ ///
250+ /// On x86_64 and AArch64 MinGW targets, the unwinding mechanism is SEH,
251+ /// however the unwind handler data (aka LSDA) uses GCC-compatible encoding
252+ ///
253+ /// [windows-eh]: https://learn.microsoft.com/en-us/cpp/cpp/structured-exception-handling-c-cpp?view=msvc-170
249254 #[ lang = "eh_personality" ]
250255 #[ allow( nonstandard_style) ]
251256 unsafe extern "C" fn rust_eh_personality(
@@ -254,6 +259,9 @@ cfg_if::cfg_if! {
254259 contextRecord: * mut uw:: CONTEXT ,
255260 dispatcherContext: * mut uw:: DISPATCHER_CONTEXT ,
256261 ) -> uw:: EXCEPTION_DISPOSITION {
262+ // SAFETY: the cfg is still target_os = "windows" and target_env = "gnu",
263+ // which means that this is the correct function to call, passing our impl fn
264+ // as the callback which gets actually used
257265 unsafe {
258266 uw:: _GCC_specific_handler(
259267 exceptionRecord,
@@ -265,7 +273,19 @@ cfg_if::cfg_if! {
265273 }
266274 }
267275 } else {
268- // The personality routine for most of our targets.
276+ /// personality fn called by [Itanium C++ ABI Exception Handling][itanium-eh]
277+ ///
278+ /// The personality routine for most non-Windows targets. This will be called by
279+ /// the unwinding library:
280+ /// - "In the search phase, the framework repeatedly calls the personality routine,
281+ /// with the _UA_SEARCH_PHASE flag as described below, first for the current PC
282+ /// and register state, and then unwinding a frame to a new PC at each step..."
283+ /// - "If the search phase reports success, the framework restarts in the cleanup
284+ /// phase. Again, it repeatedly calls the personality routine, with the
285+ /// _UA_CLEANUP_PHASE flag as described below, first for the current PC and
286+ /// register state, and then unwinding a frame to a new PC at each step..."i
287+ ///
288+ /// [itanium-eh]: https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
269289 #[ lang = "eh_personality" ]
270290 unsafe extern "C" fn rust_eh_personality(
271291 version: c_int,
@@ -274,6 +294,8 @@ cfg_if::cfg_if! {
274294 exception_object: * mut uw:: _Unwind_Exception,
275295 context: * mut uw:: _Unwind_Context,
276296 ) -> uw:: _Unwind_Reason_Code {
297+ // SAFETY: the platform support must modify the cfg for the inner fn
298+ // if it needs something different than what is currently invoked.
277299 unsafe {
278300 rust_eh_personality_impl(
279301 version,
0 commit comments