Addd stack_save, stack_restore and set_threw for longjmp

This commit is contained in:
Syrus
2019-04-06 14:32:21 -07:00
parent 3b11da91c5
commit dc3c2227dc
2 changed files with 26 additions and 1 deletions

View File

@ -37,6 +37,18 @@ pub fn __longjmp(ctx: &mut Ctx, env_addr: u32, val: c_int) {
};
}
/// _longjmp
pub fn _longjmp(ctx: &mut Ctx, env_addr: i32, val: c_int) {
let val = if val == 0 {
1
} else {
val
};
get_emscripten_data(ctx).set_threw.as_ref().expect("set_threw is None").call(env_addr, val).expect("set_threw failed to call");
panic!("longjmp");
}
extern "C" {
fn setjmp(env: *mut c_void) -> c_int;
fn longjmp(env: *mut c_void, val: c_int) -> !;