Added emscripten _signal, improved chdir implementation

This commit is contained in:
Syrus Akbary 2018-12-01 12:12:04 -08:00
parent a85e02fe6e
commit 0d3134c9fd
3 changed files with 17 additions and 6 deletions

View File

@ -306,6 +306,11 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
"_sigaction",
ImportValue::Func(signal::_sigaction as _),
);
import_object.set(
"env",
"_signal",
ImportValue::Func(signal::_signal as _),
);
// Memory
import_object.set(
"env",

View File

@ -28,3 +28,8 @@ pub extern "C" fn _sigprocmask() -> i32 {
debug!("emscripten::_sigprocmask");
0
}
pub extern "C" fn _signal(sig: u32, _instance: &mut Instance) -> i32 {
debug!("emscripten::_signal ({})", sig);
0
}

View File

@ -53,6 +53,7 @@ use libc::{
select,
FIONBIO,
setpgid,
chdir
};
/// exit
@ -134,13 +135,13 @@ pub extern "C" fn ___syscall12(
) -> c_int {
debug!("emscripten::___syscall12 (chdir)");
let path_addr: i32 = varargs.get(instance);
let _path = unsafe {
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
let path = std::ffi::CStr::from_ptr(path_ptr);
let ret = chdir(path_ptr);
debug!("=> path: {:?}, ret: {}", path, ret);
ret
}
}
// getpid