mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-29 08:31:32 +00:00
Fixed emscripten main functions
This commit is contained in:
@ -1,11 +1,10 @@
|
||||
use libc::{abort, c_char, c_int, exit, EAGAIN};
|
||||
use libc::{abort, c_int, exit, EAGAIN};
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
type PidT = libc::pid_t;
|
||||
#[cfg(target_os = "windows")]
|
||||
type PidT = c_int;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub fn abort_with_message(ctx: &mut Ctx, message: &str) {
|
||||
@ -21,6 +20,12 @@ pub fn _abort(_ctx: &mut Ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _prctl(ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
debug!("emscripten::_prctl");
|
||||
abort_with_message(ctx, "missing function: prctl");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _fork(_ctx: &mut Ctx) -> PidT {
|
||||
debug!("emscripten::_fork");
|
||||
// unsafe {
|
||||
@ -45,18 +50,6 @@ pub fn _exit(_ctx: &mut Ctx, status: c_int) {
|
||||
unsafe { exit(status) }
|
||||
}
|
||||
|
||||
pub fn em_abort(ctx: &mut Ctx, message: u32) {
|
||||
debug!("emscripten::em_abort {}", message);
|
||||
let message_addr = emscripten_memory_pointer!(ctx.memory(0), message) as *mut c_char;
|
||||
unsafe {
|
||||
let message = CStr::from_ptr(message_addr)
|
||||
.to_str()
|
||||
.unwrap_or("Unexpected abort");
|
||||
|
||||
abort_with_message(ctx, message);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _kill(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_kill");
|
||||
-1
|
||||
|
Reference in New Issue
Block a user