mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Added emscripten _signal, improved chdir implementation
This commit is contained in:
parent
a85e02fe6e
commit
0d3134c9fd
@ -306,6 +306,11 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
|||||||
"_sigaction",
|
"_sigaction",
|
||||||
ImportValue::Func(signal::_sigaction as _),
|
ImportValue::Func(signal::_sigaction as _),
|
||||||
);
|
);
|
||||||
|
import_object.set(
|
||||||
|
"env",
|
||||||
|
"_signal",
|
||||||
|
ImportValue::Func(signal::_signal as _),
|
||||||
|
);
|
||||||
// Memory
|
// Memory
|
||||||
import_object.set(
|
import_object.set(
|
||||||
"env",
|
"env",
|
||||||
|
@ -28,3 +28,8 @@ pub extern "C" fn _sigprocmask() -> i32 {
|
|||||||
debug!("emscripten::_sigprocmask");
|
debug!("emscripten::_sigprocmask");
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub extern "C" fn _signal(sig: u32, _instance: &mut Instance) -> i32 {
|
||||||
|
debug!("emscripten::_signal ({})", sig);
|
||||||
|
0
|
||||||
|
}
|
||||||
|
@ -53,6 +53,7 @@ use libc::{
|
|||||||
select,
|
select,
|
||||||
FIONBIO,
|
FIONBIO,
|
||||||
setpgid,
|
setpgid,
|
||||||
|
chdir
|
||||||
};
|
};
|
||||||
|
|
||||||
/// exit
|
/// exit
|
||||||
@ -134,13 +135,13 @@ pub extern "C" fn ___syscall12(
|
|||||||
) -> c_int {
|
) -> c_int {
|
||||||
debug!("emscripten::___syscall12 (chdir)");
|
debug!("emscripten::___syscall12 (chdir)");
|
||||||
let path_addr: i32 = varargs.get(instance);
|
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_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();
|
let path = std::ffi::CStr::from_ptr(path_ptr);
|
||||||
debug!("=> path: {}", path);
|
let ret = chdir(path_ptr);
|
||||||
path
|
debug!("=> path: {:?}, ret: {}", path, ret);
|
||||||
};
|
ret
|
||||||
0
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getpid
|
// getpid
|
||||||
|
Loading…
Reference in New Issue
Block a user