mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-05 12:18:30 +00:00
Update Emscripten to use new env and new types
This commit is contained in:
@@ -9,12 +9,7 @@ use wasmer_runtime::{
|
||||
wasmer_call_trampoline, ExportFunction, VMContext, VMFunctionBody, VMFunctionKind,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UnprovidedArgs;
|
||||
#[derive(Clone)]
|
||||
pub struct UnprovidedRets;
|
||||
|
||||
pub struct NativeFunc<'a, Args = UnprovidedArgs, Rets = UnprovidedRets> {
|
||||
pub struct NativeFunc<'a, Args = (), Rets = ()> {
|
||||
definition: FunctionDefinition,
|
||||
store: Store,
|
||||
address: *const VMFunctionBody,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::emscripten_target;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
///emscripten: _llvm_bswap_i64
|
||||
pub fn _llvm_bswap_i64(_ctx: &mut Ctx, _low: i32, high: i32) -> i32 {
|
||||
pub fn _llvm_bswap_i64(ctx: &mut EmEnv, _low: i32, high: i32) -> i32 {
|
||||
debug!("emscripten::_llvm_bswap_i64");
|
||||
emscripten_target::setTempRet0(_ctx, _low.swap_bytes());
|
||||
emscripten_target::setTempRet0(ctx, _low.swap_bytes());
|
||||
high.swap_bytes()
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::env::get_emscripten_data;
|
||||
use crate::EmEnv;
|
||||
#[cfg(target_os = "linux")]
|
||||
use libc::getdtablesize;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub fn asm_const_i(_ctx: &mut Ctx, _val: i32) -> i32 {
|
||||
pub fn asm_const_i(_ctx: &mut EmEnv, _val: i32) -> i32 {
|
||||
debug!("emscripten::asm_const_i: {}", _val);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn exit_with_live_runtime(_ctx: &mut Ctx) {
|
||||
pub fn exit_with_live_runtime(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::exit_with_live_runtime");
|
||||
}
|
||||
|
||||
pub fn setTempRet0(ctx: &mut Ctx, val: i32) {
|
||||
pub fn setTempRet0(ctx: &mut EmEnv, val: i32) {
|
||||
trace!("emscripten::setTempRet0: {}", val);
|
||||
get_emscripten_data(ctx).temp_ret_0 = val;
|
||||
}
|
||||
|
||||
pub fn getTempRet0(ctx: &mut Ctx) -> i32 {
|
||||
pub fn getTempRet0(ctx: &mut EmEnv) -> i32 {
|
||||
trace!("emscripten::getTempRet0");
|
||||
get_emscripten_data(ctx).temp_ret_0
|
||||
}
|
||||
|
||||
pub fn _alarm(_ctx: &mut Ctx, _seconds: u32) -> i32 {
|
||||
pub fn _alarm(_ctx: &mut EmEnv, _seconds: u32) -> i32 {
|
||||
debug!("emscripten::_alarm({})", _seconds);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _atexit(_ctx: &mut Ctx, _func: i32) -> i32 {
|
||||
pub fn _atexit(_ctx: &mut EmEnv, _func: i32) -> i32 {
|
||||
debug!("emscripten::_atexit");
|
||||
// TODO: implement atexit properly
|
||||
// __ATEXIT__.unshift({
|
||||
@@ -38,38 +38,38 @@ pub fn _atexit(_ctx: &mut Ctx, _func: i32) -> i32 {
|
||||
// });
|
||||
0
|
||||
}
|
||||
pub fn __Unwind_Backtrace(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn __Unwind_Backtrace(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
debug!("emscripten::__Unwind_Backtrace");
|
||||
0
|
||||
}
|
||||
pub fn __Unwind_FindEnclosingFunction(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn __Unwind_FindEnclosingFunction(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
debug!("emscripten::__Unwind_FindEnclosingFunction");
|
||||
0
|
||||
}
|
||||
pub fn __Unwind_GetIPInfo(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn __Unwind_GetIPInfo(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
debug!("emscripten::__Unwind_GetIPInfo");
|
||||
0
|
||||
}
|
||||
pub fn ___cxa_find_matching_catch_2(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___cxa_find_matching_catch_2(_ctx: &mut EmEnv) -> i32 {
|
||||
debug!("emscripten::___cxa_find_matching_catch_2");
|
||||
0
|
||||
}
|
||||
pub fn ___cxa_find_matching_catch_3(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn ___cxa_find_matching_catch_3(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
debug!("emscripten::___cxa_find_matching_catch_3");
|
||||
0
|
||||
}
|
||||
pub fn ___cxa_free_exception(_ctx: &mut Ctx, _a: i32) {
|
||||
pub fn ___cxa_free_exception(_ctx: &mut EmEnv, _a: i32) {
|
||||
debug!("emscripten::___cxa_free_exception");
|
||||
}
|
||||
pub fn ___resumeException(_ctx: &mut Ctx, _a: i32) {
|
||||
pub fn ___resumeException(_ctx: &mut EmEnv, _a: i32) {
|
||||
debug!("emscripten::___resumeException");
|
||||
}
|
||||
pub fn _dladdr(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _dladdr(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
debug!("emscripten::_dladdr");
|
||||
0
|
||||
}
|
||||
pub fn ___gxx_personality_v0(
|
||||
_ctx: &mut Ctx,
|
||||
_ctx: &mut EmEnv,
|
||||
_a: i32,
|
||||
_b: i32,
|
||||
_c: i32,
|
||||
@@ -82,25 +82,25 @@ pub fn ___gxx_personality_v0(
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn _getdtablesize(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn _getdtablesize(_ctx: &mut EmEnv) -> i32 {
|
||||
debug!("emscripten::getdtablesize");
|
||||
unsafe { getdtablesize() }
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
pub fn _getdtablesize(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn _getdtablesize(_ctx: &mut EmEnv) -> i32 {
|
||||
debug!("emscripten::getdtablesize");
|
||||
-1
|
||||
}
|
||||
pub fn _gethostbyaddr(_ctx: &mut Ctx, _addr: i32, _addrlen: i32, _atype: i32) -> i32 {
|
||||
pub fn _gethostbyaddr(_ctx: &mut EmEnv, _addr: i32, _addrlen: i32, _atype: i32) -> i32 {
|
||||
debug!("emscripten::gethostbyaddr");
|
||||
0
|
||||
}
|
||||
pub fn _gethostbyname(_ctx: &mut Ctx, _name: i32) -> i32 {
|
||||
pub fn _gethostbyname(_ctx: &mut EmEnv, _name: i32) -> i32 {
|
||||
debug!("emscripten::gethostbyname_r");
|
||||
0
|
||||
}
|
||||
pub fn _gethostbyname_r(
|
||||
_ctx: &mut Ctx,
|
||||
_ctx: &mut EmEnv,
|
||||
_name: i32,
|
||||
_ret: i32,
|
||||
_buf: i32,
|
||||
@@ -112,12 +112,12 @@ pub fn _gethostbyname_r(
|
||||
0
|
||||
}
|
||||
// NOTE: php.js has proper impl; libc has proper impl for linux
|
||||
pub fn _getloadavg(_ctx: &mut Ctx, _loadavg: i32, _nelem: i32) -> i32 {
|
||||
pub fn _getloadavg(_ctx: &mut EmEnv, _loadavg: i32, _nelem: i32) -> i32 {
|
||||
debug!("emscripten::getloadavg");
|
||||
0
|
||||
}
|
||||
pub fn _getnameinfo(
|
||||
_ctx: &mut Ctx,
|
||||
_ctx: &mut EmEnv,
|
||||
_addr: i32,
|
||||
_addrlen: i32,
|
||||
_host: i32,
|
||||
@@ -170,61 +170,61 @@ macro_rules! invoke_no_return {
|
||||
}
|
||||
|
||||
// Invoke functions
|
||||
pub fn invoke_i(ctx: &mut Ctx, index: i32) -> i32 {
|
||||
pub fn invoke_i(ctx: &mut EmEnv, index: i32) -> i32 {
|
||||
debug!("emscripten::invoke_i");
|
||||
invoke!(ctx, dyn_call_i, index)
|
||||
}
|
||||
pub fn invoke_ii(ctx: &mut Ctx, index: i32, a1: i32) -> i32 {
|
||||
pub fn invoke_ii(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 {
|
||||
debug!("emscripten::invoke_ii");
|
||||
invoke!(ctx, dyn_call_ii, index, a1)
|
||||
}
|
||||
pub fn invoke_iii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) -> i32 {
|
||||
pub fn invoke_iii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 {
|
||||
debug!("emscripten::invoke_iii");
|
||||
invoke!(ctx, dyn_call_iii, index, a1, a2)
|
||||
}
|
||||
pub fn invoke_iiii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
pub fn invoke_iiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
debug!("emscripten::invoke_iiii");
|
||||
invoke!(ctx, dyn_call_iiii, index, a1, a2, a3)
|
||||
}
|
||||
pub fn invoke_iifi(ctx: &mut Ctx, index: i32, a1: i32, a2: f64, a3: i32) -> i32 {
|
||||
pub fn invoke_iifi(ctx: &mut EmEnv, index: i32, a1: i32, a2: f64, a3: i32) -> i32 {
|
||||
debug!("emscripten::invoke_iifi");
|
||||
invoke!(ctx, dyn_call_iifi, index, a1, a2, a3)
|
||||
}
|
||||
pub fn invoke_v(ctx: &mut Ctx, index: i32) {
|
||||
pub fn invoke_v(ctx: &mut EmEnv, index: i32) {
|
||||
debug!("emscripten::invoke_v");
|
||||
invoke_no_return!(ctx, dyn_call_v, index);
|
||||
}
|
||||
pub fn invoke_vi(ctx: &mut Ctx, index: i32, a1: i32) {
|
||||
pub fn invoke_vi(ctx: &mut EmEnv, index: i32, a1: i32) {
|
||||
debug!("emscripten::invoke_vi");
|
||||
invoke_no_return!(ctx, dyn_call_vi, index, a1);
|
||||
}
|
||||
pub fn invoke_vii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) {
|
||||
pub fn invoke_vii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) {
|
||||
debug!("emscripten::invoke_vii");
|
||||
invoke_no_return!(ctx, dyn_call_vii, index, a1, a2);
|
||||
}
|
||||
|
||||
pub fn invoke_viii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) {
|
||||
pub fn invoke_viii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) {
|
||||
debug!("emscripten::invoke_viii");
|
||||
invoke_no_return!(ctx, dyn_call_viii, index, a1, a2, a3);
|
||||
}
|
||||
pub fn invoke_viiii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
|
||||
pub fn invoke_viiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
|
||||
debug!("emscripten::invoke_viiii");
|
||||
invoke_no_return!(ctx, dyn_call_viiii, index, a1, a2, a3, a4);
|
||||
}
|
||||
pub fn invoke_dii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) -> f64 {
|
||||
pub fn invoke_dii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> f64 {
|
||||
debug!("emscripten::invoke_dii");
|
||||
invoke!(ctx, dyn_call_dii, index, a1, a2)
|
||||
}
|
||||
pub fn invoke_diiii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> f64 {
|
||||
pub fn invoke_diiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> f64 {
|
||||
debug!("emscripten::invoke_diiii");
|
||||
invoke!(ctx, dyn_call_diiii, index, a1, a2, a3, a4)
|
||||
}
|
||||
pub fn invoke_iiiii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
|
||||
pub fn invoke_iiiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
|
||||
debug!("emscripten::invoke_iiiii");
|
||||
invoke!(ctx, dyn_call_iiiii, index, a1, a2, a3, a4)
|
||||
}
|
||||
pub fn invoke_iiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -236,7 +236,7 @@ pub fn invoke_iiiiii(
|
||||
invoke!(ctx, dyn_call_iiiiii, index, a1, a2, a3, a4, a5)
|
||||
}
|
||||
pub fn invoke_iiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -249,7 +249,7 @@ pub fn invoke_iiiiiii(
|
||||
invoke!(ctx, dyn_call_iiiiiii, index, a1, a2, a3, a4, a5, a6)
|
||||
}
|
||||
pub fn invoke_iiiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -263,7 +263,7 @@ pub fn invoke_iiiiiiii(
|
||||
invoke!(ctx, dyn_call_iiiiiiii, index, a1, a2, a3, a4, a5, a6, a7)
|
||||
}
|
||||
pub fn invoke_iiiiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -290,7 +290,7 @@ pub fn invoke_iiiiiiiii(
|
||||
)
|
||||
}
|
||||
pub fn invoke_iiiiiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -319,7 +319,7 @@ pub fn invoke_iiiiiiiiii(
|
||||
)
|
||||
}
|
||||
pub fn invoke_iiiiiiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -349,16 +349,16 @@ pub fn invoke_iiiiiiiiiii(
|
||||
a10
|
||||
)
|
||||
}
|
||||
pub fn invoke_vd(ctx: &mut Ctx, index: i32, a1: f64) {
|
||||
pub fn invoke_vd(ctx: &mut EmEnv, index: i32, a1: f64) {
|
||||
debug!("emscripten::invoke_vd");
|
||||
invoke_no_return!(ctx, dyn_call_vd, index, a1)
|
||||
}
|
||||
pub fn invoke_viiiii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
pub fn invoke_viiiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
debug!("emscripten::invoke_viiiii");
|
||||
invoke_no_return!(ctx, dyn_call_viiiii, index, a1, a2, a3, a4, a5)
|
||||
}
|
||||
pub fn invoke_viiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -371,7 +371,7 @@ pub fn invoke_viiiiii(
|
||||
invoke_no_return!(ctx, dyn_call_viiiiii, index, a1, a2, a3, a4, a5, a6)
|
||||
}
|
||||
pub fn invoke_viiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -385,7 +385,7 @@ pub fn invoke_viiiiiii(
|
||||
invoke_no_return!(ctx, dyn_call_viiiiiii, index, a1, a2, a3, a4, a5, a6, a7)
|
||||
}
|
||||
pub fn invoke_viiiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -412,7 +412,7 @@ pub fn invoke_viiiiiiii(
|
||||
)
|
||||
}
|
||||
pub fn invoke_viiiiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -441,7 +441,7 @@ pub fn invoke_viiiiiiiii(
|
||||
)
|
||||
}
|
||||
pub fn invoke_viiiiiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -472,23 +472,23 @@ pub fn invoke_viiiiiiiiii(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn invoke_iij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
pub fn invoke_iij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
debug!("emscripten::invoke_iij");
|
||||
invoke!(ctx, dyn_call_iij, index, a1, a2, a3)
|
||||
}
|
||||
|
||||
pub fn invoke_iji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
pub fn invoke_iji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
debug!("emscripten::invoke_iji");
|
||||
invoke!(ctx, dyn_call_iji, index, a1, a2, a3)
|
||||
}
|
||||
|
||||
pub fn invoke_iiji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
|
||||
pub fn invoke_iiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
|
||||
debug!("emscripten::invoke_iiji");
|
||||
invoke!(ctx, dyn_call_iiji, index, a1, a2, a3, a4)
|
||||
}
|
||||
|
||||
pub fn invoke_iiijj(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -500,7 +500,7 @@ pub fn invoke_iiijj(
|
||||
debug!("emscripten::invoke_iiijj");
|
||||
invoke!(ctx, dyn_call_iiijj, index, a1, a2, a3, a4, a5, a6)
|
||||
}
|
||||
pub fn invoke_j(ctx: &mut Ctx, index: i32) -> i32 {
|
||||
pub fn invoke_j(ctx: &mut EmEnv, index: i32) -> i32 {
|
||||
debug!("emscripten::invoke_j");
|
||||
if let Some(dyn_call_j) = &get_emscripten_data(ctx).dyn_call_j {
|
||||
dyn_call_j.call(index).unwrap()
|
||||
@@ -508,7 +508,7 @@ pub fn invoke_j(ctx: &mut Ctx, index: i32) -> i32 {
|
||||
panic!("dyn_call_j is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_ji(ctx: &mut Ctx, index: i32, a1: i32) -> i32 {
|
||||
pub fn invoke_ji(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 {
|
||||
debug!("emscripten::invoke_ji");
|
||||
if let Some(dyn_call_ji) = &get_emscripten_data(ctx).dyn_call_ji {
|
||||
dyn_call_ji.call(index, a1).unwrap()
|
||||
@@ -516,7 +516,7 @@ pub fn invoke_ji(ctx: &mut Ctx, index: i32, a1: i32) -> i32 {
|
||||
panic!("dyn_call_ji is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_jii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) -> i32 {
|
||||
pub fn invoke_jii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 {
|
||||
debug!("emscripten::invoke_jii");
|
||||
if let Some(dyn_call_jii) = &get_emscripten_data(ctx).dyn_call_jii {
|
||||
dyn_call_jii.call(index, a1, a2).unwrap()
|
||||
@@ -525,7 +525,7 @@ pub fn invoke_jii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn invoke_jij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
pub fn invoke_jij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
debug!("emscripten::invoke_jij");
|
||||
if let Some(dyn_call_jij) = &get_emscripten_data(ctx).dyn_call_jij {
|
||||
dyn_call_jij.call(index, a1, a2, a3).unwrap()
|
||||
@@ -533,7 +533,7 @@ pub fn invoke_jij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
|
||||
panic!("dyn_call_jij is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_jjj(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
|
||||
pub fn invoke_jjj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
|
||||
debug!("emscripten::invoke_jjj");
|
||||
if let Some(dyn_call_jjj) = &get_emscripten_data(ctx).dyn_call_jjj {
|
||||
dyn_call_jjj.call(index, a1, a2, a3, a4).unwrap()
|
||||
@@ -541,7 +541,7 @@ pub fn invoke_jjj(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32)
|
||||
panic!("dyn_call_jjj is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_viiij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
pub fn invoke_viiij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
debug!("emscripten::invoke_viiij");
|
||||
if let Some(dyn_call_viiij) = &get_emscripten_data(ctx).dyn_call_viiij {
|
||||
dyn_call_viiij.call(index, a1, a2, a3, a4, a5).unwrap();
|
||||
@@ -550,7 +550,7 @@ pub fn invoke_viiij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i3
|
||||
}
|
||||
}
|
||||
pub fn invoke_viiijiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -572,7 +572,7 @@ pub fn invoke_viiijiiii(
|
||||
}
|
||||
}
|
||||
pub fn invoke_viiijiiiiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -595,7 +595,7 @@ pub fn invoke_viiijiiiiii(
|
||||
panic!("dyn_call_viiijiiiiii is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_viij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
|
||||
pub fn invoke_viij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
|
||||
debug!("emscripten::invoke_viij");
|
||||
if let Some(dyn_call_viij) = &get_emscripten_data(ctx).dyn_call_viij {
|
||||
dyn_call_viij.call(index, a1, a2, a3, a4).unwrap();
|
||||
@@ -603,7 +603,7 @@ pub fn invoke_viij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32
|
||||
panic!("dyn_call_viij is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_viiji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
pub fn invoke_viiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
debug!("emscripten::invoke_viiji");
|
||||
if let Some(dyn_call_viiji) = &get_emscripten_data(ctx).dyn_call_viiji {
|
||||
dyn_call_viiji.call(index, a1, a2, a3, a4, a5).unwrap();
|
||||
@@ -612,7 +612,7 @@ pub fn invoke_viiji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i3
|
||||
}
|
||||
}
|
||||
pub fn invoke_viijiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -632,7 +632,7 @@ pub fn invoke_viijiii(
|
||||
}
|
||||
}
|
||||
pub fn invoke_viijj(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -648,7 +648,7 @@ pub fn invoke_viijj(
|
||||
panic!("dyn_call_viijj is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_vj(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) {
|
||||
pub fn invoke_vj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) {
|
||||
debug!("emscripten::invoke_vj");
|
||||
if let Some(dyn_call_vj) = &get_emscripten_data(ctx).dyn_call_vj {
|
||||
dyn_call_vj.call(index, a1, a2).unwrap();
|
||||
@@ -656,11 +656,11 @@ pub fn invoke_vj(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) {
|
||||
panic!("dyn_call_vj is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_vjji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
pub fn invoke_vjji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
debug!("emscripten::invoke_vjji");
|
||||
invoke_no_return!(ctx, dyn_call_vjji, index, a1, a2, a3, a4, a5)
|
||||
}
|
||||
pub fn invoke_vij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) {
|
||||
pub fn invoke_vij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) {
|
||||
debug!("emscripten::invoke_vij");
|
||||
if let Some(dyn_call_vij) = &get_emscripten_data(ctx).dyn_call_vij {
|
||||
dyn_call_vij.call(index, a1, a2, a3).unwrap();
|
||||
@@ -668,7 +668,7 @@ pub fn invoke_vij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) {
|
||||
panic!("dyn_call_vij is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_viji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
|
||||
pub fn invoke_viji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
|
||||
debug!("emscripten::invoke_viji");
|
||||
if let Some(dyn_call_viji) = &get_emscripten_data(ctx).dyn_call_viji {
|
||||
dyn_call_viji.call(index, a1, a2, a3, a4).unwrap()
|
||||
@@ -677,7 +677,7 @@ pub fn invoke_viji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32
|
||||
}
|
||||
}
|
||||
pub fn invoke_vijiii(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
@@ -693,7 +693,7 @@ pub fn invoke_vijiii(
|
||||
panic!("dyn_call_vijiii is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_vijj(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
pub fn invoke_vijj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
|
||||
debug!("emscripten::invoke_vijj");
|
||||
if let Some(dyn_call_vijj) = &get_emscripten_data(ctx).dyn_call_vijj {
|
||||
dyn_call_vijj.call(index, a1, a2, a3, a4, a5).unwrap()
|
||||
@@ -701,20 +701,20 @@ pub fn invoke_vijj(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32
|
||||
panic!("dyn_call_vijj is set to None");
|
||||
}
|
||||
}
|
||||
pub fn invoke_vidd(ctx: &mut Ctx, index: i32, a1: i32, a2: f64, a3: f64) {
|
||||
pub fn invoke_vidd(ctx: &mut EmEnv, index: i32, a1: i32, a2: f64, a3: f64) {
|
||||
debug!("emscripten::invoke_viid");
|
||||
invoke_no_return!(ctx, dyn_call_vidd, index, a1, a2, a3);
|
||||
}
|
||||
pub fn invoke_viid(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: f64) {
|
||||
pub fn invoke_viid(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: f64) {
|
||||
debug!("emscripten::invoke_viid");
|
||||
invoke_no_return!(ctx, dyn_call_viid, index, a1, a2, a3);
|
||||
}
|
||||
pub fn invoke_viidii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: f64, a4: i32, a5: i32) {
|
||||
pub fn invoke_viidii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: f64, a4: i32, a5: i32) {
|
||||
debug!("emscripten::invoke_viidii");
|
||||
invoke_no_return!(ctx, dyn_call_viidii, index, a1, a2, a3, a4, a5);
|
||||
}
|
||||
pub fn invoke_viidddddddd(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
index: i32,
|
||||
a1: i32,
|
||||
a2: i32,
|
||||
|
||||
28
lib/emscripten/src/env/mod.rs
vendored
28
lib/emscripten/src/env/mod.rs
vendored
@@ -19,9 +19,11 @@ use crate::{
|
||||
};
|
||||
|
||||
use std::os::raw::c_int;
|
||||
use wasmer_runtime_core::{types::ValueType, vm::Ctx};
|
||||
|
||||
pub fn call_malloc(ctx: &mut Ctx, size: u32) -> u32 {
|
||||
use crate::EmEnv;
|
||||
use wasmer::ValueType;
|
||||
|
||||
pub fn call_malloc(ctx: &mut EmEnv, size: u32) -> u32 {
|
||||
get_emscripten_data(ctx)
|
||||
.malloc
|
||||
.as_ref()
|
||||
@@ -31,11 +33,11 @@ pub fn call_malloc(ctx: &mut Ctx, size: u32) -> u32 {
|
||||
}
|
||||
|
||||
#[warn(dead_code)]
|
||||
pub fn call_malloc_with_cast<T: Copy, Ty>(ctx: &mut Ctx, size: u32) -> WasmPtr<T, Ty> {
|
||||
pub fn call_malloc_with_cast<T: Copy, Ty>(ctx: &mut EmEnv, size: u32) -> WasmPtr<T, Ty> {
|
||||
WasmPtr::new(call_malloc(ctx, size))
|
||||
}
|
||||
|
||||
pub fn call_memalign(ctx: &mut Ctx, alignment: u32, size: u32) -> u32 {
|
||||
pub fn call_memalign(ctx: &mut EmEnv, alignment: u32, size: u32) -> u32 {
|
||||
if let Some(memalign) = &get_emscripten_data(ctx).memalign {
|
||||
memalign.call(alignment, size).unwrap()
|
||||
} else {
|
||||
@@ -43,7 +45,7 @@ pub fn call_memalign(ctx: &mut Ctx, alignment: u32, size: u32) -> u32 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn call_memset(ctx: &mut Ctx, pointer: u32, value: u32, size: u32) -> u32 {
|
||||
pub fn call_memset(ctx: &mut EmEnv, pointer: u32, value: u32, size: u32) -> u32 {
|
||||
get_emscripten_data(ctx)
|
||||
.memset
|
||||
.as_ref()
|
||||
@@ -52,16 +54,16 @@ pub fn call_memset(ctx: &mut Ctx, pointer: u32, value: u32, size: u32) -> u32 {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub(crate) fn get_emscripten_data(ctx: &mut Ctx) -> &mut EmscriptenData {
|
||||
unsafe { &mut *(ctx.data as *mut EmscriptenData) }
|
||||
pub(crate) fn get_emscripten_data<'a, 'b>(ctx: &'a mut EmEnv<'b>) -> &'a mut EmscriptenData<'b> {
|
||||
ctx.data
|
||||
}
|
||||
|
||||
pub fn _getpagesize(_ctx: &mut Ctx) -> u32 {
|
||||
pub fn _getpagesize(_ctx: &mut EmEnv) -> u32 {
|
||||
debug!("emscripten::_getpagesize");
|
||||
16384
|
||||
}
|
||||
|
||||
pub fn _times(ctx: &mut Ctx, buffer: u32) -> u32 {
|
||||
pub fn _times(ctx: &mut EmEnv, buffer: u32) -> u32 {
|
||||
if buffer != 0 {
|
||||
call_memset(ctx, buffer, 0, 16);
|
||||
}
|
||||
@@ -69,7 +71,7 @@ pub fn _times(ctx: &mut Ctx, buffer: u32) -> u32 {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___build_environment(ctx: &mut Ctx, environ: c_int) {
|
||||
pub fn ___build_environment(ctx: &mut EmEnv, environ: c_int) {
|
||||
debug!("emscripten::___build_environment {}", environ);
|
||||
const MAX_ENV_VALUES: u32 = 64;
|
||||
const TOTAL_ENV_SIZE: u32 = 1024;
|
||||
@@ -121,13 +123,13 @@ pub fn ___build_environment(ctx: &mut Ctx, environ: c_int) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ___assert_fail(_ctx: &mut Ctx, _a: c_int, _b: c_int, _c: c_int, _d: c_int) {
|
||||
pub fn ___assert_fail(_ctx: &mut EmEnv, _a: c_int, _b: c_int, _c: c_int, _d: c_int) {
|
||||
debug!("emscripten::___assert_fail {} {} {} {}", _a, _b, _c, _d);
|
||||
// TODO: Implement like emscripten expects regarding memory/page size
|
||||
// TODO raise an error
|
||||
}
|
||||
|
||||
pub fn _pathconf(ctx: &mut Ctx, path_addr: c_int, name: c_int) -> c_int {
|
||||
pub fn _pathconf(ctx: &mut EmEnv, path_addr: c_int, name: c_int) -> c_int {
|
||||
debug!(
|
||||
"emscripten::_pathconf {} {} - UNIMPLEMENTED",
|
||||
path_addr, name
|
||||
@@ -148,7 +150,7 @@ pub fn _pathconf(ctx: &mut Ctx, path_addr: c_int, name: c_int) -> c_int {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _fpathconf(_ctx: &mut Ctx, _fildes: c_int, name: c_int) -> c_int {
|
||||
pub fn _fpathconf(_ctx: &mut EmEnv, _fildes: c_int, name: c_int) -> c_int {
|
||||
debug!("emscripten::_fpathconf {} {}", _fildes, name);
|
||||
match name {
|
||||
0 => 32000,
|
||||
|
||||
20
lib/emscripten/src/env/unix/mod.rs
vendored
20
lib/emscripten/src/env/unix/mod.rs
vendored
@@ -11,11 +11,11 @@ use std::os::raw::c_char;
|
||||
use crate::env::{call_malloc, call_malloc_with_cast, EmAddrInfo, EmSockAddr};
|
||||
use crate::ptr::{Array, WasmPtr};
|
||||
use crate::utils::{copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
// #[no_mangle]
|
||||
/// emscripten: _getenv // (name: *const char) -> *const c_char;
|
||||
pub fn _getenv(ctx: &mut Ctx, name: i32) -> u32 {
|
||||
pub fn _getenv(ctx: &mut EmEnv, name: i32) -> u32 {
|
||||
debug!("emscripten::_getenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@@ -31,7 +31,7 @@ pub fn _getenv(ctx: &mut Ctx, name: i32) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
|
||||
pub fn _setenv(ctx: &mut Ctx, name: c_int, value: c_int, overwrite: c_int) -> c_int {
|
||||
pub fn _setenv(ctx: &mut EmEnv, name: c_int, value: c_int, overwrite: c_int) -> c_int {
|
||||
debug!("emscripten::_setenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@@ -44,7 +44,7 @@ pub fn _setenv(ctx: &mut Ctx, name: c_int, value: c_int, overwrite: c_int) -> c_
|
||||
}
|
||||
|
||||
/// emscripten: _putenv // (name: *const char);
|
||||
pub fn _putenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
||||
pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int {
|
||||
debug!("emscripten::_putenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@@ -55,7 +55,7 @@ pub fn _putenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
||||
}
|
||||
|
||||
/// emscripten: _unsetenv // (name: *const char);
|
||||
pub fn _unsetenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
||||
pub fn _unsetenv(ctx: &mut EmEnv, name: c_int) -> c_int {
|
||||
debug!("emscripten::_unsetenv");
|
||||
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
@@ -66,7 +66,7 @@ pub fn _unsetenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
|
||||
debug!("emscripten::_getpwnam {}", name_ptr);
|
||||
#[cfg(feature = "debug")]
|
||||
let _ = name_ptr;
|
||||
@@ -106,7 +106,7 @@ pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
|
||||
debug!("emscripten::_getgrnam {}", name_ptr);
|
||||
|
||||
#[repr(C)]
|
||||
@@ -137,14 +137,14 @@ pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _sysconf(_ctx: &mut Ctx, name: c_int) -> i32 {
|
||||
pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> i32 {
|
||||
debug!("emscripten::_sysconf {}", name);
|
||||
// TODO: Implement like emscripten expects regarding memory/page size
|
||||
unsafe { sysconf(name) as i32 } // TODO review i64
|
||||
}
|
||||
|
||||
// this may be a memory leak, probably not though because emscripten does the same thing
|
||||
pub fn _gai_strerror(ctx: &mut Ctx, ecode: i32) -> i32 {
|
||||
pub fn _gai_strerror(ctx: &mut EmEnv, ecode: i32) -> i32 {
|
||||
debug!("emscripten::_gai_strerror({})", ecode);
|
||||
|
||||
let cstr = unsafe { std::ffi::CStr::from_ptr(libc::gai_strerror(ecode)) };
|
||||
@@ -164,7 +164,7 @@ pub fn _gai_strerror(ctx: &mut Ctx, ecode: i32) -> i32 {
|
||||
}
|
||||
|
||||
pub fn _getaddrinfo(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
node_ptr: WasmPtr<c_char>,
|
||||
service_str_ptr: WasmPtr<c_char>,
|
||||
hints_ptr: WasmPtr<EmAddrInfo>,
|
||||
|
||||
20
lib/emscripten/src/env/windows/mod.rs
vendored
20
lib/emscripten/src/env/windows/mod.rs
vendored
@@ -8,7 +8,7 @@ use std::os::raw::c_char;
|
||||
use crate::env::{call_malloc, EmAddrInfo};
|
||||
use crate::ptr::WasmPtr;
|
||||
use crate::utils::{copy_cstr_into_wasm, read_string_from_wasm};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
extern "C" {
|
||||
#[link_name = "_putenv"]
|
||||
@@ -17,7 +17,7 @@ extern "C" {
|
||||
|
||||
// #[no_mangle]
|
||||
/// emscripten: _getenv // (name: *const char) -> *const c_char;
|
||||
pub fn _getenv(ctx: &mut Ctx, name: u32) -> u32 {
|
||||
pub fn _getenv(ctx: &mut EmEnv, name: u32) -> u32 {
|
||||
debug!("emscripten::_getenv");
|
||||
let name_string = read_string_from_wasm(ctx.memory(0), name);
|
||||
debug!("=> name({:?})", name_string);
|
||||
@@ -29,7 +29,7 @@ pub fn _getenv(ctx: &mut Ctx, name: u32) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
|
||||
pub fn _setenv(ctx: &mut Ctx, name: u32, value: u32, _overwrite: u32) -> c_int {
|
||||
pub fn _setenv(ctx: &mut EmEnv, name: u32, value: u32, _overwrite: u32) -> c_int {
|
||||
debug!("emscripten::_setenv");
|
||||
// setenv does not exist on windows, so we hack it with _putenv
|
||||
let name = read_string_from_wasm(ctx.memory(0), name);
|
||||
@@ -43,7 +43,7 @@ pub fn _setenv(ctx: &mut Ctx, name: u32, value: u32, _overwrite: u32) -> c_int {
|
||||
}
|
||||
|
||||
/// emscripten: _putenv // (name: *const char);
|
||||
pub fn _putenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
||||
pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int {
|
||||
debug!("emscripten::_putenv");
|
||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||
debug!("=> name({:?})", unsafe {
|
||||
@@ -53,7 +53,7 @@ pub fn _putenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
||||
}
|
||||
|
||||
/// emscripten: _unsetenv // (name: *const char);
|
||||
pub fn _unsetenv(ctx: &mut Ctx, name: u32) -> c_int {
|
||||
pub fn _unsetenv(ctx: &mut EmEnv, name: u32) -> c_int {
|
||||
debug!("emscripten::_unsetenv");
|
||||
let name = read_string_from_wasm(ctx.memory(0), name);
|
||||
// no unsetenv on windows, so use putenv with an empty value
|
||||
@@ -65,7 +65,7 @@ pub fn _unsetenv(ctx: &mut Ctx, name: u32) -> c_int {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
|
||||
debug!("emscripten::_getpwnam {}", name_ptr);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = name_ptr;
|
||||
@@ -99,7 +99,7 @@ pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
|
||||
debug!("emscripten::_getgrnam {}", name_ptr);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = name_ptr;
|
||||
@@ -125,7 +125,7 @@ pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _sysconf(_ctx: &mut Ctx, name: c_int) -> c_long {
|
||||
pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> c_long {
|
||||
debug!("emscripten::_sysconf {}", name);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = name;
|
||||
@@ -133,13 +133,13 @@ pub fn _sysconf(_ctx: &mut Ctx, name: c_int) -> c_long {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _gai_strerror(_ctx: &mut Ctx, _ecode: i32) -> i32 {
|
||||
pub fn _gai_strerror(_ctx: &mut EmEnv, _ecode: i32) -> i32 {
|
||||
debug!("emscripten::_gai_strerror({}) - stub", _ecode);
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _getaddrinfo(
|
||||
_ctx: &mut Ctx,
|
||||
_ctx: &mut EmEnv,
|
||||
_node_ptr: WasmPtr<c_char>,
|
||||
_service_str_ptr: WasmPtr<c_char>,
|
||||
_hints_ptr: WasmPtr<EmAddrInfo>,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// use std::collections::HashMap;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
pub fn ___seterrno(_ctx: &mut Ctx, _value: i32) {
|
||||
pub fn ___seterrno(_ctx: &mut EmEnv, _value: i32) {
|
||||
debug!("emscripten::___seterrno {}", _value);
|
||||
// TODO: Incomplete impl
|
||||
eprintln!("failed to set errno!");
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
use super::env;
|
||||
use super::process::_abort;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
/// emscripten: ___cxa_allocate_exception
|
||||
pub fn ___cxa_allocate_exception(ctx: &mut Ctx, size: u32) -> u32 {
|
||||
pub fn ___cxa_allocate_exception(ctx: &mut EmEnv, size: u32) -> u32 {
|
||||
debug!("emscripten::___cxa_allocate_exception");
|
||||
env::call_malloc(ctx, size as _)
|
||||
}
|
||||
|
||||
pub fn ___cxa_current_primary_exception(_ctx: &mut Ctx) -> u32 {
|
||||
pub fn ___cxa_current_primary_exception(_ctx: &mut EmEnv) -> u32 {
|
||||
debug!("emscripten::___cxa_current_primary_exception");
|
||||
unimplemented!("emscripten::___cxa_current_primary_exception")
|
||||
}
|
||||
|
||||
pub fn ___cxa_decrement_exception_refcount(_ctx: &mut Ctx, _a: u32) {
|
||||
pub fn ___cxa_decrement_exception_refcount(_ctx: &mut EmEnv, _a: u32) {
|
||||
debug!("emscripten::___cxa_decrement_exception_refcount({})", _a);
|
||||
unimplemented!("emscripten::___cxa_decrement_exception_refcount({})", _a)
|
||||
}
|
||||
|
||||
pub fn ___cxa_increment_exception_refcount(_ctx: &mut Ctx, _a: u32) {
|
||||
pub fn ___cxa_increment_exception_refcount(_ctx: &mut EmEnv, _a: u32) {
|
||||
debug!("emscripten::___cxa_increment_exception_refcount({})", _a);
|
||||
unimplemented!("emscripten::___cxa_increment_exception_refcount({})", _a)
|
||||
}
|
||||
|
||||
pub fn ___cxa_rethrow_primary_exception(_ctx: &mut Ctx, _a: u32) {
|
||||
pub fn ___cxa_rethrow_primary_exception(_ctx: &mut EmEnv, _a: u32) {
|
||||
debug!("emscripten::___cxa_rethrow_primary_exception({})", _a);
|
||||
unimplemented!("emscripten::___cxa_rethrow_primary_exception({})", _a)
|
||||
}
|
||||
|
||||
/// emscripten: ___cxa_throw
|
||||
/// TODO: We don't have support for exceptions yet
|
||||
pub fn ___cxa_throw(ctx: &mut Ctx, _ptr: u32, _ty: u32, _destructor: u32) {
|
||||
pub fn ___cxa_throw(ctx: &mut EmEnv, _ptr: u32, _ty: u32, _destructor: u32) {
|
||||
debug!("emscripten::___cxa_throw");
|
||||
eprintln!("Throwing exceptions not yet implemented: aborting!");
|
||||
_abort(ctx);
|
||||
}
|
||||
|
||||
pub fn ___cxa_begin_catch(_ctx: &mut Ctx, _exception_object_ptr: u32) -> i32 {
|
||||
pub fn ___cxa_begin_catch(_ctx: &mut EmEnv, _exception_object_ptr: u32) -> i32 {
|
||||
debug!("emscripten::___cxa_begin_catch");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___cxa_end_catch(_ctx: &mut Ctx) {
|
||||
pub fn ___cxa_end_catch(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::___cxa_end_catch");
|
||||
}
|
||||
|
||||
pub fn ___cxa_uncaught_exception(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn ___cxa_uncaught_exception(_ctx: &mut EmEnv) -> i32 {
|
||||
debug!("emscripten::___cxa_uncaught_exception");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___cxa_pure_virtual(_ctx: &mut Ctx) {
|
||||
pub fn ___cxa_pure_virtual(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::___cxa_pure_virtual");
|
||||
// ABORT = true
|
||||
panic!("Pure virtual function called!");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::varargs::VarArgs;
|
||||
use crate::EmEnv;
|
||||
use libc::execvp as libc_execvp;
|
||||
use std::cell::Cell;
|
||||
use std::ffi::CString;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub fn execvp(ctx: &mut Ctx, command_name_offset: u32, argv_offset: u32) -> i32 {
|
||||
pub fn execvp(ctx: &mut EmEnv, command_name_offset: u32, argv_offset: u32) -> i32 {
|
||||
// a single reference to re-use
|
||||
let emscripten_memory = ctx.memory(0);
|
||||
|
||||
@@ -41,13 +41,13 @@ pub fn execvp(ctx: &mut Ctx, command_name_offset: u32, argv_offset: u32) -> i32
|
||||
}
|
||||
|
||||
/// execl
|
||||
pub fn execl(_ctx: &mut Ctx, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 {
|
||||
pub fn execl(_ctx: &mut EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::execl");
|
||||
-1
|
||||
}
|
||||
|
||||
/// execle
|
||||
pub fn execle(_ctx: &mut Ctx, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 {
|
||||
pub fn execle(_ctx: &mut EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::execle");
|
||||
-1
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
// __exit
|
||||
pub fn exit(_ctx: &mut Ctx, value: i32) {
|
||||
pub fn exit(_ctx: &mut EmEnv, value: i32) {
|
||||
debug!("emscripten::exit {}", value);
|
||||
::std::process::exit(value);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
pub fn addr(_ctx: &mut Ctx, _cp: i32) -> i32 {
|
||||
pub fn addr(_ctx: &mut EmEnv, _cp: i32) -> i32 {
|
||||
debug!("inet::addr({})", _cp);
|
||||
0
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@ pub use self::unix::*;
|
||||
#[cfg(windows)]
|
||||
pub use self::windows::*;
|
||||
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
/// getprotobyname
|
||||
pub fn getprotobyname(_ctx: &mut Ctx, _name_ptr: i32) -> i32 {
|
||||
pub fn getprotobyname(_ctx: &mut EmEnv, _name_ptr: i32) -> i32 {
|
||||
debug!("emscripten::getprotobyname");
|
||||
unimplemented!("emscripten::getprotobyname")
|
||||
}
|
||||
|
||||
/// getprotobynumber
|
||||
pub fn getprotobynumber(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn getprotobynumber(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::getprotobynumber");
|
||||
unimplemented!("emscripten::getprotobynumber")
|
||||
}
|
||||
|
||||
/// sigdelset
|
||||
pub fn sigdelset(ctx: &mut Ctx, set: i32, signum: i32) -> i32 {
|
||||
pub fn sigdelset(ctx: &mut EmEnv, set: i32, signum: i32) -> i32 {
|
||||
debug!("emscripten::sigdelset");
|
||||
let memory = ctx.memory(0);
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
@@ -37,7 +37,7 @@ pub fn sigdelset(ctx: &mut Ctx, set: i32, signum: i32) -> i32 {
|
||||
}
|
||||
|
||||
/// sigfillset
|
||||
pub fn sigfillset(ctx: &mut Ctx, set: i32) -> i32 {
|
||||
pub fn sigfillset(ctx: &mut EmEnv, set: i32) -> i32 {
|
||||
debug!("emscripten::sigfillset");
|
||||
let memory = ctx.memory(0);
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
@@ -51,13 +51,13 @@ pub fn sigfillset(ctx: &mut Ctx, set: i32) -> i32 {
|
||||
}
|
||||
|
||||
/// tzset
|
||||
pub fn tzset(_ctx: &mut Ctx) {
|
||||
pub fn tzset(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::tzset - stub");
|
||||
//unimplemented!("emscripten::tzset - stub")
|
||||
}
|
||||
|
||||
/// strptime
|
||||
pub fn strptime(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
pub fn strptime(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
debug!("emscripten::strptime");
|
||||
unimplemented!("emscripten::strptime")
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ use super::super::utils::copy_cstr_into_wasm;
|
||||
use libc::{chroot as _chroot, getpwuid as _getpwuid, printf as _printf};
|
||||
use std::mem;
|
||||
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
/// putchar
|
||||
pub fn putchar(_ctx: &mut Ctx, chr: i32) {
|
||||
pub fn putchar(_ctx: &mut EmEnv, chr: i32) {
|
||||
unsafe { libc::putchar(chr) };
|
||||
}
|
||||
|
||||
/// printf
|
||||
pub fn printf(ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
||||
pub fn printf(ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 {
|
||||
debug!("emscripten::printf {}, {}", memory_offset, extra);
|
||||
unsafe {
|
||||
let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _;
|
||||
@@ -20,7 +20,7 @@ pub fn printf(ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
||||
}
|
||||
|
||||
/// chroot
|
||||
pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 {
|
||||
pub fn chroot(ctx: &mut EmEnv, name_ptr: i32) -> i32 {
|
||||
debug!("emscripten::chroot");
|
||||
let name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8;
|
||||
unsafe { _chroot(name as *const _) }
|
||||
@@ -28,7 +28,7 @@ pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 {
|
||||
|
||||
/// getpwuid
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn getpwuid(ctx: &mut Ctx, uid: i32) -> i32 {
|
||||
pub fn getpwuid(ctx: &mut EmEnv, uid: i32) -> i32 {
|
||||
debug!("emscripten::getpwuid {}", uid);
|
||||
|
||||
#[repr(C)]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
// This may be problematic for msvc which uses inline functions for the printf family
|
||||
// this cfg_attr will try to link with the legacy lib that does not inline printf
|
||||
@@ -14,12 +14,12 @@ use wasmer_runtime_core::vm::Ctx;
|
||||
//}
|
||||
|
||||
/// putchar
|
||||
pub fn putchar(_ctx: &mut Ctx, chr: i32) {
|
||||
pub fn putchar(_ctx: &mut EmEnv, chr: i32) {
|
||||
unsafe { libc::putchar(chr) };
|
||||
}
|
||||
|
||||
/// printf
|
||||
pub fn printf(_ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
||||
pub fn printf(_ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 {
|
||||
debug!("emscripten::printf {}, {}", memory_offset, extra);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
{
|
||||
@@ -34,13 +34,13 @@ pub fn printf(_ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
||||
}
|
||||
|
||||
/// chroot
|
||||
pub fn chroot(_ctx: &mut Ctx, _name_ptr: i32) -> i32 {
|
||||
pub fn chroot(_ctx: &mut EmEnv, _name_ptr: i32) -> i32 {
|
||||
debug!("emscripten::chroot");
|
||||
unimplemented!("emscripten::chroot")
|
||||
}
|
||||
|
||||
/// getpwuid
|
||||
pub fn getpwuid(_ctx: &mut Ctx, _uid: i32) -> i32 {
|
||||
pub fn getpwuid(_ctx: &mut EmEnv, _uid: i32) -> i32 {
|
||||
debug!("emscripten::getpwuid");
|
||||
unimplemented!("emscripten::getpwuid")
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ use super::env::get_emscripten_data;
|
||||
use super::process::abort_with_message;
|
||||
use libc::c_int;
|
||||
// use std::cell::UnsafeCell;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
/// setjmp
|
||||
pub fn __setjmp(ctx: &mut Ctx, _env_addr: u32) -> c_int {
|
||||
pub fn __setjmp(ctx: &mut EmEnv, _env_addr: u32) -> c_int {
|
||||
debug!("emscripten::__setjmp (setjmp)");
|
||||
abort_with_message(ctx, "missing function: _setjmp");
|
||||
unreachable!()
|
||||
@@ -28,7 +28,7 @@ pub fn __setjmp(ctx: &mut Ctx, _env_addr: u32) -> c_int {
|
||||
|
||||
/// longjmp
|
||||
#[allow(unreachable_code)]
|
||||
pub fn __longjmp(ctx: &mut Ctx, _env_addr: u32, _val: c_int) {
|
||||
pub fn __longjmp(ctx: &mut EmEnv, _env_addr: u32, _val: c_int) {
|
||||
debug!("emscripten::__longjmp (longmp)");
|
||||
abort_with_message(ctx, "missing function: _longjmp");
|
||||
// unsafe {
|
||||
@@ -43,7 +43,7 @@ pub fn __longjmp(ctx: &mut Ctx, _env_addr: u32, _val: c_int) {
|
||||
|
||||
/// _longjmp
|
||||
// This function differs from the js implementation, it should return Result<(), &'static str>
|
||||
pub fn _longjmp(ctx: &mut Ctx, env_addr: i32, val: c_int) -> Result<(), ()> {
|
||||
pub fn _longjmp(ctx: &mut EmEnv, env_addr: i32, val: c_int) -> Result<(), ()> {
|
||||
let val = if val == 0 { 1 } else { val };
|
||||
get_emscripten_data(ctx)
|
||||
.set_threw
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
extern crate libc;
|
||||
use crate::EmEnv;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::convert::TryInto;
|
||||
@@ -48,7 +49,7 @@ pub fn killpg(_a: i32, _b: i32) -> i32 {
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn pathconf(ctx: &mut Ctx, path_ptr: i32, name: i32) -> i32 {
|
||||
pub fn pathconf(ctx: &mut EmEnv, path_ptr: i32, name: i32) -> i32 {
|
||||
debug!("emscripten::pathconf");
|
||||
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
|
||||
unsafe { libc::pathconf(path as *const _, name).try_into().unwrap() }
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
// TODO: Need to implement.
|
||||
|
||||
/// emscripten: dlopen(filename: *const c_char, flag: c_int) -> *mut c_void
|
||||
pub fn _dlopen(_ctx: &mut Ctx, _filename: u32, _flag: u32) -> i32 {
|
||||
pub fn _dlopen(_ctx: &mut EmEnv, _filename: u32, _flag: u32) -> i32 {
|
||||
debug!("emscripten::_dlopen");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlclose(handle: *mut c_void) -> c_int
|
||||
pub fn _dlclose(_ctx: &mut Ctx, _filename: u32) -> i32 {
|
||||
pub fn _dlclose(_ctx: &mut EmEnv, _filename: u32) -> i32 {
|
||||
debug!("emscripten::_dlclose");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void
|
||||
pub fn _dlsym(_ctx: &mut Ctx, _filepath: u32, _symbol: u32) -> i32 {
|
||||
pub fn _dlsym(_ctx: &mut EmEnv, _filepath: u32, _symbol: u32) -> i32 {
|
||||
debug!("emscripten::_dlsym");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlerror() -> *mut c_char
|
||||
pub fn _dlerror(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn _dlerror(_ctx: &mut EmEnv) -> i32 {
|
||||
debug!("emscripten::_dlerror");
|
||||
-1
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
use crate::EmEnv;
|
||||
use libc::c_int;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub fn ___lock(_ctx: &mut Ctx, _what: c_int) {
|
||||
pub fn ___lock(_ctx: &mut EmEnv, _what: c_int) {
|
||||
debug!("emscripten::___lock {}", _what);
|
||||
}
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub fn ___unlock(_ctx: &mut Ctx, _what: c_int) {
|
||||
pub fn ___unlock(_ctx: &mut EmEnv, _what: c_int) {
|
||||
debug!("emscripten::___unlock {}", _what);
|
||||
}
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub fn ___wait(_ctx: &mut Ctx, _which: u32, _varargs: u32, _three: u32, _four: u32) {
|
||||
pub fn ___wait(_ctx: &mut EmEnv, _which: u32, _varargs: u32, _three: u32, _four: u32) {
|
||||
debug!("emscripten::___wait");
|
||||
}
|
||||
|
||||
pub fn _flock(_ctx: &mut Ctx, _fd: u32, _op: u32) -> u32 {
|
||||
pub fn _flock(_ctx: &mut EmEnv, _fd: u32, _op: u32) -> u32 {
|
||||
debug!("emscripten::_flock");
|
||||
0
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
pub fn _llvm_copysign_f32(x: f64, y: f64) -> f64 {
|
||||
x.copysign(y)
|
||||
@@ -62,7 +62,7 @@ pub fn _llvm_fma_f64(value: f64, a: f64, b: f64) -> f64 {
|
||||
value.mul_add(a, b)
|
||||
}
|
||||
|
||||
pub fn _emscripten_random(_ctx: &mut Ctx) -> f64 {
|
||||
pub fn _emscripten_random(_ctx: &mut EmEnv) -> f64 {
|
||||
debug!("emscripten::_emscripten_random");
|
||||
-1.0
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
use super::env::get_emscripten_data;
|
||||
use super::process::abort_with_message;
|
||||
use crate::EmEnv;
|
||||
use libc::{c_int, c_void, memcpy, size_t};
|
||||
use wasmer_runtime_core::{
|
||||
units::{Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE},
|
||||
vm::Ctx,
|
||||
};
|
||||
// TODO: investigate max pages etc. probably in Wasm Common, maybe reexport
|
||||
use wasmer::{Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE};
|
||||
|
||||
/// emscripten: _emscripten_memcpy_big
|
||||
pub fn _emscripten_memcpy_big(ctx: &mut Ctx, dest: u32, src: u32, len: u32) -> u32 {
|
||||
pub fn _emscripten_memcpy_big(ctx: &mut EmEnv, dest: u32, src: u32, len: u32) -> u32 {
|
||||
debug!(
|
||||
"emscripten::_emscripten_memcpy_big {}, {}, {}",
|
||||
dest, src, len
|
||||
@@ -21,7 +20,7 @@ pub fn _emscripten_memcpy_big(ctx: &mut Ctx, dest: u32, src: u32, len: u32) -> u
|
||||
}
|
||||
|
||||
/// emscripten: _emscripten_get_heap_size
|
||||
pub fn _emscripten_get_heap_size(ctx: &mut Ctx) -> u32 {
|
||||
pub fn _emscripten_get_heap_size(ctx: &mut EmEnv) -> u32 {
|
||||
trace!("emscripten::_emscripten_get_heap_size");
|
||||
let result = ctx.memory(0).size().bytes().0 as u32;
|
||||
trace!("=> {}", result);
|
||||
@@ -39,7 +38,7 @@ fn align_up(mut val: usize, multiple: usize) -> usize {
|
||||
|
||||
/// emscripten: _emscripten_resize_heap
|
||||
/// Note: this function only allows growing the size of heap
|
||||
pub fn _emscripten_resize_heap(ctx: &mut Ctx, requested_size: u32) -> u32 {
|
||||
pub fn _emscripten_resize_heap(ctx: &mut EmEnv, requested_size: u32) -> u32 {
|
||||
debug!("emscripten::_emscripten_resize_heap {}", requested_size);
|
||||
let current_memory_pages = ctx.memory(0).size();
|
||||
let current_memory = current_memory_pages.bytes().0 as u32;
|
||||
@@ -67,7 +66,7 @@ pub fn _emscripten_resize_heap(ctx: &mut Ctx, requested_size: u32) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: sbrk
|
||||
pub fn sbrk(ctx: &mut Ctx, increment: i32) -> i32 {
|
||||
pub fn sbrk(ctx: &mut EmEnv, increment: i32) -> i32 {
|
||||
debug!("emscripten::sbrk");
|
||||
// let old_dynamic_top = 0;
|
||||
// let new_dynamic_top = 0;
|
||||
@@ -95,7 +94,7 @@ pub fn sbrk(ctx: &mut Ctx, increment: i32) -> i32 {
|
||||
}
|
||||
|
||||
/// emscripten: getTotalMemory
|
||||
pub fn get_total_memory(_ctx: &mut Ctx) -> u32 {
|
||||
pub fn get_total_memory(_ctx: &mut EmEnv) -> u32 {
|
||||
debug!("emscripten::get_total_memory");
|
||||
// instance.memories[0].current_pages()
|
||||
// TODO: Fix implementation
|
||||
@@ -103,7 +102,7 @@ pub fn get_total_memory(_ctx: &mut Ctx) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: enlargeMemory
|
||||
pub fn enlarge_memory(_ctx: &mut Ctx) -> u32 {
|
||||
pub fn enlarge_memory(_ctx: &mut EmEnv) -> u32 {
|
||||
debug!("emscripten::enlarge_memory");
|
||||
// instance.memories[0].grow(100);
|
||||
// TODO: Fix implementation
|
||||
@@ -111,7 +110,7 @@ pub fn enlarge_memory(_ctx: &mut Ctx) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: abortOnCannotGrowMemory
|
||||
pub fn abort_on_cannot_grow_memory(ctx: &mut Ctx, _requested_size: u32) -> u32 {
|
||||
pub fn abort_on_cannot_grow_memory(ctx: &mut EmEnv, _requested_size: u32) -> u32 {
|
||||
debug!(
|
||||
"emscripten::abort_on_cannot_grow_memory {}",
|
||||
_requested_size
|
||||
@@ -121,32 +120,32 @@ pub fn abort_on_cannot_grow_memory(ctx: &mut Ctx, _requested_size: u32) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: abortOnCannotGrowMemory
|
||||
pub fn abort_on_cannot_grow_memory_old(ctx: &mut Ctx) -> u32 {
|
||||
pub fn abort_on_cannot_grow_memory_old(ctx: &mut EmEnv) -> u32 {
|
||||
debug!("emscripten::abort_on_cannot_grow_memory");
|
||||
abort_with_message(ctx, "Cannot enlarge memory arrays!");
|
||||
0
|
||||
}
|
||||
|
||||
/// emscripten: segfault
|
||||
pub fn segfault(ctx: &mut Ctx) {
|
||||
pub fn segfault(ctx: &mut EmEnv) {
|
||||
debug!("emscripten::segfault");
|
||||
abort_with_message(ctx, "segmentation fault");
|
||||
}
|
||||
|
||||
/// emscripten: alignfault
|
||||
pub fn alignfault(ctx: &mut Ctx) {
|
||||
pub fn alignfault(ctx: &mut EmEnv) {
|
||||
debug!("emscripten::alignfault");
|
||||
abort_with_message(ctx, "alignment fault");
|
||||
}
|
||||
|
||||
/// emscripten: ftfault
|
||||
pub fn ftfault(ctx: &mut Ctx) {
|
||||
pub fn ftfault(ctx: &mut EmEnv) {
|
||||
debug!("emscripten::ftfault");
|
||||
abort_with_message(ctx, "Function table mask error");
|
||||
}
|
||||
|
||||
/// emscripten: ___map_file
|
||||
pub fn ___map_file(_ctx: &mut Ctx, _one: u32, _two: u32) -> c_int {
|
||||
pub fn ___map_file(_ctx: &mut EmEnv, _one: u32, _two: u32) -> c_int {
|
||||
debug!("emscripten::___map_file");
|
||||
// NOTE: TODO: Em returns -1 here as well. May need to implement properly
|
||||
-1
|
||||
|
||||
@@ -5,35 +5,35 @@ type PidT = libc::pid_t;
|
||||
#[cfg(target_os = "windows")]
|
||||
type PidT = c_int;
|
||||
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
pub fn abort_with_message(ctx: &mut Ctx, message: &str) {
|
||||
pub fn abort_with_message(ctx: &mut EmEnv, message: &str) {
|
||||
debug!("emscripten::abort_with_message");
|
||||
println!("{}", message);
|
||||
_abort(ctx);
|
||||
}
|
||||
|
||||
/// The name of this call is `abort` but we want to avoid conflicts with libc::abort
|
||||
pub fn em_abort(ctx: &mut Ctx, arg: u32) {
|
||||
pub fn em_abort(ctx: &mut EmEnv, arg: u32) {
|
||||
debug!("emscripten::abort");
|
||||
eprintln!("Program aborted with value {}", arg);
|
||||
_abort(ctx);
|
||||
}
|
||||
|
||||
pub fn _abort(_ctx: &mut Ctx) {
|
||||
pub fn _abort(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::_abort");
|
||||
unsafe {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _prctl(ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _prctl(ctx: &mut EmEnv, _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 EmEnv) -> PidT {
|
||||
debug!("emscripten::_fork");
|
||||
// unsafe {
|
||||
// fork()
|
||||
@@ -41,132 +41,132 @@ pub fn _fork(_ctx: &mut Ctx) -> PidT {
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _endgrent(_ctx: &mut Ctx) {
|
||||
pub fn _endgrent(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::_endgrent");
|
||||
}
|
||||
|
||||
pub fn _execve(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
pub fn _execve(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
debug!("emscripten::_execve");
|
||||
-1
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn _exit(_ctx: &mut Ctx, status: c_int) {
|
||||
pub fn _exit(_ctx: &mut EmEnv, status: c_int) {
|
||||
// -> !
|
||||
debug!("emscripten::_exit {}", status);
|
||||
unsafe { exit(status) }
|
||||
}
|
||||
|
||||
pub fn _kill(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn _kill(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_kill");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _sched_yield(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn _sched_yield(_ctx: &mut EmEnv) -> i32 {
|
||||
debug!("emscripten::_sched_yield");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _llvm_stacksave(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn _llvm_stacksave(_ctx: &mut EmEnv) -> i32 {
|
||||
debug!("emscripten::_llvm_stacksave");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _llvm_stackrestore(_ctx: &mut Ctx, _one: i32) {
|
||||
pub fn _llvm_stackrestore(_ctx: &mut EmEnv, _one: i32) {
|
||||
debug!("emscripten::_llvm_stackrestore");
|
||||
}
|
||||
|
||||
pub fn _raise(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _raise(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_raise");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _sem_init(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
pub fn _sem_init(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
debug!("emscripten::_sem_init: {}, {}, {}", _one, _two, _three);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _sem_destroy(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _sem_destroy(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_sem_destroy");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _sem_post(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _sem_post(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_sem_post");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _sem_wait(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _sem_wait(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_sem_post");
|
||||
-1
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _getgrent(_ctx: &mut Ctx) -> c_int {
|
||||
pub fn _getgrent(_ctx: &mut EmEnv) -> c_int {
|
||||
debug!("emscripten::_getgrent");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _setgrent(_ctx: &mut Ctx) {
|
||||
pub fn _setgrent(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::_setgrent");
|
||||
}
|
||||
|
||||
pub fn _setgroups(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn _setgroups(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_setgroups");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _setitimer(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
pub fn _setitimer(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
debug!("emscripten::_setitimer");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _usleep(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _usleep(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_usleep");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _nanosleep(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn _nanosleep(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_nanosleep");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _utime(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn _utime(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_utime");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _utimes(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn _utimes(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_utimes");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _wait(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _wait(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_wait");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _wait3(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
pub fn _wait3(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
debug!("emscripten::_wait3");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _wait4(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
|
||||
pub fn _wait4(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
|
||||
debug!("emscripten::_wait4");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _waitid(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
|
||||
pub fn _waitid(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
|
||||
debug!("emscripten::_waitid");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _waitpid(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
pub fn _waitpid(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
debug!("emscripten::_waitpid");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn abort_stack_overflow(ctx: &mut Ctx, _what: c_int) {
|
||||
pub fn abort_stack_overflow(ctx: &mut EmEnv, _what: c_int) {
|
||||
debug!("emscripten::abort_stack_overflow");
|
||||
// TODO: Message incomplete. Need to finish em runtime data first
|
||||
abort_with_message(
|
||||
@@ -175,24 +175,24 @@ pub fn abort_stack_overflow(ctx: &mut Ctx, _what: c_int) {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn _llvm_trap(ctx: &mut Ctx) {
|
||||
pub fn _llvm_trap(ctx: &mut EmEnv) {
|
||||
debug!("emscripten::_llvm_trap");
|
||||
abort_with_message(ctx, "abort!");
|
||||
}
|
||||
|
||||
pub fn _llvm_eh_typeid_for(_ctx: &mut Ctx, _type_info_addr: u32) -> i32 {
|
||||
pub fn _llvm_eh_typeid_for(_ctx: &mut EmEnv, _type_info_addr: u32) -> i32 {
|
||||
debug!("emscripten::_llvm_eh_typeid_for");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _system(_ctx: &mut Ctx, _one: i32) -> c_int {
|
||||
pub fn _system(_ctx: &mut EmEnv, _one: i32) -> c_int {
|
||||
debug!("emscripten::_system");
|
||||
// TODO: May need to change this Em impl to a working version
|
||||
eprintln!("Can't call external programs");
|
||||
EAGAIN
|
||||
}
|
||||
|
||||
pub fn _popen(_ctx: &mut Ctx, _one: i32, _two: i32) -> c_int {
|
||||
pub fn _popen(_ctx: &mut EmEnv, _one: i32, _two: i32) -> c_int {
|
||||
debug!("emscripten::_popen");
|
||||
// TODO: May need to change this Em impl to a working version
|
||||
eprintln!("Missing function: popen");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
pub fn _pthread_attr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_attr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_attr_destroy");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_attr_getstack(
|
||||
_ctx: &mut Ctx,
|
||||
_ctx: &mut EmEnv,
|
||||
_stackaddr: i32,
|
||||
_stacksize: i32,
|
||||
_other: i32,
|
||||
@@ -23,175 +23,175 @@ pub fn _pthread_attr_getstack(
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_attr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_attr_init(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_attr_init({})", _a);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_attr_setstacksize(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_attr_setstacksize(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_attr_setstacksize");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_cleanup_pop(_ctx: &mut Ctx, _a: i32) -> () {
|
||||
pub fn _pthread_cleanup_pop(_ctx: &mut EmEnv, _a: i32) -> () {
|
||||
trace!("emscripten::_pthread_cleanup_pop");
|
||||
}
|
||||
|
||||
pub fn _pthread_cleanup_push(_ctx: &mut Ctx, _a: i32, _b: i32) -> () {
|
||||
pub fn _pthread_cleanup_push(_ctx: &mut EmEnv, _a: i32, _b: i32) -> () {
|
||||
trace!("emscripten::_pthread_cleanup_push");
|
||||
}
|
||||
|
||||
pub fn _pthread_cond_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_cond_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_cond_destroy");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_cond_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_cond_init(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_cond_init");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_cond_signal(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_cond_signal(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_cond_signal");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_cond_timedwait(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
|
||||
pub fn _pthread_cond_timedwait(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_cond_timedwait");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_cond_wait(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_cond_wait(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_cond_wait");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_condattr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_condattr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_condattr_destroy");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_condattr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_condattr_init(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_condattr_init");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_condattr_setclock(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_condattr_setclock(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_condattr_setclock");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_create(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 {
|
||||
pub fn _pthread_create(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_create");
|
||||
// 11 seems to mean "no"
|
||||
11
|
||||
}
|
||||
|
||||
pub fn _pthread_detach(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_detach(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_detach");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_equal(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_equal(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_equal");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_exit(_ctx: &mut Ctx, _a: i32) -> () {
|
||||
pub fn _pthread_exit(_ctx: &mut EmEnv, _a: i32) -> () {
|
||||
trace!("emscripten::_pthread_exit");
|
||||
}
|
||||
|
||||
pub fn _pthread_getattr_np(_ctx: &mut Ctx, _thread: i32, _attr: i32) -> i32 {
|
||||
pub fn _pthread_getattr_np(_ctx: &mut EmEnv, _thread: i32, _attr: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_getspecific(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_getspecific(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_getspecific");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_join(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_join(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_join");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_self(_ctx: &mut Ctx) -> i32 {
|
||||
pub fn _pthread_self(_ctx: &mut EmEnv) -> i32 {
|
||||
trace!("emscripten::_pthread_self");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_key_create(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_key_create(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_key_create");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_mutex_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_mutex_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_mutex_destroy");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_mutex_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_mutex_init(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_mutex_init");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_mutexattr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_mutexattr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_mutexattr_destroy");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_mutexattr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_mutexattr_init(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_mutexattr_init");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_mutexattr_settype(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_mutexattr_settype(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_mutexattr_settype");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_once(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_once(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_once");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_rwlock_destroy(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
|
||||
pub fn _pthread_rwlock_destroy(_ctx: &mut EmEnv, _rwlock: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_rwlock_destroy({})", _rwlock);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_rwlock_init(_ctx: &mut Ctx, _rwlock: i32, _attr: i32) -> i32 {
|
||||
pub fn _pthread_rwlock_init(_ctx: &mut EmEnv, _rwlock: i32, _attr: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_rwlock_rdlock(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_rwlock_rdlock(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_rwlock_rdlock");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_rwlock_unlock(_ctx: &mut Ctx, _a: i32) -> i32 {
|
||||
pub fn _pthread_rwlock_unlock(_ctx: &mut EmEnv, _a: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_rwlock_unlock");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_rwlock_wrlock(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
|
||||
pub fn _pthread_rwlock_wrlock(_ctx: &mut EmEnv, _rwlock: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_rwlock_wrlock({})", _rwlock);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_setcancelstate(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_setcancelstate(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_setcancelstate");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_setspecific(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
pub fn _pthread_setspecific(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_setspecific");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _pthread_sigmask(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
|
||||
pub fn _pthread_sigmask(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32) -> i32 {
|
||||
trace!("emscripten::_pthread_sigmask");
|
||||
0
|
||||
}
|
||||
|
||||
@@ -6,14 +6,10 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::{cell::Cell, fmt};
|
||||
pub use wasmer_runtime_core::memory::ptr::Array;
|
||||
use wasmer_runtime_core::{
|
||||
memory::{ptr, Memory},
|
||||
types::{ValueType, WasmExternType},
|
||||
};
|
||||
pub use wasmer::{Array, Memory, ValueType, WasmExternType};
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct WasmPtr<T: Copy, Ty = ptr::Item>(ptr::WasmPtr<T, Ty>);
|
||||
pub struct WasmPtr<T: Copy, Ty = wasmer::Item>(wasmer::WasmPtr<T, Ty>);
|
||||
|
||||
unsafe impl<T: Copy, Ty> ValueType for WasmPtr<T, Ty> {}
|
||||
impl<T: Copy, Ty> Copy for WasmPtr<T, Ty> {}
|
||||
@@ -31,13 +27,13 @@ impl<T: Copy, Ty> fmt::Debug for WasmPtr<T, Ty> {
|
||||
}
|
||||
|
||||
unsafe impl<T: Copy, Ty> WasmExternType for WasmPtr<T, Ty> {
|
||||
type Native = <ptr::WasmPtr<T, Ty> as WasmExternType>::Native;
|
||||
type Native = <wasmer::WasmPtr<T, Ty> as WasmExternType>::Native;
|
||||
|
||||
fn to_native(self) -> Self::Native {
|
||||
self.0.to_native()
|
||||
}
|
||||
fn from_native(n: Self::Native) -> Self {
|
||||
Self(ptr::WasmPtr::from_native(n))
|
||||
Self(wasmer::WasmPtr::from_native(n))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +48,7 @@ impl<T: Copy, Ty> Eq for WasmPtr<T, Ty> {}
|
||||
impl<T: Copy, Ty> WasmPtr<T, Ty> {
|
||||
#[inline(always)]
|
||||
pub fn new(offset: u32) -> Self {
|
||||
Self(ptr::WasmPtr::new(offset))
|
||||
Self(wasmer::WasmPtr::new(offset))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@@ -61,7 +57,7 @@ impl<T: Copy, Ty> WasmPtr<T, Ty> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy + ValueType> WasmPtr<T, ptr::Item> {
|
||||
impl<T: Copy + ValueType> WasmPtr<T, wasmer::Item> {
|
||||
#[inline(always)]
|
||||
pub fn deref<'a>(self, memory: &'a Memory) -> Option<&'a Cell<T>> {
|
||||
if self.0.offset() == 0 {
|
||||
@@ -81,7 +77,7 @@ impl<T: Copy + ValueType> WasmPtr<T, ptr::Item> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy + ValueType> WasmPtr<T, ptr::Array> {
|
||||
impl<T: Copy + ValueType> WasmPtr<T, wasmer::Array> {
|
||||
#[inline(always)]
|
||||
pub fn deref<'a>(self, memory: &'a Memory, index: u32, length: u32) -> Option<&'a [Cell<T>]> {
|
||||
if self.0.offset() == 0 {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// use super::varargs::VarArgs;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _sigemptyset(ctx: &mut Ctx, set: u32) -> i32 {
|
||||
pub fn _sigemptyset(ctx: &mut EmEnv, set: u32) -> i32 {
|
||||
debug!("emscripten::_sigemptyset");
|
||||
let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32;
|
||||
unsafe {
|
||||
@@ -11,18 +11,18 @@ pub fn _sigemptyset(ctx: &mut Ctx, set: u32) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _sigaction(_ctx: &mut Ctx, _signum: u32, _act: u32, _oldact: u32) -> i32 {
|
||||
pub fn _sigaction(_ctx: &mut EmEnv, _signum: u32, _act: u32, _oldact: u32) -> i32 {
|
||||
debug!("emscripten::_sigaction {}, {}, {}", _signum, _act, _oldact);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _siginterrupt(_ctx: &mut Ctx, _a: u32, _b: u32) -> i32 {
|
||||
pub fn _siginterrupt(_ctx: &mut EmEnv, _a: u32, _b: u32) -> i32 {
|
||||
debug!("emscripten::_siginterrupt {}, {}", _a, _b);
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _sigaddset(ctx: &mut Ctx, set: u32, signum: u32) -> i32 {
|
||||
pub fn _sigaddset(ctx: &mut EmEnv, set: u32, signum: u32) -> i32 {
|
||||
debug!("emscripten::_sigaddset {}, {}", set, signum);
|
||||
let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32;
|
||||
unsafe {
|
||||
@@ -31,17 +31,17 @@ pub fn _sigaddset(ctx: &mut Ctx, set: u32, signum: u32) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _sigsuspend(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _sigsuspend(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_sigsuspend");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _sigprocmask(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
pub fn _sigprocmask(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||
debug!("emscripten::_sigprocmask");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _signal(_ctx: &mut Ctx, _sig: u32, _two: i32) -> i32 {
|
||||
pub fn _signal(_ctx: &mut EmEnv, _sig: u32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_signal ({})", _sig);
|
||||
0
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ pub use self::windows::*;
|
||||
use crate::{
|
||||
ptr::{Array, WasmPtr},
|
||||
utils::{copy_stat_into_wasm, get_cstr_path, get_current_directory},
|
||||
EmEnv,
|
||||
};
|
||||
|
||||
use super::varargs::VarArgs;
|
||||
@@ -43,7 +44,6 @@ use libc::{
|
||||
write,
|
||||
// ENOTTY,
|
||||
};
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
use super::env;
|
||||
use std::cell::Cell;
|
||||
@@ -52,7 +52,7 @@ use std::io::Error;
|
||||
use std::slice;
|
||||
|
||||
/// exit
|
||||
pub fn ___syscall1(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) {
|
||||
pub fn ___syscall1(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) {
|
||||
debug!("emscripten::___syscall1 (exit) {}", _which);
|
||||
let status: i32 = varargs.get(ctx);
|
||||
unsafe {
|
||||
@@ -61,7 +61,7 @@ pub fn ___syscall1(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) {
|
||||
}
|
||||
|
||||
/// read
|
||||
pub fn ___syscall3(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall3(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
// -> ssize_t
|
||||
debug!("emscripten::___syscall3 (read) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@@ -75,7 +75,7 @@ pub fn ___syscall3(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
}
|
||||
|
||||
/// write
|
||||
pub fn ___syscall4(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall4(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall4 (write) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let buf: i32 = varargs.get(ctx);
|
||||
@@ -86,7 +86,7 @@ pub fn ___syscall4(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// close
|
||||
pub fn ___syscall6(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall6(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall6 (close) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
debug!("fd: {}", fd);
|
||||
@@ -94,7 +94,7 @@ pub fn ___syscall6(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
// chdir
|
||||
pub fn ___syscall12(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall12(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall12 (chdir) {}", _which);
|
||||
let path_ptr = varargs.get_str(ctx);
|
||||
let real_path_owned = get_cstr_path(ctx, path_ptr as *const _);
|
||||
@@ -112,59 +112,59 @@ pub fn ___syscall12(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
ret
|
||||
}
|
||||
|
||||
pub fn ___syscall10(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall10(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall10");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall14(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall14(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall14");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall15(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall15(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall15");
|
||||
-1
|
||||
}
|
||||
|
||||
// getpid
|
||||
pub fn ___syscall20(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall20(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall20 (getpid)");
|
||||
unsafe { getpid() }
|
||||
}
|
||||
|
||||
pub fn ___syscall21(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall21(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall21");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall25(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall25(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall25");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall29(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall29(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall29");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall32(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall32(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall32");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall33(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall33(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall33");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall36(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall36(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall36");
|
||||
-1
|
||||
}
|
||||
|
||||
// rename
|
||||
pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall38(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall38 (rename)");
|
||||
let old_path = varargs.get_str(ctx);
|
||||
let new_path = varargs.get_str(ctx);
|
||||
@@ -191,7 +191,7 @@ pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
}
|
||||
|
||||
// rmdir
|
||||
pub fn ___syscall40(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall40(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall40 (rmdir)");
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
let real_path_owned = get_cstr_path(ctx, pathname_addr as *const _);
|
||||
@@ -204,7 +204,7 @@ pub fn ___syscall40(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
// pipe
|
||||
pub fn ___syscall42(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall42(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall42 (pipe)");
|
||||
// offset to a file descriptor, which contains a read end and write end, 2 integers
|
||||
let fd_offset: u32 = varargs.get(ctx);
|
||||
@@ -232,28 +232,28 @@ pub fn ___syscall42(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
result
|
||||
}
|
||||
|
||||
pub fn ___syscall51(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall51(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall51");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall52(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall52(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall52");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall53(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall53(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall53");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall60(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall60(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall60");
|
||||
-1
|
||||
}
|
||||
|
||||
// dup2
|
||||
pub fn ___syscall63(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall63(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall63 (dup2) {}", _which);
|
||||
|
||||
let src: i32 = varargs.get(ctx);
|
||||
@@ -263,93 +263,93 @@ pub fn ___syscall63(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
// getppid
|
||||
pub fn ___syscall64(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall64(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall64 (getppid)");
|
||||
unsafe { getpid() }
|
||||
}
|
||||
|
||||
pub fn ___syscall66(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall66(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall66");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall75(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall75(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall75");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall91(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall91(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall91 - stub");
|
||||
0
|
||||
}
|
||||
|
||||
pub fn ___syscall96(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall96(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall96");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall97(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall97(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall97");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall110(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall110(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall110");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall121(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall121(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall121");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall125(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall125(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall125");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall133(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall133(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall133");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall144(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall144(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall144");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall147(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall147(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall147");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall150(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall150(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall150");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall151(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall151(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall151");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall152(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall152(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall152");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall153(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall153(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall153");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall163(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall163(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall163");
|
||||
-1
|
||||
}
|
||||
|
||||
// getcwd
|
||||
pub fn ___syscall183(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall183(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall183");
|
||||
let buf_offset: WasmPtr<libc::c_char, Array> = varargs.get(ctx);
|
||||
let _size: c_int = varargs.get(ctx);
|
||||
@@ -366,7 +366,7 @@ pub fn ___syscall183(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32
|
||||
}
|
||||
|
||||
// mmap2
|
||||
pub fn ___syscall192(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall192(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall192 (mmap2) {}", _which);
|
||||
let _addr: i32 = varargs.get(ctx);
|
||||
let len: u32 = varargs.get(ctx);
|
||||
@@ -401,7 +401,7 @@ pub fn ___syscall192(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// lseek
|
||||
pub fn ___syscall140(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall140(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
// -> c_int
|
||||
debug!("emscripten::___syscall140 (lseek) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@@ -429,7 +429,7 @@ pub fn ___syscall140(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
|
||||
/// readv
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall145(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall145(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
// -> ssize_t
|
||||
debug!("emscripten::___syscall145 (readv) {}", _which);
|
||||
|
||||
@@ -466,7 +466,7 @@ pub fn ___syscall145(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32
|
||||
|
||||
// writev
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall146(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall146(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
// -> ssize_t
|
||||
debug!("emscripten::___syscall146 (writev) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@@ -507,7 +507,7 @@ pub fn ___syscall146(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
ret as _
|
||||
}
|
||||
|
||||
pub fn ___syscall191(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall191(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
let _resource: i32 = varargs.get(ctx);
|
||||
debug!(
|
||||
"emscripten::___syscall191 - mostly stub, resource: {}",
|
||||
@@ -524,13 +524,13 @@ pub fn ___syscall191(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn ___syscall193(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall193(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall193");
|
||||
-1
|
||||
}
|
||||
|
||||
// stat64
|
||||
pub fn ___syscall195(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall195(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall195 (stat64) {}", _which);
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@@ -561,7 +561,7 @@ pub fn ___syscall195(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
// fstat64
|
||||
pub fn ___syscall197(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall197(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall197 (fstat64) {}", _which);
|
||||
|
||||
let fd: c_int = varargs.get(ctx);
|
||||
@@ -580,129 +580,129 @@ pub fn ___syscall197(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
0
|
||||
}
|
||||
|
||||
pub fn ___syscall209(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall209(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall209");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall211(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall211(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall211");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall218(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall218(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall218");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall268(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall268(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall268");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall269(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall269(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall269");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall272(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall272(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall272");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall295(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall295(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall295");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall296(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall296(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall296");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall297(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall297(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall297");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall298(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall298(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall298");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall300(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall300(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall300");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall301(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall301(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall301");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall302(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall302(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall302");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall303(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall303(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall303");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall304(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall304(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall304");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall305(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall305(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall305");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall306(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall306(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall306");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall307(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall307(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall307");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall308(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall308(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall308");
|
||||
-1
|
||||
}
|
||||
|
||||
// utimensat
|
||||
pub fn ___syscall320(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall320(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall320 (utimensat), {}", _which);
|
||||
0
|
||||
}
|
||||
|
||||
pub fn ___syscall331(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall331(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall331");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall333(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall333(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall333");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall334(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall334(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall334");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn ___syscall337(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall337(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall337");
|
||||
-1
|
||||
}
|
||||
|
||||
// prlimit64
|
||||
pub fn ___syscall340(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall340(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall340 (prlimit64), {}", _which);
|
||||
// NOTE: Doesn't really matter. Wasm modules cannot exceed WASM_PAGE_SIZE anyway.
|
||||
let _pid: i32 = varargs.get(ctx);
|
||||
@@ -728,7 +728,7 @@ pub fn ___syscall340(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
0
|
||||
}
|
||||
|
||||
pub fn ___syscall345(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall345(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall345");
|
||||
-1
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@ fn translate_ioctl(wasm_ioctl: u32) -> c_ulong {
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use std::ffi::CStr;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
use crate::env::EmSockAddr;
|
||||
use crate::utils::{self, get_cstr_path};
|
||||
use crate::EmEnv;
|
||||
#[allow(unused_imports)]
|
||||
use std::io::Error;
|
||||
use std::mem;
|
||||
@@ -156,7 +156,7 @@ use libc::SO_NOSIGPIPE;
|
||||
const SO_NOSIGPIPE: c_int = 0;
|
||||
|
||||
/// open
|
||||
pub fn ___syscall5(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall5(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall5 (open) {}", _which);
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
let flags: i32 = varargs.get(ctx);
|
||||
@@ -180,7 +180,7 @@ pub fn ___syscall5(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// link
|
||||
pub fn ___syscall9(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall9(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall9 (link) {}", _which);
|
||||
|
||||
let oldname_ptr = varargs.get_str(ctx);
|
||||
@@ -196,7 +196,7 @@ pub fn ___syscall9(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// getrusage
|
||||
pub fn ___syscall77(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall77(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall77 (getrusage) {}", _which);
|
||||
|
||||
let resource: c_int = varargs.get(ctx);
|
||||
@@ -208,7 +208,7 @@ pub fn ___syscall77(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// symlink
|
||||
pub fn ___syscall83(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall83(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall83 (symlink) {}", _which);
|
||||
|
||||
let path1 = varargs.get_str(ctx);
|
||||
@@ -236,7 +236,7 @@ pub fn ___syscall83(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// readlink
|
||||
pub fn ___syscall85(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall85(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall85 (readlink)");
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
let buf = varargs.get_str(ctx);
|
||||
@@ -265,7 +265,7 @@ pub fn ___syscall85(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
|
||||
}
|
||||
|
||||
/// ftruncate64
|
||||
pub fn ___syscall194(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall194(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall194 (ftruncate64) {}", _which);
|
||||
let _fd: c_int = varargs.get(ctx);
|
||||
let _length: i64 = varargs.get(ctx);
|
||||
@@ -282,7 +282,7 @@ pub fn ___syscall194(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// lchown
|
||||
pub fn ___syscall198(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall198(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall198 (lchown) {}", _which);
|
||||
let path_ptr = varargs.get_str(ctx);
|
||||
let real_path_owned = utils::get_cstr_path(ctx, path_ptr as *const _);
|
||||
@@ -305,7 +305,7 @@ pub fn ___syscall198(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// getgroups
|
||||
pub fn ___syscall205(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall205(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall205 (getgroups) {}", _which);
|
||||
let ngroups_max: c_int = varargs.get(ctx);
|
||||
let groups: c_int = varargs.get(ctx);
|
||||
@@ -322,7 +322,7 @@ pub fn ___syscall205(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
// chown
|
||||
pub fn ___syscall212(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall212(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall212 (chown) {}", _which);
|
||||
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
@@ -339,7 +339,7 @@ pub fn ___syscall212(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// madvise
|
||||
pub fn ___syscall219(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall219(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall212 (chown) {}", _which);
|
||||
|
||||
let addr_ptr: c_int = varargs.get(ctx);
|
||||
@@ -352,7 +352,7 @@ pub fn ___syscall219(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// access
|
||||
pub fn ___syscall33(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall33(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall33 (access) {}", _which);
|
||||
let path = varargs.get_str(ctx);
|
||||
let real_path_owned = utils::get_cstr_path(ctx, path as *const _);
|
||||
@@ -373,14 +373,14 @@ pub fn ___syscall33(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// nice
|
||||
pub fn ___syscall34(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall34(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall34 (nice) {}", _which);
|
||||
let inc_r: c_int = varargs.get(ctx);
|
||||
unsafe { nice(inc_r) }
|
||||
}
|
||||
|
||||
// mkdir
|
||||
pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall39(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall39 (mkdir) {}", _which);
|
||||
let pathname_addr = varargs.get_str(ctx);
|
||||
let real_path_owned = utils::get_cstr_path(ctx, pathname_addr as *const _);
|
||||
@@ -394,20 +394,20 @@ pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// dup
|
||||
pub fn ___syscall41(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall41(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall41 (dup) {}", _which);
|
||||
let fd: c_int = varargs.get(ctx);
|
||||
unsafe { dup(fd) }
|
||||
}
|
||||
|
||||
/// getgid32
|
||||
pub fn ___syscall200(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall200(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall200 (getgid32)");
|
||||
unsafe { getgid() as i32 }
|
||||
}
|
||||
|
||||
// geteuid32
|
||||
pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall201 (geteuid32)");
|
||||
unsafe {
|
||||
// Maybe fix: Emscripten returns 0 always
|
||||
@@ -416,7 +416,7 @@ pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
}
|
||||
|
||||
// getegid32
|
||||
pub fn ___syscall202(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
// gid_t
|
||||
debug!("emscripten::___syscall202 (getegid32)");
|
||||
unsafe {
|
||||
@@ -426,7 +426,7 @@ pub fn ___syscall202(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
}
|
||||
|
||||
/// fchown
|
||||
pub fn ___syscall207(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall207(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall207 (fchown) {}", _which);
|
||||
let fd: c_int = varargs.get(ctx);
|
||||
let owner: uid_t = varargs.get(ctx);
|
||||
@@ -435,7 +435,7 @@ pub fn ___syscall207(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// dup3
|
||||
pub fn ___syscall330(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t {
|
||||
pub fn ___syscall330(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t {
|
||||
// Implementation based on description at https://linux.die.net/man/2/dup3
|
||||
debug!("emscripten::___syscall330 (dup3)");
|
||||
let oldfd: c_int = varargs.get(ctx);
|
||||
@@ -469,7 +469,7 @@ pub fn ___syscall330(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_
|
||||
}
|
||||
|
||||
/// ioctl
|
||||
pub fn ___syscall54(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall54(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall54 (ioctl) {}", _which);
|
||||
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@@ -511,7 +511,7 @@ const SOCK_CLOEXC: i32 = 0x80000;
|
||||
|
||||
// socketcall
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall102(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall102(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall102 (socketcall) {}", _which);
|
||||
let call: u32 = varargs.get(ctx);
|
||||
let mut socket_varargs: VarArgs = varargs.get(ctx);
|
||||
@@ -829,7 +829,7 @@ fn translate_socket_name_flag(name: i32) -> i32 {
|
||||
}
|
||||
|
||||
/// getpgid
|
||||
pub fn ___syscall132(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall132(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall132 (getpgid)");
|
||||
|
||||
let pid: pid_t = varargs.get(ctx);
|
||||
@@ -850,10 +850,10 @@ pub struct EmPollFd {
|
||||
pub revents: i16,
|
||||
}
|
||||
|
||||
unsafe impl wasmer_runtime_core::types::ValueType for EmPollFd {}
|
||||
unsafe impl wasmer::ValueType for EmPollFd {}
|
||||
|
||||
/// poll
|
||||
pub fn ___syscall168(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall168(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall168(poll)");
|
||||
let fds: WasmPtr<EmPollFd> = varargs.get(ctx);
|
||||
let nfds: u32 = varargs.get(ctx);
|
||||
@@ -873,7 +873,7 @@ pub fn ___syscall168(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
}
|
||||
|
||||
// pread
|
||||
pub fn ___syscall180(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall180(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall180 (pread) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@@ -890,7 +890,7 @@ pub fn ___syscall180(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
// pwrite
|
||||
pub fn ___syscall181(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall181(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall181 (pwrite) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
@@ -911,7 +911,7 @@ pub fn ___syscall181(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// fchmod
|
||||
pub fn ___syscall94(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall94(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall118 (fchmod) {}", _which);
|
||||
let fd: c_int = varargs.get(ctx);
|
||||
let mode: mode_t = varargs.get(ctx);
|
||||
@@ -920,7 +920,7 @@ pub fn ___syscall94(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
|
||||
/// wait4
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall114(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t {
|
||||
pub fn ___syscall114(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t {
|
||||
debug!("emscripten::___syscall114 (wait4)");
|
||||
let pid: pid_t = varargs.get(ctx);
|
||||
let status: u32 = varargs.get(ctx);
|
||||
@@ -938,7 +938,7 @@ pub fn ___syscall114(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_
|
||||
}
|
||||
|
||||
/// fsync
|
||||
pub fn ___syscall118(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall118(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall118 (fsync) {}", _which);
|
||||
let fd: c_int = varargs.get(ctx);
|
||||
unsafe { fsync(fd) }
|
||||
@@ -946,7 +946,7 @@ pub fn ___syscall118(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
|
||||
// select
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall142(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall142(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall142 (newselect) {}", _which);
|
||||
|
||||
let nfds: i32 = varargs.get(ctx);
|
||||
@@ -968,7 +968,7 @@ pub fn ___syscall142(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// fdatasync
|
||||
pub fn ___syscall148(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall148(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall148 (fdatasync) {}", _which);
|
||||
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@@ -977,7 +977,7 @@ pub fn ___syscall148(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
// setpgid
|
||||
pub fn ___syscall57(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall57(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall57 (setpgid) {}", _which);
|
||||
|
||||
let pid: i32 = varargs.get(ctx);
|
||||
@@ -993,7 +993,7 @@ pub fn ___syscall57(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
||||
|
||||
/// uname
|
||||
// NOTE: Wondering if we should return custom utsname, like Emscripten.
|
||||
pub fn ___syscall122(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall122(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall122 (uname) {}", _which);
|
||||
let buf: u32 = varargs.get(ctx);
|
||||
debug!("=> buf: {}", buf);
|
||||
@@ -1002,7 +1002,7 @@ pub fn ___syscall122(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// lstat64
|
||||
pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall196(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall196 (lstat64) {}", _which);
|
||||
let path = varargs.get_str(ctx);
|
||||
let real_path_owned = utils::get_cstr_path(ctx, path as *const _);
|
||||
@@ -1035,7 +1035,7 @@ pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
}
|
||||
|
||||
// getuid
|
||||
pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall199 (getuid)");
|
||||
let uid = unsafe { getuid() as _ };
|
||||
debug!(" => {}", uid);
|
||||
@@ -1045,7 +1045,7 @@ pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
// getdents
|
||||
// dirent structure is
|
||||
// i64, i64, u16 (280), i8, [i8; 256]
|
||||
pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall220(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
use super::super::env::get_emscripten_data;
|
||||
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
@@ -1109,7 +1109,7 @@ pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
|
||||
}
|
||||
|
||||
// fcntl64
|
||||
pub fn ___syscall221(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall221(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall221 (fcntl64) {}", _which);
|
||||
let fd: i32 = varargs.get(ctx);
|
||||
let cmd: i32 = varargs.get(ctx);
|
||||
@@ -1127,7 +1127,7 @@ pub fn ___syscall221(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// fallocate
|
||||
pub fn ___syscall324(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall324(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall324 (fallocate) {}", _which);
|
||||
let _fd: c_int = varargs.get(ctx);
|
||||
let _mode: c_int = varargs.get(ctx);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::utils::{copy_cstr_into_wasm, get_cstr_path};
|
||||
use crate::varargs::VarArgs;
|
||||
use crate::EmEnv;
|
||||
use libc::mkdir;
|
||||
use libc::open;
|
||||
use std::env;
|
||||
@@ -7,13 +8,12 @@ use std::ffi::CString;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::os::raw::c_int;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
type pid_t = c_int;
|
||||
|
||||
/// open
|
||||
pub fn ___syscall5(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall5(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall5 (open) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -64,19 +64,19 @@ pub fn ___syscall5(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
}
|
||||
|
||||
/// link
|
||||
pub fn ___syscall9(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall9(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall9 (link) {}", _which);
|
||||
unimplemented!("emscripten::___syscall9 (link) {}", _which);
|
||||
}
|
||||
|
||||
/// ftruncate64
|
||||
pub fn ___syscall194(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall194(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall194 - stub");
|
||||
unimplemented!("emscripten::___syscall194 - stub")
|
||||
}
|
||||
|
||||
// chown
|
||||
pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall212(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall212 (chown) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -84,19 +84,19 @@ pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
|
||||
}
|
||||
|
||||
/// access
|
||||
pub fn ___syscall33(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall33(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall33 (access) {}", _which);
|
||||
unimplemented!("emscripten::___syscall33 (access) {}", _which);
|
||||
}
|
||||
|
||||
/// nice
|
||||
pub fn ___syscall34(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall34(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall34 (nice) {}", _which);
|
||||
unimplemented!("emscripten::___syscall34 (nice) {}", _which);
|
||||
}
|
||||
|
||||
// mkdir
|
||||
pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall39(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall39 (mkdir) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -111,80 +111,80 @@ pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int
|
||||
}
|
||||
|
||||
/// dup
|
||||
pub fn ___syscall41(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall41(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall41 (dup) {}", _which);
|
||||
unimplemented!("emscripten::___syscall41 (dup) {}", _which);
|
||||
}
|
||||
|
||||
/// getrusage
|
||||
pub fn ___syscall77(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall77(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall77 (getrusage) {}", _which);
|
||||
unimplemented!("emscripten::___syscall77 (getrusage) {}", _which);
|
||||
}
|
||||
|
||||
/// symlink
|
||||
pub fn ___syscall83(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall83(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall83 (symlink) {}", _which);
|
||||
unimplemented!("emscripten::___syscall83 (symlink) {}", _which);
|
||||
}
|
||||
|
||||
/// readlink
|
||||
pub fn ___syscall85(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall85(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall85 (readlink) {}", _which);
|
||||
-1
|
||||
}
|
||||
|
||||
/// getpgid
|
||||
pub fn ___syscall132(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall132(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall132 (getpgid)");
|
||||
-1
|
||||
}
|
||||
|
||||
/// lchown
|
||||
pub fn ___syscall198(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall198(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall198 (lchown) {}", _which);
|
||||
unimplemented!("emscripten::___syscall198 (lchown) {}", _which);
|
||||
}
|
||||
|
||||
/// getgid32
|
||||
pub fn ___syscall200(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall200(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall200 (getgid32)");
|
||||
unimplemented!("emscripten::___syscall200 (getgid32)");
|
||||
}
|
||||
|
||||
// geteuid32
|
||||
pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall201 (geteuid32)");
|
||||
unimplemented!("emscripten::___syscall201 (geteuid32)");
|
||||
}
|
||||
|
||||
// getegid32
|
||||
pub fn ___syscall202(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
// gid_t
|
||||
debug!("emscripten::___syscall202 (getegid32)");
|
||||
unimplemented!("emscripten::___syscall202 (getegid32)");
|
||||
}
|
||||
|
||||
/// getgroups
|
||||
pub fn ___syscall205(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall205(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall205 (getgroups) {}", _which);
|
||||
unimplemented!("emscripten::___syscall205 (getgroups) {}", _which);
|
||||
}
|
||||
|
||||
/// madvise
|
||||
pub fn ___syscall219(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall219(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall212 (chown) {}", _which);
|
||||
unimplemented!("emscripten::___syscall212 (chown) {}", _which);
|
||||
}
|
||||
|
||||
/// dup3
|
||||
pub fn ___syscall330(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
||||
pub fn ___syscall330(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
||||
debug!("emscripten::___syscall330 (dup3)");
|
||||
-1
|
||||
}
|
||||
|
||||
/// ioctl
|
||||
pub fn ___syscall54(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall54(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall54 (ioctl) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -192,14 +192,14 @@ pub fn ___syscall54(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_in
|
||||
}
|
||||
|
||||
/// fchmod
|
||||
pub fn ___syscall94(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall94(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall118 (fchmod) {}", _which);
|
||||
unimplemented!("emscripten::___syscall118 (fchmod) {}", _which);
|
||||
}
|
||||
|
||||
// socketcall
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall102(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall102(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall102 (socketcall) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -207,13 +207,13 @@ pub fn ___syscall102(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
|
||||
}
|
||||
|
||||
/// fsync
|
||||
pub fn ___syscall118(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall118(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall118 (fsync) {}", _which);
|
||||
unimplemented!("emscripten::___syscall118 (fsync) {}", _which);
|
||||
}
|
||||
|
||||
// pread
|
||||
pub fn ___syscall180(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall180(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall180 (pread) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -221,7 +221,7 @@ pub fn ___syscall180(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
|
||||
}
|
||||
|
||||
// pwrite
|
||||
pub fn ___syscall181(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall181(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall181 (pwrite) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -230,14 +230,14 @@ pub fn ___syscall181(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
|
||||
|
||||
/// wait4
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall114(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
||||
pub fn ___syscall114(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
||||
debug!("emscripten::___syscall114 (wait4)");
|
||||
-1
|
||||
}
|
||||
|
||||
// select
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn ___syscall142(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall142(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall142 (newselect) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -245,13 +245,13 @@ pub fn ___syscall142(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
|
||||
}
|
||||
|
||||
/// fdatasync
|
||||
pub fn ___syscall148(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall148(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall148 (fdatasync) {}", _which);
|
||||
unimplemented!("emscripten::___syscall148 (fdatasync) {}", _which);
|
||||
}
|
||||
|
||||
// setpgid
|
||||
pub fn ___syscall57(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall57(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall57 (setpgid) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -260,7 +260,7 @@ pub fn ___syscall57(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_in
|
||||
|
||||
/// uname
|
||||
// NOTE: Wondering if we should return custom utsname, like Emscripten.
|
||||
pub fn ___syscall122(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall122(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall122 (uname) {}", which);
|
||||
#[cfg(not(feature = "debug"))]
|
||||
let _ = which;
|
||||
@@ -268,43 +268,43 @@ pub fn ___syscall122(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
|
||||
}
|
||||
|
||||
/// poll
|
||||
pub fn ___syscall168(_ctx: &mut Ctx, _which: i32, _varargs: VarArgs) -> i32 {
|
||||
pub fn ___syscall168(_ctx: &mut EmEnv, _which: i32, _varargs: VarArgs) -> i32 {
|
||||
debug!("emscripten::___syscall168(poll) - stub");
|
||||
-1
|
||||
}
|
||||
|
||||
/// lstat64
|
||||
pub fn ___syscall196(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall196(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall196 (lstat64) - stub");
|
||||
-1
|
||||
}
|
||||
|
||||
// getuid
|
||||
pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall199 (getuid)");
|
||||
-1
|
||||
}
|
||||
|
||||
// getdents
|
||||
pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn ___syscall220(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::___syscall220");
|
||||
-1
|
||||
}
|
||||
|
||||
// fcntl64
|
||||
pub fn ___syscall221(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall221(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall221 (fcntl64) {}", _which);
|
||||
-1
|
||||
}
|
||||
|
||||
/// fchown
|
||||
pub fn ___syscall207(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall207(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall207 (fchown) {}", _which);
|
||||
unimplemented!("emscripten::___syscall207 (fchown) {}", _which)
|
||||
}
|
||||
|
||||
/// fallocate
|
||||
pub fn ___syscall324(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
pub fn ___syscall324(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||
debug!("emscripten::___syscall324 (fallocate) {}", _which);
|
||||
unimplemented!("emscripten::___syscall324 (fallocate) {}", _which)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::utils::{copy_cstr_into_wasm, write_to_buf};
|
||||
use crate::allocate_on_stack;
|
||||
use crate::{allocate_on_stack, EmEnv};
|
||||
use libc::{c_char, c_int};
|
||||
// use libc::{c_char, c_int, clock_getres, clock_settime};
|
||||
use std::mem;
|
||||
@@ -26,7 +26,6 @@ extern "C" {
|
||||
use time;
|
||||
|
||||
use super::env;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use libc::{CLOCK_MONOTONIC, CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME};
|
||||
@@ -53,7 +52,7 @@ const CLOCK_MONOTONIC_COARSE: clockid_t = 6;
|
||||
|
||||
/// emscripten: _gettimeofday
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _gettimeofday(ctx: &mut Ctx, tp: c_int, tz: c_int) -> c_int {
|
||||
pub fn _gettimeofday(ctx: &mut EmEnv, tp: c_int, tz: c_int) -> c_int {
|
||||
debug!("emscripten::_gettimeofday {} {}", tp, tz);
|
||||
#[repr(C)]
|
||||
struct GuestTimeVal {
|
||||
@@ -76,7 +75,7 @@ pub fn _gettimeofday(ctx: &mut Ctx, tp: c_int, tz: c_int) -> c_int {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _clock_getres(_ctx: &mut Ctx, _clk_id: i32, _tp: i32) -> i32 {
|
||||
pub fn _clock_getres(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 {
|
||||
debug!("emscripten::_clock_getres");
|
||||
// clock_getres(clk_id, tp)
|
||||
0
|
||||
@@ -84,7 +83,7 @@ pub fn _clock_getres(_ctx: &mut Ctx, _clk_id: i32, _tp: i32) -> i32 {
|
||||
|
||||
/// emscripten: _clock_gettime
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int {
|
||||
pub fn _clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int {
|
||||
debug!("emscripten::_clock_gettime {} {}", clk_id, tp);
|
||||
// debug!("Memory {:?}", ctx.memory(0)[..]);
|
||||
#[repr(C)]
|
||||
@@ -116,41 +115,41 @@ pub fn _clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn _clock_settime(_ctx: &mut Ctx, _clk_id: i32, _tp: i32) -> i32 {
|
||||
pub fn _clock_settime(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 {
|
||||
debug!("emscripten::_clock_settime");
|
||||
// clock_settime(clk_id, tp)
|
||||
0
|
||||
}
|
||||
|
||||
/// emscripten: ___clock_gettime
|
||||
pub fn ___clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int {
|
||||
pub fn ___clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int {
|
||||
debug!("emscripten::___clock_gettime {} {}", clk_id, tp);
|
||||
_clock_gettime(ctx, clk_id, tp)
|
||||
}
|
||||
|
||||
/// emscripten: _clock
|
||||
pub fn _clock(_ctx: &mut Ctx) -> c_int {
|
||||
pub fn _clock(_ctx: &mut EmEnv) -> c_int {
|
||||
debug!("emscripten::_clock");
|
||||
0 // TODO: unimplemented
|
||||
}
|
||||
|
||||
/// emscripten: _difftime
|
||||
pub fn _difftime(_ctx: &mut Ctx, t0: u32, t1: u32) -> f64 {
|
||||
pub fn _difftime(_ctx: &mut EmEnv, t0: u32, t1: u32) -> f64 {
|
||||
debug!("emscripten::_difftime");
|
||||
(t0 - t1) as _
|
||||
}
|
||||
|
||||
pub fn _gmtime_r(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
pub fn _gmtime_r(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_gmtime_r");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _mktime(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _mktime(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_mktime");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _gmtime(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||
pub fn _gmtime(_ctx: &mut EmEnv, _one: i32) -> i32 {
|
||||
debug!("emscripten::_gmtime");
|
||||
-1
|
||||
}
|
||||
@@ -171,13 +170,13 @@ struct guest_tm {
|
||||
}
|
||||
|
||||
/// emscripten: _tvset
|
||||
pub fn _tvset(_ctx: &mut Ctx) {
|
||||
pub fn _tvset(_ctx: &mut EmEnv) {
|
||||
debug!("emscripten::_tvset UNIMPLEMENTED");
|
||||
}
|
||||
|
||||
/// formats time as a C string
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
unsafe fn fmt_time(ctx: &mut Ctx, time: u32) -> *const c_char {
|
||||
unsafe fn fmt_time(ctx: &mut EmEnv, time: u32) -> *const c_char {
|
||||
let date = &*(emscripten_memory_pointer!(ctx.memory(0), time) as *mut guest_tm);
|
||||
|
||||
let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
@@ -202,7 +201,7 @@ unsafe fn fmt_time(ctx: &mut Ctx, time: u32) -> *const c_char {
|
||||
}
|
||||
|
||||
/// emscripten: _asctime
|
||||
pub fn _asctime(ctx: &mut Ctx, time: u32) -> u32 {
|
||||
pub fn _asctime(ctx: &mut EmEnv, time: u32) -> u32 {
|
||||
debug!("emscripten::_asctime {}", time);
|
||||
|
||||
unsafe {
|
||||
@@ -216,7 +215,7 @@ pub fn _asctime(ctx: &mut Ctx, time: u32) -> u32 {
|
||||
}
|
||||
|
||||
/// emscripten: _asctime_r
|
||||
pub fn _asctime_r(ctx: &mut Ctx, time: u32, buf: u32) -> u32 {
|
||||
pub fn _asctime_r(ctx: &mut EmEnv, time: u32, buf: u32) -> u32 {
|
||||
debug!("emscripten::_asctime_r {}, {}", time, buf);
|
||||
|
||||
unsafe {
|
||||
@@ -235,7 +234,7 @@ pub fn _asctime_r(ctx: &mut Ctx, time: u32, buf: u32) -> u32 {
|
||||
|
||||
/// emscripten: _localtime
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _localtime(ctx: &mut Ctx, time_p: u32) -> c_int {
|
||||
pub fn _localtime(ctx: &mut EmEnv, time_p: u32) -> c_int {
|
||||
debug!("emscripten::_localtime {}", time_p);
|
||||
// NOTE: emscripten seems to want tzset() called in this function
|
||||
// https://stackoverflow.com/questions/19170721/real-time-awareness-of-timezone-change-in-localtime-vs-localtime-r
|
||||
@@ -273,7 +272,7 @@ pub fn _localtime(ctx: &mut Ctx, time_p: u32) -> c_int {
|
||||
}
|
||||
/// emscripten: _localtime_r
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _localtime_r(ctx: &mut Ctx, time_p: u32, result: u32) -> c_int {
|
||||
pub fn _localtime_r(ctx: &mut EmEnv, time_p: u32, result: u32) -> c_int {
|
||||
debug!("emscripten::_localtime_r {}", time_p);
|
||||
|
||||
// NOTE: emscripten seems to want tzset() called in this function
|
||||
@@ -310,7 +309,7 @@ pub fn _localtime_r(ctx: &mut Ctx, time_p: u32, result: u32) -> c_int {
|
||||
|
||||
/// emscripten: _time
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _time(ctx: &mut Ctx, time_p: u32) -> i32 {
|
||||
pub fn _time(ctx: &mut EmEnv, time_p: u32) -> i32 {
|
||||
debug!("emscripten::_time {}", time_p);
|
||||
|
||||
unsafe {
|
||||
@@ -319,7 +318,7 @@ pub fn _time(ctx: &mut Ctx, time_p: u32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _ctime_r(ctx: &mut Ctx, time_p: u32, buf: u32) -> u32 {
|
||||
pub fn _ctime_r(ctx: &mut EmEnv, time_p: u32, buf: u32) -> u32 {
|
||||
debug!("emscripten::_ctime_r {} {}", time_p, buf);
|
||||
|
||||
// var stack = stackSave();
|
||||
@@ -330,7 +329,7 @@ pub fn _ctime_r(ctx: &mut Ctx, time_p: u32, buf: u32) -> u32 {
|
||||
rv
|
||||
}
|
||||
|
||||
pub fn _ctime(ctx: &mut Ctx, time_p: u32) -> u32 {
|
||||
pub fn _ctime(ctx: &mut EmEnv, time_p: u32) -> u32 {
|
||||
debug!("emscripten::_ctime {}", time_p);
|
||||
let tm_current = 2414544;
|
||||
_ctime_r(ctx, time_p, tm_current)
|
||||
@@ -339,7 +338,7 @@ pub fn _ctime(ctx: &mut Ctx, time_p: u32) -> u32 {
|
||||
/// emscripten: _timegm
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub fn _timegm(ctx: &mut Ctx, time_ptr: u32) -> i32 {
|
||||
pub fn _timegm(ctx: &mut EmEnv, time_ptr: u32) -> i32 {
|
||||
debug!("emscripten::_timegm {}", time_ptr);
|
||||
|
||||
unsafe {
|
||||
@@ -379,7 +378,7 @@ pub fn _timegm(ctx: &mut Ctx, time_ptr: u32) -> i32 {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn _timegm(_ctx: &mut Ctx, _time_ptr: c_int) -> i32 {
|
||||
pub fn _timegm(_ctx: &mut EmEnv, _time_ptr: c_int) -> i32 {
|
||||
debug!(
|
||||
"emscripten::_timegm - UNIMPLEMENTED IN WINDOWS {}",
|
||||
_time_ptr
|
||||
@@ -389,7 +388,7 @@ pub fn _timegm(_ctx: &mut Ctx, _time_ptr: c_int) -> i32 {
|
||||
|
||||
/// emscripten: _strftime
|
||||
pub fn _strftime(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
s_ptr: c_int,
|
||||
maxsize: u32,
|
||||
format_ptr: c_int,
|
||||
@@ -449,7 +448,7 @@ pub fn _strftime(
|
||||
|
||||
/// emscripten: _strftime_l
|
||||
pub fn _strftime_l(
|
||||
ctx: &mut Ctx,
|
||||
ctx: &mut EmEnv,
|
||||
s_ptr: c_int,
|
||||
maxsize: u32,
|
||||
format_ptr: c_int,
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
pub fn _getcontext(_ctx: &mut Ctx, _ucp: i32) -> i32 {
|
||||
pub fn _getcontext(_ctx: &mut EmEnv, _ucp: i32) -> i32 {
|
||||
debug!("emscripten::_getcontext({})", _ucp);
|
||||
0
|
||||
}
|
||||
pub fn _makecontext(_ctx: &mut Ctx, _ucp: i32, _func: i32, _argc: i32, _argv: i32) {
|
||||
pub fn _makecontext(_ctx: &mut EmEnv, _ucp: i32, _func: i32, _argc: i32, _argv: i32) {
|
||||
debug!(
|
||||
"emscripten::_makecontext({}, {}, {}, {})",
|
||||
_ucp, _func, _argc, _argv
|
||||
);
|
||||
}
|
||||
pub fn _setcontext(_ctx: &mut Ctx, _ucp: i32) -> i32 {
|
||||
pub fn _setcontext(_ctx: &mut EmEnv, _ucp: i32) -> i32 {
|
||||
debug!("emscripten::_setcontext({})", _ucp);
|
||||
0
|
||||
}
|
||||
pub fn _swapcontext(_ctx: &mut Ctx, _oucp: i32, _ucp: i32) -> i32 {
|
||||
pub fn _swapcontext(_ctx: &mut EmEnv, _oucp: i32, _ucp: i32) -> i32 {
|
||||
debug!("emscripten::_swapcontext({}, {})", _oucp, _ucp);
|
||||
0
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
use crate::EmEnv;
|
||||
|
||||
pub fn confstr(_ctx: &mut Ctx, _name: i32, _buf_pointer: i32, _len: i32) -> i32 {
|
||||
pub fn confstr(_ctx: &mut EmEnv, _name: i32, _buf_pointer: i32, _len: i32) -> i32 {
|
||||
debug!("unistd::confstr({}, {}, {})", _name, _buf_pointer, _len);
|
||||
0
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
use super::env;
|
||||
use super::env::get_emscripten_data;
|
||||
use crate::storage::align_memory;
|
||||
use crate::EmEnv;
|
||||
use libc::stat;
|
||||
use std::ffi::CStr;
|
||||
use std::mem::size_of;
|
||||
use std::os::raw::c_char;
|
||||
use std::path::PathBuf;
|
||||
use std::slice;
|
||||
use wasmer_runtime_core::memory::Memory;
|
||||
use wasmer::{Memory, Module, Pages};
|
||||
use wasmer_runtime_core::{
|
||||
module::Module,
|
||||
structures::TypedIndex,
|
||||
types::{ImportedMemoryIndex, ImportedTableIndex},
|
||||
units::Pages,
|
||||
vm::Ctx,
|
||||
};
|
||||
|
||||
/// We check if a provided module is an Emscripten generated one
|
||||
@@ -104,7 +102,7 @@ pub fn get_emscripten_metadata(module: &Module) -> Result<Option<(u32, u32)>, St
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn write_to_buf(ctx: &mut Ctx, string: *const c_char, buf: u32, max: u32) -> u32 {
|
||||
pub unsafe fn write_to_buf(ctx: &mut EmEnv, string: *const c_char, buf: u32, max: u32) -> u32 {
|
||||
let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut c_char;
|
||||
|
||||
for i in 0..max {
|
||||
@@ -115,7 +113,7 @@ pub unsafe fn write_to_buf(ctx: &mut Ctx, string: *const c_char, buf: u32, max:
|
||||
}
|
||||
|
||||
/// This function expects nullbyte to be appended.
|
||||
pub unsafe fn copy_cstr_into_wasm(ctx: &mut Ctx, cstr: *const c_char) -> u32 {
|
||||
pub unsafe fn copy_cstr_into_wasm(ctx: &mut EmEnv, cstr: *const c_char) -> u32 {
|
||||
let s = CStr::from_ptr(cstr).to_str().unwrap();
|
||||
let cstr_len = s.len();
|
||||
let space_offset = env::call_malloc(ctx, (cstr_len as u32) + 1);
|
||||
@@ -133,7 +131,7 @@ pub unsafe fn copy_cstr_into_wasm(ctx: &mut Ctx, cstr: *const c_char) -> u32 {
|
||||
space_offset
|
||||
}
|
||||
|
||||
pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a mut Ctx, count: u32) -> (u32, &'a mut [T]) {
|
||||
pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a mut EmEnv, count: u32) -> (u32, &'a mut [T]) {
|
||||
let offset = get_emscripten_data(ctx)
|
||||
.stack_alloc
|
||||
.as_ref()
|
||||
@@ -146,7 +144,7 @@ pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a mut Ctx, count: u32) -> (u
|
||||
(offset, slice)
|
||||
}
|
||||
|
||||
pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut Ctx, s: &str) -> (u32, &'a [u8]) {
|
||||
pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut EmEnv, s: &str) -> (u32, &'a [u8]) {
|
||||
let (offset, slice) = allocate_on_stack(ctx, (s.len() + 1) as u32);
|
||||
|
||||
use std::iter;
|
||||
@@ -158,7 +156,7 @@ pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut Ctx, s: &str) -> (u32, &'a
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &mut Ctx, cstrs: *mut *mut c_char) -> u32 {
|
||||
pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &mut EmEnv, cstrs: *mut *mut c_char) -> u32 {
|
||||
let _total_num = {
|
||||
let mut ptr = cstrs;
|
||||
let mut counter = 0;
|
||||
@@ -196,7 +194,7 @@ pub struct GuestStat {
|
||||
}
|
||||
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
pub unsafe fn copy_stat_into_wasm(ctx: &mut Ctx, buf: u32, stat: &stat) {
|
||||
pub unsafe fn copy_stat_into_wasm(ctx: &mut EmEnv, buf: u32, stat: &stat) {
|
||||
let stat_ptr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut GuestStat;
|
||||
(*stat_ptr).st_dev = stat.st_dev as _;
|
||||
(*stat_ptr).__st_dev_padding = 0;
|
||||
@@ -235,7 +233,7 @@ pub fn read_string_from_wasm(memory: &Memory, offset: u32) -> String {
|
||||
|
||||
/// This function trys to find an entry in mapdir
|
||||
/// translating paths into their correct value
|
||||
pub fn get_cstr_path(ctx: &mut Ctx, path: *const i8) -> Option<std::ffi::CString> {
|
||||
pub fn get_cstr_path(ctx: &mut EmEnv, path: *const i8) -> Option<std::ffi::CString> {
|
||||
use std::collections::VecDeque;
|
||||
|
||||
let path_str =
|
||||
@@ -271,7 +269,7 @@ pub fn get_cstr_path(ctx: &mut Ctx, path: *const i8) -> Option<std::ffi::CString
|
||||
|
||||
/// gets the current directory
|
||||
/// handles mapdir logic
|
||||
pub fn get_current_directory(ctx: &mut Ctx) -> Option<PathBuf> {
|
||||
pub fn get_current_directory(ctx: &mut EmEnv) -> Option<PathBuf> {
|
||||
if let Some(val) = get_emscripten_data(ctx).mapped_dirs.get(".") {
|
||||
return Some(val.clone());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::EmEnv;
|
||||
use std::mem;
|
||||
use wasmer_runtime_core::{types::WasmExternType, vm::Ctx};
|
||||
use wasmer::WasmExternType;
|
||||
// use std::ffi::CStr;
|
||||
use std::os::raw::c_char;
|
||||
|
||||
@@ -10,14 +11,14 @@ pub struct VarArgs {
|
||||
}
|
||||
|
||||
impl VarArgs {
|
||||
pub fn get<T: Sized>(&mut self, ctx: &mut Ctx) -> T {
|
||||
pub fn get<T: Sized>(&mut self, ctx: &mut EmEnv) -> T {
|
||||
let ptr = emscripten_memory_pointer!(ctx.memory(0), self.pointer);
|
||||
self.pointer += mem::size_of::<T>() as u32;
|
||||
unsafe { (ptr as *const T).read() }
|
||||
}
|
||||
|
||||
// pub fn getStr<'a>(&mut self, ctx: &mut Ctx) -> &'a CStr {
|
||||
pub fn get_str(&mut self, ctx: &mut Ctx) -> *const c_char {
|
||||
pub fn get_str(&mut self, ctx: &mut EmEnv) -> *const c_char {
|
||||
let ptr_addr: u32 = self.get(ctx);
|
||||
let ptr = emscripten_memory_pointer!(ctx.memory(0), ptr_addr) as *const c_char;
|
||||
ptr
|
||||
|
||||
@@ -51,7 +51,7 @@ impl<'a> WasiEnv<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the state
|
||||
/// Set the memory
|
||||
pub fn set_memory(&mut self, memory: &'a Memory) {
|
||||
self.memory = Some(memory);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user