relocate io stubs and add windows syscall stubs

This commit is contained in:
Mark McCaskey 2019-03-25 10:45:02 -07:00
parent e56dfe70c7
commit de0dedc78d
6 changed files with 113 additions and 52 deletions

View File

@ -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!()
}

View File

@ -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
}

View File

@ -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!()
}

View File

@ -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),

View File

@ -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);

View File

@ -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)");