Added ___syscall12 and ___syscall192 implementations

This commit is contained in:
Syrus Akbary 2018-11-26 23:28:37 -08:00
parent 4fb01c87ec
commit cf64cc8e04
2 changed files with 46 additions and 1 deletions

View File

@ -254,6 +254,16 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
"___syscall54", "___syscall54",
ImportValue::Func(syscalls::___syscall54 as _), ImportValue::Func(syscalls::___syscall54 as _),
); );
import_object.set(
"env",
"___syscall12",
ImportValue::Func(syscalls::___syscall12 as _),
);
import_object.set(
"env",
"___syscall192",
ImportValue::Func(syscalls::___syscall192 as _),
);
// Process // Process
import_object.set( import_object.set(

View File

@ -451,7 +451,8 @@ pub extern "C" fn ___syscall39(
let mode: u32 = varargs.get(instance); let mode: u32 = varargs.get(instance);
let pathname_addr = instance.memory_offset_addr(0, pathname as usize) as *const i8; let pathname_addr = instance.memory_offset_addr(0, pathname as usize) as *const i8;
unsafe { mkdir(pathname_addr, mode as _) } unsafe { mkdir(pathname_addr, mode as _) };
0
} }
// sys_stat64 // sys_stat64
@ -508,3 +509,37 @@ pub extern "C" fn ___syscall221(
_ => -1, _ => -1,
} }
} }
// chdir
pub extern "C" fn ___syscall12(
_which: c_int,
mut varargs: VarArgs,
instance: &mut Instance,
) -> c_int {
debug!("emscripten::___syscall12");
let path_addr: i32 = varargs.get(instance);
let path = unsafe {
let path_ptr = instance.memory_offset_addr(0, path_addr as usize) as *const i8;
let path = std::ffi::CStr::from_ptr(path_ptr).to_str().unwrap();
debug!("path: {}", path);
path
};
0
}
// mmap2
pub extern "C" fn ___syscall192(
_which: c_int,
mut varargs: VarArgs,
instance: &mut Instance,
) -> c_int {
debug!("emscripten::___syscall192");
let addr: i32 = varargs.get(instance);
let len: i32 = varargs.get(instance);
let prot: i32 = varargs.get(instance);
let flags: i32 = varargs.get(instance);
let fd: i32 = varargs.get(instance);
let off: i32 = varargs.get(instance);
debug!("{} {} {} {} {} {}", addr, len, prot, flags, fd, off);
0
}