diff --git a/lib/emscripten/src/env/mod.rs b/lib/emscripten/src/env/mod.rs index 74f6caddc..98bc39dc8 100644 --- a/lib/emscripten/src/env/mod.rs +++ b/lib/emscripten/src/env/mod.rs @@ -10,6 +10,8 @@ pub use self::unix::*; #[cfg(windows)] pub use self::windows::*; +use libc::c_char; + use crate::{allocate_on_stack, EmscriptenData}; use std::os::raw::c_int; use wasmer_runtime_core::vm::Ctx; @@ -113,6 +115,27 @@ pub fn ___assert_fail(_ctx: &mut Ctx, _a: c_int, _b: c_int, _c: c_int, _d: c_int // TODO raise an error } +pub fn _pathconf(ctx: &mut Ctx, path_addr: c_int, name: c_int) -> c_int { + debug!( + "emscripten::_pathconf {} {} - UNIMPLEMENTED", + path_addr, name + ); + let _path = emscripten_memory_pointer!(ctx.memory(0), path_addr) as *const c_char; + match name { + 0 => 32000, + 1 | 2 | 3 => 255, + 4 | 5 | 16 | 17 | 18 => 4096, + 6 | 7 | 20 => 1, + 8 => 0, + 9 | 10 | 11 | 12 | 14 | 15 | 19 => -1, + 13 => 64, + _ => { + // ___setErrNo(22); + -1 + } + } +} + pub fn _fpathconf(_ctx: &mut Ctx, _fildes: c_int, name: c_int) -> c_int { debug!("emscripten::_fpathconf {} {}", _fildes, name); match name { diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index cbc881019..400bcd94f 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -545,7 +545,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "_sysconf" => func!(crate::env::_sysconf), "_getaddrinfo" => func!(crate::env::_getaddrinfo), "_times" => func!(crate::env::_times), - "_pathconf" => func!(crate::env::_fpathconf), + "_pathconf" => func!(crate::env::_pathconf), "_fpathconf" => func!(crate::env::_fpathconf), // Syscalls