Added emscripten abort function

# Conflicts:
#	src/linkers/emscripten/mod.rs
This commit is contained in:
Syrus Akbary 2018-11-13 19:42:36 -08:00
parent 7bd2af98b3
commit b16fceb9d3
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,9 @@
use crate::webassembly::Instance;
use std::process;
pub extern "C" fn abort(_code: i32, _instance: &Instance) {
process::abort();
// abort!("Aborted")
}

View File

@ -2,11 +2,14 @@ use crate::webassembly::{ImportObject, ImportValue};
mod printf;
mod putchar;
mod abort;
pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
let mut import_object = ImportObject::new();
import_object.set("env", "printf", ImportValue::Func(printf::printf as *const u8));
import_object.set("env", "putchar", ImportValue::Func(putchar::putchar as *const u8));
import_object.set("env", "abort", ImportValue::Func(abort::abort as *const u8));
import_object.set("env", "_abort", ImportValue::Func(abort::abort as *const u8));
import_object
}