optimize mroe

This commit is contained in:
Mackenzie Clark 2019-03-21 12:22:18 -07:00
parent 92e1fce83a
commit 65c4c12942
2 changed files with 2 additions and 37 deletions

View File

@ -14,7 +14,7 @@ pub use vfs::*;
/// NOTE: TODO: These syscalls only support wasm_32 for now because they assume offsets are u32
/// Syscall list: https://www.cs.utexas.edu/~bismith/test/syscalls/syscalls32.html
use libc::{c_int, dup2, fcntl, pid_t, rusage, setpgid, uname, utsname, EINVAL, F_GETFD, F_SETFD};
use libc::{c_int, pid_t, rusage, setpgid, uname, utsname};
use wasmer_runtime_core::vm::Ctx;
// Linking to functions that are not provided by rust libc
@ -103,37 +103,3 @@ pub fn ___syscall212(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
unsafe { libc::chown(pathname_addr, owner, group) }
}
/// dup3
pub fn ___syscall330(ctx: &mut Ctx, _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);
let newfd: c_int = varargs.get(ctx);
let flags: c_int = varargs.get(ctx);
if oldfd == newfd {
return EINVAL;
}
let res = unsafe { dup2(oldfd, newfd) };
// Set flags on newfd (https://www.gnu.org/software/libc/manual/html_node/Descriptor-Flags.html)
let mut old_flags = unsafe { fcntl(newfd, F_GETFD, 0) };
if old_flags > 0 {
old_flags |= flags;
} else if old_flags == 0 {
old_flags &= !flags;
}
unsafe {
fcntl(newfd, F_SETFD, old_flags);
}
debug!(
"=> oldfd: {}, newfd: {}, flags: {} = pid: {}",
oldfd, newfd, flags, res
);
res
}

View File

@ -114,7 +114,7 @@ pub fn ___syscall15(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
0
}
// mkdir
/// mkdir
pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall39 (mkdir vfs) {}", _which);
let pathname: u32 = varargs.get(ctx);
@ -132,7 +132,6 @@ pub fn ___syscall39(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
} else {
-1
};
// debug!("mkdir returns {}", ret);
ret
}