Skip to content

Commit

Permalink
Implement eh_unwind_resume in libstd.
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimcn committed Oct 19, 2015
1 parent 1da4662 commit def917a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/libstd/sys/common/libunwind.rs
Expand Up @@ -142,6 +142,9 @@ extern "C" {
-> _Unwind_Reason_Code;

pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception);

#[unwind]
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
}

// ... and now we just providing access to SjLj counterspart
Expand Down
7 changes: 7 additions & 0 deletions src/libstd/sys/common/unwind/gcc.rs
Expand Up @@ -231,3 +231,10 @@ pub mod eabi {
}
}
}

#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu", not(test)))]
#[lang = "eh_unwind_resume"]
#[unwind]
unsafe extern fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! {
uw::_Unwind_Resume(panic_ctx as *mut uw::_Unwind_Exception);
}
11 changes: 2 additions & 9 deletions src/libstd/sys/common/unwind/seh64_gnu.rs
Expand Up @@ -190,17 +190,10 @@ unsafe extern fn rust_eh_personality(
ExceptionContinueSearch
}

// The `resume` instruction, found at the end of the landing pads, and whose job
// is to resume stack unwinding, is typically lowered by LLVM into a call to
// `_Unwind_Resume` routine. To avoid confusion with the same symbol exported
// from libgcc, we redirect it to `rust_eh_unwind_resume`.
// Since resolution of this symbol is done by the linker, `rust_eh_unwind_resume`
// must be marked `pub` + `#[no_mangle]`. (Can we make it a lang item?)

#[lang = "eh_unwind_resume"]
#[cfg(not(test))]
#[lang = "eh_unwind_resume"]
#[unwind]
unsafe extern fn rust_eh_unwind_resume(panic_ctx: LPVOID) {
unsafe extern fn rust_eh_unwind_resume(panic_ctx: LPVOID) -> ! {
let params = [panic_ctx as ULONG_PTR];
RaiseException(RUST_PANIC,
EXCEPTION_NONCONTINUABLE,
Expand Down

0 comments on commit def917a

Please sign in to comment.