-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
121 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// This file is part of libfringe, a low-level green threading library. | ||
// Copyright (c) Amanieu d'Antras <amanieu@gmail.com>, | ||
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or | ||
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or | ||
// http://opensource.org/licenses/MIT>, at your option. This file may not be | ||
// copied, modified, or distributed except according to those terms. | ||
|
||
use std::panic; | ||
use arch::StackPointer; | ||
use std::boxed::Box; | ||
|
||
struct UnwindMarker; | ||
|
||
pub unsafe extern "C" fn unwind_wrapper(arg: usize, sp: StackPointer, | ||
f: unsafe extern "C" fn(usize, StackPointer)) { | ||
match panic::catch_unwind(move || f(arg, sp)) { | ||
Ok(_) => (), | ||
Err(err) => { | ||
if !err.is::<UnwindMarker>() { | ||
// Propagate the panic to the parent context if it wasn't generated by us | ||
panic::resume_unwind(err) | ||
} | ||
} | ||
} | ||
} | ||
|
||
pub unsafe extern "C" fn force_unwind() -> ! { | ||
// Use resume_unwind instead of panic! to avoid printing a message | ||
panic::resume_unwind(Box::new(UnwindMarker)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters