mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-26 23:21:35 +00:00
Merge branch 'master' into feature/add-syscalls-for-sqlite3
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::env::get_emscripten_data;
|
use crate::env::get_emscripten_data;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use libc::getdtablesize;
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
pub fn setTempRet0(_ctx: &mut Ctx, _a: i32) {
|
pub fn setTempRet0(_ctx: &mut Ctx, _a: i32) {
|
||||||
@ -10,9 +12,24 @@ pub fn getTempRet0(_ctx: &mut Ctx) -> i32 {
|
|||||||
debug!("emscripten::getTempRet0");
|
debug!("emscripten::getTempRet0");
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
pub fn nullFunc_d(_ctx: &mut Ctx, _a: i32) {
|
||||||
|
debug!("emscripten::nullFunc_d");
|
||||||
|
}
|
||||||
pub fn nullFunc_ji(_ctx: &mut Ctx, _a: i32) {
|
pub fn nullFunc_ji(_ctx: &mut Ctx, _a: i32) {
|
||||||
debug!("emscripten::nullFunc_ji");
|
debug!("emscripten::nullFunc_ji");
|
||||||
}
|
}
|
||||||
|
pub fn nullFunc_viidii(_ctx: &mut Ctx, _a: i32) {
|
||||||
|
debug!("emscripten::nullFunc_viidii");
|
||||||
|
}
|
||||||
|
pub fn nullFunc_iiiiiii(_ctx: &mut Ctx, _a: i32) {
|
||||||
|
debug!("emscripten::nullFunc_iiiiiii");
|
||||||
|
}
|
||||||
|
pub fn nullFunc_iiiiiiii(_ctx: &mut Ctx, _a: i32) {
|
||||||
|
debug!("emscripten::nullFunc_iiiiiiii");
|
||||||
|
}
|
||||||
|
pub fn nullFunc_iiiiiiiiii(_ctx: &mut Ctx, _a: i32) {
|
||||||
|
debug!("emscripten::nullFunc_iiiiiiiiii");
|
||||||
|
}
|
||||||
pub fn invoke_i(ctx: &mut Ctx, index: i32) -> i32 {
|
pub fn invoke_i(ctx: &mut Ctx, index: i32) -> i32 {
|
||||||
debug!("emscripten::invoke_i");
|
debug!("emscripten::invoke_i");
|
||||||
if let Some(dyn_call_i) = &get_emscripten_data(ctx).dyn_call_i {
|
if let Some(dyn_call_i) = &get_emscripten_data(ctx).dyn_call_i {
|
||||||
@ -171,6 +188,10 @@ pub fn _pthread_rwlock_unlock(_ctx: &mut Ctx, _a: i32) -> i32 {
|
|||||||
debug!("emscripten::_pthread_rwlock_unlock");
|
debug!("emscripten::_pthread_rwlock_unlock");
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
pub fn _pthread_setcancelstate(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||||
|
debug!("emscripten::_pthread_setcancelstate");
|
||||||
|
0
|
||||||
|
}
|
||||||
pub fn ___gxx_personality_v0(
|
pub fn ___gxx_personality_v0(
|
||||||
_ctx: &mut Ctx,
|
_ctx: &mut Ctx,
|
||||||
_a: i32,
|
_a: i32,
|
||||||
@ -183,6 +204,37 @@ pub fn ___gxx_personality_v0(
|
|||||||
debug!("emscripten::___gxx_personality_v0");
|
debug!("emscripten::___gxx_personality_v0");
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub fn _getdtablesize(_ctx: &mut Ctx) -> i32 {
|
||||||
|
debug!("emscripten::getdtablesize");
|
||||||
|
unsafe { getdtablesize() }
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
pub fn _getdtablesize(_ctx: &mut Ctx) -> i32 {
|
||||||
|
debug!("emscripten::getdtablesize");
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
pub fn _gethostbyaddr(_ctx: &mut Ctx, _addr: i32, _addrlen: i32, _atype: i32) -> i32 {
|
||||||
|
debug!("emscripten::gethostbyaddr");
|
||||||
|
0
|
||||||
|
}
|
||||||
|
pub fn _gethostbyname_r(
|
||||||
|
_ctx: &mut Ctx,
|
||||||
|
_name: i32,
|
||||||
|
_ret: i32,
|
||||||
|
_buf: i32,
|
||||||
|
_buflen: i32,
|
||||||
|
_out: i32,
|
||||||
|
_err: i32,
|
||||||
|
) -> i32 {
|
||||||
|
debug!("emscripten::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 {
|
||||||
|
debug!("emscripten::getloadavg");
|
||||||
|
0
|
||||||
|
}
|
||||||
// round 2
|
// round 2
|
||||||
pub fn nullFunc_dii(_ctx: &mut Ctx, _index: i32) {
|
pub fn nullFunc_dii(_ctx: &mut Ctx, _index: i32) {
|
||||||
debug!("emscripten::nullFunc_dii");
|
debug!("emscripten::nullFunc_dii");
|
||||||
@ -287,6 +339,67 @@ pub fn invoke_iiiiii(
|
|||||||
panic!("dyn_call_iiiiii is set to None");
|
panic!("dyn_call_iiiiii is set to None");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn invoke_iiiiiii(
|
||||||
|
ctx: &mut Ctx,
|
||||||
|
index: i32,
|
||||||
|
a1: i32,
|
||||||
|
a2: i32,
|
||||||
|
a3: i32,
|
||||||
|
a4: i32,
|
||||||
|
a5: i32,
|
||||||
|
a6: i32,
|
||||||
|
) -> i32 {
|
||||||
|
debug!("emscripten::invoke_iiiiiii");
|
||||||
|
if let Some(dyn_call_iiiiiii) = &get_emscripten_data(ctx).dyn_call_iiiiiii {
|
||||||
|
dyn_call_iiiiiii
|
||||||
|
.call(index, a1, a2, a3, a4, a5, a6)
|
||||||
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
panic!("dyn_call_iiiiiii is set to None");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn invoke_iiiiiiii(
|
||||||
|
ctx: &mut Ctx,
|
||||||
|
index: i32,
|
||||||
|
a1: i32,
|
||||||
|
a2: i32,
|
||||||
|
a3: i32,
|
||||||
|
a4: i32,
|
||||||
|
a5: i32,
|
||||||
|
a6: i32,
|
||||||
|
a7: i32,
|
||||||
|
) -> i32 {
|
||||||
|
debug!("emscripten::invoke_iiiiiiii");
|
||||||
|
if let Some(dyn_call_iiiiiiii) = &get_emscripten_data(ctx).dyn_call_iiiiiiii {
|
||||||
|
dyn_call_iiiiiiii
|
||||||
|
.call(index, a1, a2, a3, a4, a5, a6, a7)
|
||||||
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
panic!("dyn_call_iiiiiiii is set to None");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn invoke_iiiiiiiiii(
|
||||||
|
ctx: &mut Ctx,
|
||||||
|
index: i32,
|
||||||
|
a1: i32,
|
||||||
|
a2: i32,
|
||||||
|
a3: i32,
|
||||||
|
a4: i32,
|
||||||
|
a5: i32,
|
||||||
|
a6: i32,
|
||||||
|
a7: i32,
|
||||||
|
a8: i32,
|
||||||
|
a9: i32,
|
||||||
|
) -> i32 {
|
||||||
|
debug!("emscripten::invoke_iiiiiiiiii");
|
||||||
|
if let Some(dyn_call_iiiiiiiiii) = &get_emscripten_data(ctx).dyn_call_iiiiiiiiii {
|
||||||
|
dyn_call_iiiiiiiiii
|
||||||
|
.call(index, a1, a2, a3, a4, a5, a6, a7, a8, a9)
|
||||||
|
.unwrap()
|
||||||
|
} else {
|
||||||
|
panic!("dyn_call_iiiiiiiiii is set to None");
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn invoke_vd(ctx: &mut Ctx, index: i32, a1: f64) {
|
pub fn invoke_vd(ctx: &mut Ctx, index: i32, a1: f64) {
|
||||||
debug!("emscripten::invoke_vd");
|
debug!("emscripten::invoke_vd");
|
||||||
if let Some(dyn_call_vd) = &get_emscripten_data(ctx).dyn_call_vd {
|
if let Some(dyn_call_vd) = &get_emscripten_data(ctx).dyn_call_vd {
|
||||||
@ -573,3 +686,11 @@ 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");
|
panic!("dyn_call_vijj is set to None");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn invoke_viidii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: f64, a4: i32, a5: i32) {
|
||||||
|
debug!("emscripten::invoke_viidii");
|
||||||
|
if let Some(dyn_call_viidii) = &get_emscripten_data(ctx).dyn_call_viidii {
|
||||||
|
dyn_call_viidii.call(index, a1, a2, a3, a4, a5).unwrap();
|
||||||
|
} else {
|
||||||
|
panic!("dyn_call_viidii is set to None");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use crate::varargs::VarArgs;
|
||||||
use libc::execvp as libc_execvp;
|
use libc::execvp as libc_execvp;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
@ -38,3 +39,15 @@ pub fn execvp(ctx: &mut Ctx, command_name_offset: u32, argv_offset: u32) -> i32
|
|||||||
let args_pointer = argv.as_ptr();
|
let args_pointer = argv.as_ptr();
|
||||||
unsafe { libc_execvp(command_pointer, args_pointer) }
|
unsafe { libc_execvp(command_pointer, args_pointer) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// execl
|
||||||
|
pub fn execl(_ctx: &mut Ctx, _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 {
|
||||||
|
debug!("emscripten::execle");
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
@ -9,3 +9,47 @@ pub use self::unix::*;
|
|||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub use self::windows::*;
|
pub use self::windows::*;
|
||||||
|
|
||||||
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
|
/// getprotobyname
|
||||||
|
pub fn getprotobyname(_ctx: &mut Ctx, _name_ptr: i32) -> i32 {
|
||||||
|
debug!("emscripten::getprotobyname");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getprotobynumber
|
||||||
|
pub fn getprotobynumber(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||||
|
debug!("emscripten::getprotobynumber");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getpwuid
|
||||||
|
pub fn getpwuid(_ctx: &mut Ctx, _uid: i32) -> i32 {
|
||||||
|
debug!("emscripten::getpwuid");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// sigdelset
|
||||||
|
pub fn sigdelset(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
|
debug!("emscripten::sigdelset");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// sigfillset
|
||||||
|
pub fn sigfillset(_ctx: &mut Ctx, _one: i32) -> i32 {
|
||||||
|
debug!("emscripten::sigfillset");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// tzset
|
||||||
|
pub fn tzset(_ctx: &mut Ctx) {
|
||||||
|
debug!("emscripten::tzset");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// strptime
|
||||||
|
pub fn strptime(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
|
||||||
|
debug!("emscripten::strptime");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use libc::printf as _printf;
|
use libc::{chroot as _chroot, printf as _printf};
|
||||||
|
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
@ -15,3 +15,10 @@ pub fn printf(ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
|||||||
_printf(addr, extra)
|
_printf(addr, extra)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// chroot
|
||||||
|
pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 {
|
||||||
|
debug!("emscripten::chroot");
|
||||||
|
let name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8;
|
||||||
|
unsafe { _chroot(name) }
|
||||||
|
}
|
||||||
|
@ -32,3 +32,9 @@ pub fn printf(_ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
|||||||
// }
|
// }
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// chroot
|
||||||
|
pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 {
|
||||||
|
debug!("emscripten::chroot");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
@ -94,6 +94,10 @@ pub struct EmscriptenData<'a> {
|
|||||||
pub dyn_call_diiii: Option<Func<'a, (i32, i32, i32, i32, i32), f64>>,
|
pub dyn_call_diiii: Option<Func<'a, (i32, i32, i32, i32, i32), f64>>,
|
||||||
pub dyn_call_iiiii: Option<Func<'a, (i32, i32, i32, i32, i32), i32>>,
|
pub dyn_call_iiiii: Option<Func<'a, (i32, i32, i32, i32, i32), i32>>,
|
||||||
pub dyn_call_iiiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32), i32>>,
|
pub dyn_call_iiiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32), i32>>,
|
||||||
|
pub dyn_call_iiiiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32), i32>>,
|
||||||
|
pub dyn_call_iiiiiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32, i32), i32>>,
|
||||||
|
pub dyn_call_iiiiiiiiii:
|
||||||
|
Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32, i32, i32, i32), i32>>,
|
||||||
pub dyn_call_vd: Option<Func<'a, (i32, f64)>>,
|
pub dyn_call_vd: Option<Func<'a, (i32, f64)>>,
|
||||||
pub dyn_call_viiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32)>>,
|
pub dyn_call_viiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32)>>,
|
||||||
pub dyn_call_viiiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32)>>,
|
pub dyn_call_viiiiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32)>>,
|
||||||
@ -117,6 +121,7 @@ pub struct EmscriptenData<'a> {
|
|||||||
pub dyn_call_viji: Option<Func<'a, (i32, i32, i32, i32, i32)>>,
|
pub dyn_call_viji: Option<Func<'a, (i32, i32, i32, i32, i32)>>,
|
||||||
pub dyn_call_vijiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32)>>,
|
pub dyn_call_vijiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32)>>,
|
||||||
pub dyn_call_vijj: Option<Func<'a, (i32, i32, i32, i32, i32, i32)>>,
|
pub dyn_call_vijj: Option<Func<'a, (i32, i32, i32, i32, i32, i32)>>,
|
||||||
|
pub dyn_call_viidii: Option<Func<'a, (i32, i32, i32, f64, i32, i32)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EmscriptenData<'a> {
|
impl<'a> EmscriptenData<'a> {
|
||||||
@ -146,6 +151,9 @@ impl<'a> EmscriptenData<'a> {
|
|||||||
let dyn_call_diiii = instance.func("dynCall_diiii").ok();
|
let dyn_call_diiii = instance.func("dynCall_diiii").ok();
|
||||||
let dyn_call_iiiii = instance.func("dynCall_iiiii").ok();
|
let dyn_call_iiiii = instance.func("dynCall_iiiii").ok();
|
||||||
let dyn_call_iiiiii = instance.func("dynCall_iiiiii").ok();
|
let dyn_call_iiiiii = instance.func("dynCall_iiiiii").ok();
|
||||||
|
let dyn_call_iiiiiii = instance.func("dynCall_iiiiiii").ok();
|
||||||
|
let dyn_call_iiiiiiii = instance.func("dynCall_iiiiiiii").ok();
|
||||||
|
let dyn_call_iiiiiiiiii = instance.func("dynCall_iiiiiiiiii").ok();
|
||||||
let dyn_call_vd = instance.func("dynCall_vd").ok();
|
let dyn_call_vd = instance.func("dynCall_vd").ok();
|
||||||
let dyn_call_viiiii = instance.func("dynCall_viiiii").ok();
|
let dyn_call_viiiii = instance.func("dynCall_viiiii").ok();
|
||||||
let dyn_call_viiiiii = instance.func("dynCall_viiiiii").ok();
|
let dyn_call_viiiiii = instance.func("dynCall_viiiiii").ok();
|
||||||
@ -168,6 +176,7 @@ impl<'a> EmscriptenData<'a> {
|
|||||||
let dyn_call_viji = instance.func("dynCall_viji").ok();
|
let dyn_call_viji = instance.func("dynCall_viji").ok();
|
||||||
let dyn_call_vijiii = instance.func("dynCall_vijiii").ok();
|
let dyn_call_vijiii = instance.func("dynCall_vijiii").ok();
|
||||||
let dyn_call_vijj = instance.func("dynCall_vijj").ok();
|
let dyn_call_vijj = instance.func("dynCall_vijj").ok();
|
||||||
|
let dyn_call_viidii = instance.func("dynCall_viidii").ok();
|
||||||
|
|
||||||
EmscriptenData {
|
EmscriptenData {
|
||||||
malloc,
|
malloc,
|
||||||
@ -191,6 +200,9 @@ impl<'a> EmscriptenData<'a> {
|
|||||||
dyn_call_diiii,
|
dyn_call_diiii,
|
||||||
dyn_call_iiiii,
|
dyn_call_iiiii,
|
||||||
dyn_call_iiiiii,
|
dyn_call_iiiiii,
|
||||||
|
dyn_call_iiiiiii,
|
||||||
|
dyn_call_iiiiiiii,
|
||||||
|
dyn_call_iiiiiiiiii,
|
||||||
dyn_call_vd,
|
dyn_call_vd,
|
||||||
dyn_call_viiiii,
|
dyn_call_viiiii,
|
||||||
dyn_call_viiiiii,
|
dyn_call_viiiiii,
|
||||||
@ -213,6 +225,7 @@ impl<'a> EmscriptenData<'a> {
|
|||||||
dyn_call_viji,
|
dyn_call_viji,
|
||||||
dyn_call_vijiii,
|
dyn_call_vijiii,
|
||||||
dyn_call_vijj,
|
dyn_call_vijj,
|
||||||
|
dyn_call_viidii,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -415,9 +428,20 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"___lock" => func!(crate::lock::___lock),
|
"___lock" => func!(crate::lock::___lock),
|
||||||
"___unlock" => func!(crate::lock::___unlock),
|
"___unlock" => func!(crate::lock::___unlock),
|
||||||
"___wait" => func!(crate::lock::___wait),
|
"___wait" => func!(crate::lock::___wait),
|
||||||
|
"_flock" => func!(crate::lock::_flock),
|
||||||
|
"_chroot" => func!(crate::io::chroot),
|
||||||
|
"_getprotobyname" => func!(crate::io::getprotobyname),
|
||||||
|
"_getprotobynumber" => func!(crate::io::getprotobynumber),
|
||||||
|
"_getpwuid" => func!(crate::io::getpwuid),
|
||||||
|
"_sigdelset" => func!(crate::io::sigdelset),
|
||||||
|
"_sigfillset" => func!(crate::io::sigfillset),
|
||||||
|
"_tzset" => func!(crate::io::tzset),
|
||||||
|
"_strptime" => func!(crate::io::strptime),
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
"_execvp" => func!(crate::exec::execvp),
|
"_execvp" => func!(crate::exec::execvp),
|
||||||
|
"_execl" => func!(crate::exec::execl),
|
||||||
|
"_execle" => func!(crate::exec::execle),
|
||||||
|
|
||||||
// exit
|
// exit
|
||||||
"__exit" => func!(crate::exit::exit),
|
"__exit" => func!(crate::exit::exit),
|
||||||
@ -457,13 +481,17 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"___syscall4" => func!(crate::syscalls::___syscall4),
|
"___syscall4" => func!(crate::syscalls::___syscall4),
|
||||||
"___syscall5" => func!(crate::syscalls::___syscall5),
|
"___syscall5" => func!(crate::syscalls::___syscall5),
|
||||||
"___syscall6" => func!(crate::syscalls::___syscall6),
|
"___syscall6" => func!(crate::syscalls::___syscall6),
|
||||||
|
"___syscall9" => func!(crate::syscalls::___syscall9),
|
||||||
"___syscall10" => func!(crate::syscalls::___syscall10),
|
"___syscall10" => func!(crate::syscalls::___syscall10),
|
||||||
"___syscall12" => func!(crate::syscalls::___syscall12),
|
"___syscall12" => func!(crate::syscalls::___syscall12),
|
||||||
"___syscall15" => func!(crate::syscalls::___syscall15),
|
"___syscall15" => func!(crate::syscalls::___syscall15),
|
||||||
"___syscall20" => func!(crate::syscalls::___syscall20),
|
"___syscall20" => func!(crate::syscalls::___syscall20),
|
||||||
|
"___syscall33" => func!(crate::syscalls::___syscall33),
|
||||||
|
"___syscall34" => func!(crate::syscalls::___syscall34),
|
||||||
"___syscall39" => func!(crate::syscalls::___syscall39),
|
"___syscall39" => func!(crate::syscalls::___syscall39),
|
||||||
"___syscall38" => func!(crate::syscalls::___syscall38),
|
"___syscall38" => func!(crate::syscalls::___syscall38),
|
||||||
"___syscall40" => func!(crate::syscalls::___syscall40),
|
"___syscall40" => func!(crate::syscalls::___syscall40),
|
||||||
|
"___syscall41" => func!(crate::syscalls::___syscall41),
|
||||||
"___syscall42" => func!(crate::syscalls::___syscall42),
|
"___syscall42" => func!(crate::syscalls::___syscall42),
|
||||||
"___syscall54" => func!(crate::syscalls::___syscall54),
|
"___syscall54" => func!(crate::syscalls::___syscall54),
|
||||||
"___syscall57" => func!(crate::syscalls::___syscall57),
|
"___syscall57" => func!(crate::syscalls::___syscall57),
|
||||||
@ -472,6 +500,8 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"___syscall64" => func!(crate::syscalls::___syscall64),
|
"___syscall64" => func!(crate::syscalls::___syscall64),
|
||||||
"___syscall66" => func!(crate::syscalls::___syscall66),
|
"___syscall66" => func!(crate::syscalls::___syscall66),
|
||||||
"___syscall75" => func!(crate::syscalls::___syscall75),
|
"___syscall75" => func!(crate::syscalls::___syscall75),
|
||||||
|
"___syscall77" => func!(crate::syscalls::___syscall77),
|
||||||
|
"___syscall83" => func!(crate::syscalls::___syscall83),
|
||||||
"___syscall85" => func!(crate::syscalls::___syscall85),
|
"___syscall85" => func!(crate::syscalls::___syscall85),
|
||||||
"___syscall91" => func!(crate::syscalls::___syscall191),
|
"___syscall91" => func!(crate::syscalls::___syscall191),
|
||||||
"___syscall94" => func!(crate::syscalls::___syscall194),
|
"___syscall94" => func!(crate::syscalls::___syscall194),
|
||||||
@ -495,11 +525,15 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"___syscall195" => func!(crate::syscalls::___syscall195),
|
"___syscall195" => func!(crate::syscalls::___syscall195),
|
||||||
"___syscall196" => func!(crate::syscalls::___syscall196),
|
"___syscall196" => func!(crate::syscalls::___syscall196),
|
||||||
"___syscall197" => func!(crate::syscalls::___syscall197),
|
"___syscall197" => func!(crate::syscalls::___syscall197),
|
||||||
|
"___syscall198" => func!(crate::syscalls::___syscall198),
|
||||||
"___syscall199" => func!(crate::syscalls::___syscall199),
|
"___syscall199" => func!(crate::syscalls::___syscall199),
|
||||||
|
"___syscall200" => func!(crate::syscalls::___syscall200),
|
||||||
"___syscall201" => func!(crate::syscalls::___syscall201),
|
"___syscall201" => func!(crate::syscalls::___syscall201),
|
||||||
"___syscall202" => func!(crate::syscalls::___syscall202),
|
"___syscall202" => func!(crate::syscalls::___syscall202),
|
||||||
|
"___syscall205" => func!(crate::syscalls::___syscall205),
|
||||||
"___syscall207" => func!(crate::syscalls::___syscall207),
|
"___syscall207" => func!(crate::syscalls::___syscall207),
|
||||||
"___syscall212" => func!(crate::syscalls::___syscall212),
|
"___syscall212" => func!(crate::syscalls::___syscall212),
|
||||||
|
"___syscall219" => func!(crate::syscalls::___syscall219),
|
||||||
"___syscall220" => func!(crate::syscalls::___syscall220),
|
"___syscall220" => func!(crate::syscalls::___syscall220),
|
||||||
"___syscall221" => func!(crate::syscalls::___syscall221),
|
"___syscall221" => func!(crate::syscalls::___syscall221),
|
||||||
"___syscall268" => func!(crate::syscalls::___syscall268),
|
"___syscall268" => func!(crate::syscalls::___syscall268),
|
||||||
@ -534,6 +568,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"_setgroups" => func!(crate::process::_setgroups),
|
"_setgroups" => func!(crate::process::_setgroups),
|
||||||
"_setitimer" => func!(crate::process::_setitimer),
|
"_setitimer" => func!(crate::process::_setitimer),
|
||||||
"_usleep" => func!(crate::process::_usleep),
|
"_usleep" => func!(crate::process::_usleep),
|
||||||
|
"_nanosleep" => func!(crate::process::_nanosleep),
|
||||||
"_utimes" => func!(crate::process::_utimes),
|
"_utimes" => func!(crate::process::_utimes),
|
||||||
"_waitpid" => func!(crate::process::_waitpid),
|
"_waitpid" => func!(crate::process::_waitpid),
|
||||||
|
|
||||||
@ -581,11 +616,14 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64),
|
"_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64),
|
||||||
"_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32),
|
"_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32),
|
||||||
"_llvm_log2_f32" => func!(crate::math::_llvm_log2_f64),
|
"_llvm_log2_f32" => func!(crate::math::_llvm_log2_f64),
|
||||||
|
"_llvm_sin_f64" => func!(crate::math::_llvm_sin_f64),
|
||||||
|
"_llvm_cos_f64" => func!(crate::math::_llvm_cos_f64),
|
||||||
"_emscripten_random" => func!(crate::math::_emscripten_random),
|
"_emscripten_random" => func!(crate::math::_emscripten_random),
|
||||||
|
|
||||||
// Jump
|
// Jump
|
||||||
"__setjmp" => func!(crate::jmp::__setjmp),
|
"__setjmp" => func!(crate::jmp::__setjmp),
|
||||||
"__longjmp" => func!(crate::jmp::__longjmp),
|
"__longjmp" => func!(crate::jmp::__longjmp),
|
||||||
|
"_longjmp" => func!(crate::jmp::__longjmp),
|
||||||
|
|
||||||
// Linking
|
// Linking
|
||||||
"_dlclose" => func!(crate::linking::_dlclose),
|
"_dlclose" => func!(crate::linking::_dlclose),
|
||||||
@ -597,6 +635,11 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"setTempRet0" => func!(crate::emscripten_target::setTempRet0),
|
"setTempRet0" => func!(crate::emscripten_target::setTempRet0),
|
||||||
"getTempRet0" => func!(crate::emscripten_target::getTempRet0),
|
"getTempRet0" => func!(crate::emscripten_target::getTempRet0),
|
||||||
"nullFunc_ji" => func!(crate::emscripten_target::nullFunc_ji),
|
"nullFunc_ji" => func!(crate::emscripten_target::nullFunc_ji),
|
||||||
|
"nullFunc_d" => func!(crate::emscripten_target::nullFunc_d),
|
||||||
|
"nullFunc_viidii" => func!(crate::emscripten_target::nullFunc_viidii),
|
||||||
|
"nullFunc_iiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiii),
|
||||||
|
"nullFunc_iiiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiiii),
|
||||||
|
"nullFunc_iiiiiiiiii" => func!(crate::emscripten_target::nullFunc_iiiiiiiiii),
|
||||||
"invoke_i" => func!(crate::emscripten_target::invoke_i),
|
"invoke_i" => func!(crate::emscripten_target::invoke_i),
|
||||||
"invoke_ii" => func!(crate::emscripten_target::invoke_ii),
|
"invoke_ii" => func!(crate::emscripten_target::invoke_ii),
|
||||||
"invoke_iii" => func!(crate::emscripten_target::invoke_iii),
|
"invoke_iii" => func!(crate::emscripten_target::invoke_iii),
|
||||||
@ -628,7 +671,12 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"_pthread_mutexattr_settype" => func!(crate::emscripten_target::_pthread_mutexattr_settype),
|
"_pthread_mutexattr_settype" => func!(crate::emscripten_target::_pthread_mutexattr_settype),
|
||||||
"_pthread_rwlock_rdlock" => func!(crate::emscripten_target::_pthread_rwlock_rdlock),
|
"_pthread_rwlock_rdlock" => func!(crate::emscripten_target::_pthread_rwlock_rdlock),
|
||||||
"_pthread_rwlock_unlock" => func!(crate::emscripten_target::_pthread_rwlock_unlock),
|
"_pthread_rwlock_unlock" => func!(crate::emscripten_target::_pthread_rwlock_unlock),
|
||||||
|
"_pthread_setcancelstate" => func!(crate::emscripten_target::_pthread_setcancelstate),
|
||||||
"___gxx_personality_v0" => func!(crate::emscripten_target::___gxx_personality_v0),
|
"___gxx_personality_v0" => func!(crate::emscripten_target::___gxx_personality_v0),
|
||||||
|
"_getdtablesize" => func!(crate::emscripten_target::_getdtablesize),
|
||||||
|
"_gethostbyaddr" => func!(crate::emscripten_target::_gethostbyaddr),
|
||||||
|
"_gethostbyname_r" => func!(crate::emscripten_target::_gethostbyname_r),
|
||||||
|
"_getloadavg" => func!(crate::emscripten_target::_getloadavg),
|
||||||
// round 2
|
// round 2
|
||||||
"nullFunc_dii" => func!(crate::emscripten_target::nullFunc_dii),
|
"nullFunc_dii" => func!(crate::emscripten_target::nullFunc_dii),
|
||||||
"nullFunc_diiii" => func!(crate::emscripten_target::nullFunc_diiii),
|
"nullFunc_diiii" => func!(crate::emscripten_target::nullFunc_diiii),
|
||||||
@ -655,6 +703,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"invoke_diiii" => func!(crate::emscripten_target::invoke_diiii),
|
"invoke_diiii" => func!(crate::emscripten_target::invoke_diiii),
|
||||||
"invoke_iiiii" => func!(crate::emscripten_target::invoke_iiiii),
|
"invoke_iiiii" => func!(crate::emscripten_target::invoke_iiiii),
|
||||||
"invoke_iiiiii" => func!(crate::emscripten_target::invoke_iiiiii),
|
"invoke_iiiiii" => func!(crate::emscripten_target::invoke_iiiiii),
|
||||||
|
"invoke_iiiiiii" => func!(crate::emscripten_target::invoke_iiiiiii),
|
||||||
|
"invoke_iiiiiiii" => func!(crate::emscripten_target::invoke_iiiiiiii),
|
||||||
|
"invoke_iiiiiiiiii" => func!(crate::emscripten_target::invoke_iiiiiiiiii),
|
||||||
"invoke_vd" => func!(crate::emscripten_target::invoke_vd),
|
"invoke_vd" => func!(crate::emscripten_target::invoke_vd),
|
||||||
"invoke_viiiii" => func!(crate::emscripten_target::invoke_viiiii),
|
"invoke_viiiii" => func!(crate::emscripten_target::invoke_viiiii),
|
||||||
"invoke_viiiiii" => func!(crate::emscripten_target::invoke_viiiiii),
|
"invoke_viiiiii" => func!(crate::emscripten_target::invoke_viiiiii),
|
||||||
@ -677,6 +728,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
"invoke_viji" => func!(crate::emscripten_target::invoke_viji),
|
"invoke_viji" => func!(crate::emscripten_target::invoke_viji),
|
||||||
"invoke_vijiii" => func!(crate::emscripten_target::invoke_vijiii),
|
"invoke_vijiii" => func!(crate::emscripten_target::invoke_vijiii),
|
||||||
"invoke_vijj" => func!(crate::emscripten_target::invoke_vijj),
|
"invoke_vijj" => func!(crate::emscripten_target::invoke_vijj),
|
||||||
|
"invoke_viidii" => func!(crate::emscripten_target::invoke_viidii),
|
||||||
},
|
},
|
||||||
"global" => {
|
"global" => {
|
||||||
"NaN" => Global::new(Value::F64(f64::NAN)),
|
"NaN" => Global::new(Value::F64(f64::NAN)),
|
||||||
@ -684,6 +736,8 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
},
|
},
|
||||||
"global.Math" => {
|
"global.Math" => {
|
||||||
"pow" => func!(crate::math::pow),
|
"pow" => func!(crate::math::pow),
|
||||||
|
"exp" => func!(crate::math::exp),
|
||||||
|
"log" => func!(crate::math::log),
|
||||||
},
|
},
|
||||||
"asm2wasm" => {
|
"asm2wasm" => {
|
||||||
"f64-rem" => func!(crate::math::f64_rem),
|
"f64-rem" => func!(crate::math::f64_rem),
|
||||||
|
@ -15,3 +15,8 @@ pub fn ___unlock(_ctx: &mut Ctx, _what: c_int) {
|
|||||||
pub fn ___wait(_ctx: &mut Ctx, _which: u32, _varargs: u32, _three: u32, _four: u32) {
|
pub fn ___wait(_ctx: &mut Ctx, _which: u32, _varargs: u32, _three: u32, _four: u32) {
|
||||||
debug!("emscripten::___wait");
|
debug!("emscripten::___wait");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _flock(_ctx: &mut Ctx, _fd: u32, _op: u32) -> u32 {
|
||||||
|
debug!("emscripten::_flock");
|
||||||
|
0
|
||||||
|
}
|
||||||
|
@ -12,6 +12,18 @@ pub fn _llvm_log2_f64(_ctx: &mut Ctx, value: f64) -> f64 {
|
|||||||
value.log2()
|
value.log2()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// emscripten: _llvm_sin_f64
|
||||||
|
pub fn _llvm_sin_f64(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||||
|
debug!("emscripten::_llvm_sin_f64");
|
||||||
|
value.sin()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// emscripten: _llvm_cos_f64
|
||||||
|
pub fn _llvm_cos_f64(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||||
|
debug!("emscripten::_llvm_cos_f64");
|
||||||
|
value.cos()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn _llvm_log10_f32(_ctx: &mut Ctx, _value: f64) -> f64 {
|
pub fn _llvm_log10_f32(_ctx: &mut Ctx, _value: f64) -> f64 {
|
||||||
debug!("emscripten::_llvm_log10_f32");
|
debug!("emscripten::_llvm_log10_f32");
|
||||||
-1.0
|
-1.0
|
||||||
@ -37,3 +49,13 @@ pub fn f64_rem(_ctx: &mut Ctx, x: f64, y: f64) -> f64 {
|
|||||||
pub fn pow(_ctx: &mut Ctx, x: f64, y: f64) -> f64 {
|
pub fn pow(_ctx: &mut Ctx, x: f64, y: f64) -> f64 {
|
||||||
x.powf(y)
|
x.powf(y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// emscripten: global.Math exp
|
||||||
|
pub fn exp(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||||
|
value.exp()
|
||||||
|
}
|
||||||
|
|
||||||
|
// emscripten: global.Math log
|
||||||
|
pub fn log(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||||
|
value.ln()
|
||||||
|
}
|
||||||
|
@ -121,6 +121,11 @@ pub fn _usleep(_ctx: &mut Ctx, _one: i32) -> i32 {
|
|||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _nanosleep(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
|
debug!("emscripten::_nanosleep");
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
|
||||||
pub fn _utimes(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
pub fn _utimes(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
debug!("emscripten::_utimes");
|
debug!("emscripten::_utimes");
|
||||||
-1
|
-1
|
||||||
|
@ -3,6 +3,7 @@ use crate::varargs::VarArgs;
|
|||||||
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
|
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
|
||||||
use libc::{
|
use libc::{
|
||||||
accept,
|
accept,
|
||||||
|
access,
|
||||||
bind,
|
bind,
|
||||||
c_char,
|
c_char,
|
||||||
c_int,
|
c_int,
|
||||||
@ -10,6 +11,7 @@ use libc::{
|
|||||||
chown,
|
chown,
|
||||||
// fcntl, setsockopt, getppid
|
// fcntl, setsockopt, getppid
|
||||||
connect,
|
connect,
|
||||||
|
dup,
|
||||||
dup2,
|
dup2,
|
||||||
fchmod,
|
fchmod,
|
||||||
fchown,
|
fchown,
|
||||||
@ -17,18 +19,23 @@ use libc::{
|
|||||||
// ENOTTY,
|
// ENOTTY,
|
||||||
fsync,
|
fsync,
|
||||||
getgid,
|
getgid,
|
||||||
|
getgroups,
|
||||||
getpeername,
|
getpeername,
|
||||||
|
getrusage,
|
||||||
getsockname,
|
getsockname,
|
||||||
getsockopt,
|
getsockopt,
|
||||||
gid_t,
|
gid_t,
|
||||||
in_addr_t,
|
in_addr_t,
|
||||||
in_port_t,
|
in_port_t,
|
||||||
ioctl,
|
ioctl,
|
||||||
|
lchown,
|
||||||
|
link,
|
||||||
// iovec,
|
// iovec,
|
||||||
listen,
|
listen,
|
||||||
mkdir,
|
mkdir,
|
||||||
mode_t,
|
mode_t,
|
||||||
msghdr,
|
msghdr,
|
||||||
|
nice,
|
||||||
open,
|
open,
|
||||||
pid_t,
|
pid_t,
|
||||||
pread,
|
pread,
|
||||||
@ -45,9 +52,11 @@ use libc::{
|
|||||||
sendto,
|
sendto,
|
||||||
setpgid,
|
setpgid,
|
||||||
setsockopt,
|
setsockopt,
|
||||||
|
size_t,
|
||||||
sockaddr,
|
sockaddr,
|
||||||
socket,
|
socket,
|
||||||
socklen_t,
|
socklen_t,
|
||||||
|
symlink,
|
||||||
uid_t,
|
uid_t,
|
||||||
uname,
|
uname,
|
||||||
utsname,
|
utsname,
|
||||||
@ -70,10 +79,11 @@ use std::mem;
|
|||||||
#[link(name = "c")]
|
#[link(name = "c")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn wait4(pid: pid_t, status: *mut c_int, options: c_int, rusage: *mut rusage) -> pid_t;
|
pub fn wait4(pid: pid_t, status: *mut c_int, options: c_int, rusage: *mut rusage) -> pid_t;
|
||||||
|
pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
use libc::wait4;
|
use libc::{madvise, wait4};
|
||||||
|
|
||||||
// Another conditional constant for name resolution: Macos et iOS use
|
// Another conditional constant for name resolution: Macos et iOS use
|
||||||
// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket.
|
// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket.
|
||||||
@ -99,6 +109,89 @@ pub fn ___syscall5(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
|||||||
fd
|
fd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// link
|
||||||
|
pub fn ___syscall9(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall9 (link) {}", _which);
|
||||||
|
|
||||||
|
let oldname: c_int = varargs.get(ctx);
|
||||||
|
let newname: c_int = varargs.get(ctx);
|
||||||
|
let oldname_ptr = emscripten_memory_pointer!(ctx.memory(0), oldname) as *const i8;
|
||||||
|
let newname_ptr = emscripten_memory_pointer!(ctx.memory(0), newname) as *const i8;
|
||||||
|
let result = unsafe { link(oldname_ptr, newname_ptr) };
|
||||||
|
debug!(
|
||||||
|
"=> oldname: {}, newname: {}, result: {}",
|
||||||
|
unsafe { std::ffi::CStr::from_ptr(oldname_ptr).to_str().unwrap() },
|
||||||
|
unsafe { std::ffi::CStr::from_ptr(newname_ptr).to_str().unwrap() },
|
||||||
|
result,
|
||||||
|
);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getrusage
|
||||||
|
pub fn ___syscall77(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall77 (getrusage) {}", _which);
|
||||||
|
|
||||||
|
let resource: c_int = varargs.get(ctx);
|
||||||
|
let rusage_ptr: c_int = varargs.get(ctx);
|
||||||
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
|
let rusage = emscripten_memory_pointer!(ctx.memory(0), rusage_ptr) as *mut rusage;
|
||||||
|
assert_eq!(8, mem::align_of_val(&rusage));
|
||||||
|
unsafe { getrusage(resource, rusage) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// symlink
|
||||||
|
pub fn ___syscall83(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall83 (symlink) {}", _which);
|
||||||
|
|
||||||
|
let path1_ptr: c_int = varargs.get(ctx);
|
||||||
|
let path2_ptr: c_int = varargs.get(ctx);
|
||||||
|
let path1 = emscripten_memory_pointer!(ctx.memory(0), path1_ptr) as *mut i8;
|
||||||
|
let path2 = emscripten_memory_pointer!(ctx.memory(0), path2_ptr) as *mut i8;
|
||||||
|
let result = unsafe { symlink(path1, path2) };
|
||||||
|
debug!(
|
||||||
|
"=> path1: {}, path2: {}, result: {}",
|
||||||
|
unsafe { std::ffi::CStr::from_ptr(path1).to_str().unwrap() },
|
||||||
|
unsafe { std::ffi::CStr::from_ptr(path2).to_str().unwrap() },
|
||||||
|
result,
|
||||||
|
);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// lchown
|
||||||
|
pub fn ___syscall198(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall198 (lchown) {}", _which);
|
||||||
|
let path: c_int = varargs.get(ctx);
|
||||||
|
let uid: uid_t = varargs.get(ctx);
|
||||||
|
let gid: gid_t = varargs.get(ctx);
|
||||||
|
let path_ptr = emscripten_memory_pointer!(ctx.memory(0), path) as *const i8;
|
||||||
|
let result = unsafe { lchown(path_ptr, uid, gid) };
|
||||||
|
debug!(
|
||||||
|
"=> path: {}, uid: {}, gid: {}, result: {}",
|
||||||
|
unsafe { std::ffi::CStr::from_ptr(path_ptr).to_str().unwrap() },
|
||||||
|
uid,
|
||||||
|
gid,
|
||||||
|
result,
|
||||||
|
);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getgroups
|
||||||
|
pub fn ___syscall205(ctx: &mut Ctx, _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);
|
||||||
|
|
||||||
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
|
let gid_ptr = emscripten_memory_pointer!(ctx.memory(0), groups) as *mut gid_t;
|
||||||
|
assert_eq!(4, mem::align_of_val(&gid_ptr));
|
||||||
|
let result = unsafe { getgroups(ngroups_max, gid_ptr) };
|
||||||
|
debug!(
|
||||||
|
"=> ngroups_max: {}, gid_ptr: {:?}, result: {}",
|
||||||
|
ngroups_max, gid_ptr, result,
|
||||||
|
);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
// chown
|
// chown
|
||||||
pub fn ___syscall212(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall212(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall212 (chown) {}", _which);
|
debug!("emscripten::___syscall212 (chown) {}", _which);
|
||||||
@ -112,6 +205,41 @@ pub fn ___syscall212(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
|
|||||||
unsafe { chown(pathname_addr, owner, group) }
|
unsafe { chown(pathname_addr, owner, group) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// madvise
|
||||||
|
pub fn ___syscall219(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall212 (chown) {}", _which);
|
||||||
|
|
||||||
|
let addr_ptr: c_int = varargs.get(ctx);
|
||||||
|
let len: usize = varargs.get(ctx);
|
||||||
|
let advice: c_int = varargs.get(ctx);
|
||||||
|
|
||||||
|
let addr = emscripten_memory_pointer!(ctx.memory(0), addr_ptr) as *mut c_void;
|
||||||
|
|
||||||
|
unsafe { madvise(addr, len, advice) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// access
|
||||||
|
pub fn ___syscall33(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall33 (access) {}", _which);
|
||||||
|
let path_ptr: c_int = varargs.get(ctx);
|
||||||
|
let amode: c_int = varargs.get(ctx);
|
||||||
|
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
|
||||||
|
let result = unsafe { access(path, amode) };
|
||||||
|
debug!(
|
||||||
|
"=> path: {}, result: {}",
|
||||||
|
unsafe { std::ffi::CStr::from_ptr(path).to_str().unwrap() },
|
||||||
|
result
|
||||||
|
);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// nice
|
||||||
|
pub fn ___syscall34(ctx: &mut Ctx, _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
|
// mkdir
|
||||||
pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall39 (mkdir) {}", _which);
|
debug!("emscripten::___syscall39 (mkdir) {}", _which);
|
||||||
@ -121,6 +249,19 @@ pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
|
|||||||
unsafe { mkdir(pathname_addr, mode as _) }
|
unsafe { mkdir(pathname_addr, mode as _) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// dup
|
||||||
|
pub fn ___syscall41(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall41 (dup) {}", _which);
|
||||||
|
let fd: c_int = varargs.get(ctx);
|
||||||
|
unsafe { dup(fd) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getgid
|
||||||
|
pub fn ___syscall200(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
|
debug!("emscripten::___syscall200 (getgid)");
|
||||||
|
unsafe { getgid() as i32 }
|
||||||
|
}
|
||||||
|
|
||||||
// getgid
|
// getgid
|
||||||
pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
debug!("emscripten::___syscall201 (getgid)");
|
debug!("emscripten::___syscall201 (getgid)");
|
||||||
@ -531,6 +672,7 @@ pub fn ___syscall114(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_
|
|||||||
let options: c_int = varargs.get(ctx);
|
let options: c_int = varargs.get(ctx);
|
||||||
let rusage: u32 = varargs.get(ctx);
|
let rusage: u32 = varargs.get(ctx);
|
||||||
let status_addr = emscripten_memory_pointer!(ctx.memory(0), status) as *mut c_int;
|
let status_addr = emscripten_memory_pointer!(ctx.memory(0), status) as *mut c_int;
|
||||||
|
|
||||||
let rusage_addr = emscripten_memory_pointer!(ctx.memory(0), rusage) as *mut rusage;
|
let rusage_addr = emscripten_memory_pointer!(ctx.memory(0), rusage) as *mut rusage;
|
||||||
let res = unsafe { wait4(pid, status_addr, options, rusage_addr) };
|
let res = unsafe { wait4(pid, status_addr, options, rusage_addr) };
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -58,6 +58,12 @@ 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 {
|
||||||
|
debug!("emscripten::___syscall9 (link) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
// chown
|
// chown
|
||||||
pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall212 (chown) {}", which);
|
debug!("emscripten::___syscall212 (chown) {}", which);
|
||||||
@ -66,6 +72,18 @@ pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i
|
|||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// access
|
||||||
|
pub fn ___syscall33(_ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall33 (access) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// nice
|
||||||
|
pub fn ___syscall34(_ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall34 (nice) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
// mkdir
|
// mkdir
|
||||||
pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall39 (mkdir) {}", which);
|
debug!("emscripten::___syscall39 (mkdir) {}", which);
|
||||||
@ -76,6 +94,36 @@ pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int
|
|||||||
unsafe { mkdir(pathname_addr) }
|
unsafe { mkdir(pathname_addr) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// dup
|
||||||
|
pub fn ___syscall41(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall41 (dup) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getrusage
|
||||||
|
pub fn ___syscall77(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall77 (getrusage) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// symlink
|
||||||
|
pub fn ___syscall83(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall83 (symlink) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// lchown
|
||||||
|
pub fn ___syscall198(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall198 (lchown) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getgid
|
||||||
|
pub fn ___syscall200(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
|
debug!("emscripten::___syscall200 (getgid)");
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
// getgid
|
// getgid
|
||||||
pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||||
debug!("emscripten::___syscall201 (getgid)");
|
debug!("emscripten::___syscall201 (getgid)");
|
||||||
@ -89,6 +137,18 @@ pub fn ___syscall202(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
|||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getgroups
|
||||||
|
pub fn ___syscall205(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall205 (getgroups) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// madvise
|
||||||
|
pub fn ___syscall219(_ctx: &mut Ctx, _which: c_int, _varargs: VarArgs) -> c_int {
|
||||||
|
debug!("emscripten::___syscall212 (chown) {}", _which);
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
/// dup3
|
/// dup3
|
||||||
pub fn ___syscall330(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
pub fn ___syscall330(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
||||||
debug!("emscripten::___syscall330 (dup3)");
|
debug!("emscripten::___syscall330 (dup3)");
|
||||||
|
Reference in New Issue
Block a user