mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 13:11:32 +00:00
Fixed emscripten main functions
This commit is contained in:
@ -735,8 +735,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"___syscall345" => func!(crate::syscalls::___syscall345),
|
"___syscall345" => func!(crate::syscalls::___syscall345),
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
"abort" => func!(crate::process::em_abort),
|
"abort" => func!(crate::process::_abort),
|
||||||
"_abort" => func!(crate::process::_abort),
|
"_abort" => func!(crate::process::_abort),
|
||||||
|
"_prctl" => func!(crate::process::_prctl),
|
||||||
"abortStackOverflow" => func!(crate::process::abort_stack_overflow),
|
"abortStackOverflow" => func!(crate::process::abort_stack_overflow),
|
||||||
"_llvm_trap" => func!(crate::process::_llvm_trap),
|
"_llvm_trap" => func!(crate::process::_llvm_trap),
|
||||||
"_fork" => func!(crate::process::_fork),
|
"_fork" => func!(crate::process::_fork),
|
||||||
@ -829,6 +830,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"_gmtime" => func!(crate::time::_gmtime),
|
"_gmtime" => func!(crate::time::_gmtime),
|
||||||
|
|
||||||
// Math
|
// Math
|
||||||
|
"sqrt" => func!(crate::math::sqrt),
|
||||||
|
"floor" => func!(crate::math::floor),
|
||||||
|
"fabs" => func!(crate::math::fabs),
|
||||||
"f64-rem" => func!(crate::math::f64_rem),
|
"f64-rem" => func!(crate::math::f64_rem),
|
||||||
"_llvm_copysign_f32" => func!(crate::math::_llvm_copysign_f32),
|
"_llvm_copysign_f32" => func!(crate::math::_llvm_copysign_f32),
|
||||||
"_llvm_copysign_f64" => func!(crate::math::_llvm_copysign_f64),
|
"_llvm_copysign_f64" => func!(crate::math::_llvm_copysign_f64),
|
||||||
|
@ -88,6 +88,21 @@ pub fn log(_ctx: &mut Ctx, value: f64) -> f64 {
|
|||||||
value.ln()
|
value.ln()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// emscripten: global.Math sqrt
|
||||||
|
pub fn sqrt(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||||
|
value.sqrt()
|
||||||
|
}
|
||||||
|
|
||||||
|
// emscripten: global.Math floor
|
||||||
|
pub fn floor(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||||
|
value.floor()
|
||||||
|
}
|
||||||
|
|
||||||
|
// emscripten: global.Math fabs
|
||||||
|
pub fn fabs(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||||
|
value.abs()
|
||||||
|
}
|
||||||
|
|
||||||
// emscripten: asm2wasm.f64-to-int
|
// emscripten: asm2wasm.f64-to-int
|
||||||
pub fn f64_to_int(_ctx: &mut Ctx, value: f64) -> i32 {
|
pub fn f64_to_int(_ctx: &mut Ctx, value: f64) -> i32 {
|
||||||
debug!("emscripten::f64_to_int {}", value);
|
debug!("emscripten::f64_to_int {}", value);
|
||||||
|
@ -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"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
type PidT = libc::pid_t;
|
type PidT = libc::pid_t;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
type PidT = c_int;
|
type PidT = c_int;
|
||||||
|
|
||||||
use std::ffi::CStr;
|
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
pub fn abort_with_message(ctx: &mut Ctx, message: &str) {
|
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 {
|
pub fn _fork(_ctx: &mut Ctx) -> PidT {
|
||||||
debug!("emscripten::_fork");
|
debug!("emscripten::_fork");
|
||||||
// unsafe {
|
// unsafe {
|
||||||
@ -45,18 +50,6 @@ pub fn _exit(_ctx: &mut Ctx, status: c_int) {
|
|||||||
unsafe { exit(status) }
|
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 {
|
pub fn _kill(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
debug!("emscripten::_kill");
|
debug!("emscripten::_kill");
|
||||||
-1
|
-1
|
||||||
|
Reference in New Issue
Block a user