From de0dedc78d70481efd86dba46da993758da878dc Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Mon, 25 Mar 2019 10:45:02 -0700 Subject: [PATCH] relocate io stubs and add windows syscall stubs --- lib/emscripten/src/io/mod.rs | 44 +++++++++++++++++++ lib/emscripten/src/io/unix.rs | 51 +--------------------- lib/emscripten/src/io/windows.rs | 6 +++ lib/emscripten/src/lib.rs | 2 +- lib/emscripten/src/syscalls/unix.rs | 2 +- lib/emscripten/src/syscalls/windows.rs | 60 ++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 52 deletions(-) diff --git a/lib/emscripten/src/io/mod.rs b/lib/emscripten/src/io/mod.rs index aea5e6fc2..496c2da36 100644 --- a/lib/emscripten/src/io/mod.rs +++ b/lib/emscripten/src/io/mod.rs @@ -9,3 +9,47 @@ pub use self::unix::*; #[cfg(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!() +} diff --git a/lib/emscripten/src/io/unix.rs b/lib/emscripten/src/io/unix.rs index bc8fafbf4..f5a495528 100644 --- a/lib/emscripten/src/io/unix.rs +++ b/lib/emscripten/src/io/unix.rs @@ -18,56 +18,7 @@ pub fn printf(ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 { /// 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) } } - -/// getprotobyname -pub fn getprotobyname(ctx: &mut Ctx, name_ptr: i32) -> i32 { - debug!("emscripten::getprotobyname"); - // TODO: actually do this logic to return correctly - let _name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8; - //unsafe { _getprotobyname(name) as i32 } - 0 -} - -/// getprotobynumber -pub fn getprotobynumber(_ctx: &mut Ctx, _one: i32) -> i32 { - debug!("emscripten::getprotobynumber"); - 0 -} - -/// getpwuid -pub fn getpwuid(_ctx: &mut Ctx, _uid: i32) -> i32 { - debug!("emscripten::getpwuid"); - // TODO: actually do this logic to return correctly - 0 -} - -/// longjmp -pub fn longjmp(_ctx: &mut Ctx, _one: i32, _two: i32) { - debug!("emscripten::longjump"); -} - -/// sigdelset -pub fn sigdelset(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { - debug!("emscripten::sigdelset"); - 0 -} - -/// sigfillset -pub fn sigfillset(_ctx: &mut Ctx, _one: i32) -> i32 { - debug!("emscripten::sigfillset"); - 0 -} - -/// tzset -pub fn tzset(_ctx: &mut Ctx) { - debug!("emscripten::tzset"); -} - -/// strptime -pub fn strptime(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 { - debug!("emscripten::strptime"); - 0 -} diff --git a/lib/emscripten/src/io/windows.rs b/lib/emscripten/src/io/windows.rs index 99c67a0be..bb1484c78 100644 --- a/lib/emscripten/src/io/windows.rs +++ b/lib/emscripten/src/io/windows.rs @@ -32,3 +32,9 @@ pub fn printf(_ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 { // } -1 } + +/// chroot +pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 { + debug!("emscripten::chroot"); + unimplemented!() +} diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index b8eb92ea1..c847a3827 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -433,7 +433,6 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "_getprotobyname" => func!(crate::io::getprotobyname), "_getprotobynumber" => func!(crate::io::getprotobynumber), "_getpwuid" => func!(crate::io::getpwuid), - "_longjmp" => func!(crate::io::longjmp), "_sigdelset" => func!(crate::io::sigdelset), "_sigfillset" => func!(crate::io::sigfillset), "_tzset" => func!(crate::io::tzset), @@ -621,6 +620,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject // Jump "__setjmp" => func!(crate::jmp::__setjmp), "__longjmp" => func!(crate::jmp::__longjmp), + "_longjmp" => func!(crate::jmp::__longjmp), // Linking "_dlclose" => func!(crate::linking::_dlclose), diff --git a/lib/emscripten/src/syscalls/unix.rs b/lib/emscripten/src/syscalls/unix.rs index 264675139..5751003fc 100644 --- a/lib/emscripten/src/syscalls/unix.rs +++ b/lib/emscripten/src/syscalls/unix.rs @@ -135,7 +135,7 @@ pub fn ___syscall77(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int unsafe { getrusage(resource, rusage) } } -/// link +/// symlink pub fn ___syscall83(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall83 (symlink) {}", _which); diff --git a/lib/emscripten/src/syscalls/windows.rs b/lib/emscripten/src/syscalls/windows.rs index b65ca158e..ff72c166a 100644 --- a/lib/emscripten/src/syscalls/windows.rs +++ b/lib/emscripten/src/syscalls/windows.rs @@ -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 pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall212 (chown) {}", which); @@ -66,6 +72,18 @@ pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_i -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 pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int { 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) } } +/// 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 pub fn ___syscall201(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall201 (getgid)"); @@ -89,6 +137,18 @@ pub fn ___syscall202(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { -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 pub fn ___syscall330(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> pid_t { debug!("emscripten::___syscall330 (dup3)");