@@ -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]
102
+ ///
103
+ /// Apple 32-bit ARM (but not watchOS) uses the default routine instead
104
+ /// since it uses "setjmp-longjmp" unwinding.
105
+ ///
106
+ /// [ARM EHABI]: 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,10 @@ 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 SEH
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
249
252
#[ lang = "eh_personality" ]
250
253
#[ allow( nonstandard_style) ]
251
254
unsafe extern "C" fn rust_eh_personality(
@@ -254,6 +257,9 @@ cfg_if::cfg_if! {
254
257
contextRecord: * mut uw:: CONTEXT ,
255
258
dispatcherContext: * mut uw:: DISPATCHER_CONTEXT ,
256
259
) -> uw:: EXCEPTION_DISPOSITION {
260
+ // SAFETY: the cfg is still target_os = "windows" and target_env = "gnu",
261
+ // which means that this is the correct function to call, passing our impl fn
262
+ // as the callback which gets actually used
257
263
unsafe {
258
264
uw:: _GCC_specific_handler(
259
265
exceptionRecord,
@@ -265,7 +271,19 @@ cfg_if::cfg_if! {
265
271
}
266
272
}
267
273
} else {
268
- // The personality routine for most of our targets.
274
+ /// personality fn called by [Itanium C++ ABI Exception Handling][itanium-eh]
275
+ ///
276
+ /// The personality routine for most non-Windows targets. This will be called by
277
+ /// the unwinding library:
278
+ /// - "In the search phase, the framework repeatedly calls the personality routine,
279
+ /// with the _UA_SEARCH_PHASE flag as described below, first for the current PC
280
+ /// and register state, and then unwinding a frame to a new PC at each step..."
281
+ /// - "If the search phase reports success, the framework restarts in the cleanup
282
+ /// phase. Again, it repeatedly calls the personality routine, with the
283
+ /// _UA_CLEANUP_PHASE flag as described below, first for the current PC and
284
+ /// register state, and then unwinding a frame to a new PC at each step..."i
285
+ ///
286
+ /// [itanium-eh]: https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
269
287
#[ lang = "eh_personality" ]
270
288
unsafe extern "C" fn rust_eh_personality(
271
289
version: c_int,
@@ -274,6 +292,8 @@ cfg_if::cfg_if! {
274
292
exception_object: * mut uw:: _Unwind_Exception,
275
293
context: * mut uw:: _Unwind_Context,
276
294
) -> uw:: _Unwind_Reason_Code {
295
+ // SAFETY: the platform support must modify the cfg for the inner fn
296
+ // if it needs something different than what is currently invoked.
277
297
unsafe {
278
298
rust_eh_personality_impl(
279
299
version,
0 commit comments