@@ -98,11 +98,12 @@ cfg_if::cfg_if! {
98
98
not( all( target_vendor = "apple" , not( target_os = "watchos" ) ) ) ,
99
99
not( target_os = "netbsd" ) ,
100
100
) ) ] {
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
106
107
#[ lang = "eh_personality" ]
107
108
unsafe extern "C" fn rust_eh_personality(
108
109
state: uw:: _Unwind_State,
@@ -198,8 +199,8 @@ cfg_if::cfg_if! {
198
199
}
199
200
}
200
201
} 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.
203
204
unsafe extern "C" fn rust_eh_personality_impl(
204
205
version: c_int,
205
206
actions: uw:: _Unwind_Action,
@@ -244,8 +245,12 @@ cfg_if::cfg_if! {
244
245
245
246
cfg_if:: cfg_if! {
246
247
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
249
254
#[ lang = "eh_personality" ]
250
255
#[ allow( nonstandard_style) ]
251
256
unsafe extern "C" fn rust_eh_personality(
@@ -254,6 +259,9 @@ cfg_if::cfg_if! {
254
259
contextRecord: * mut uw:: CONTEXT ,
255
260
dispatcherContext: * mut uw:: DISPATCHER_CONTEXT ,
256
261
) -> 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
257
265
unsafe {
258
266
uw:: _GCC_specific_handler(
259
267
exceptionRecord,
@@ -265,7 +273,19 @@ cfg_if::cfg_if! {
265
273
}
266
274
}
267
275
} 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
269
289
#[ lang = "eh_personality" ]
270
290
unsafe extern "C" fn rust_eh_personality(
271
291
version: c_int,
@@ -274,6 +294,8 @@ cfg_if::cfg_if! {
274
294
exception_object: * mut uw:: _Unwind_Exception,
275
295
context: * mut uw:: _Unwind_Context,
276
296
) -> 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.
277
299
unsafe {
278
300
rust_eh_personality_impl(
279
301
version,
0 commit comments