diff --git a/lib/emscripten/src/env.rs b/lib/emscripten/src/env.rs index 8076d2846..16987b70d 100644 --- a/lib/emscripten/src/env.rs +++ b/lib/emscripten/src/env.rs @@ -188,10 +188,10 @@ pub fn ___build_environment(environ: c_int, ctx: &mut Ctx) { // }; } -pub fn _sysconf(name: c_int, _ctx: &mut Ctx) -> c_long { +pub fn _sysconf(name: c_int, _ctx: &mut Ctx) -> i32 { debug!("emscripten::_sysconf {}", name); // TODO: Implement like emscripten expects regarding memory/page size - unsafe { sysconf(name) } + unsafe { sysconf(name) as i32 } // TODO review i64 } pub fn ___assert_fail(a: c_int, b: c_int, c: c_int, d: c_int, _ctx: &mut Ctx) { diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 235639f89..c46d83524 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -331,8 +331,6 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "DYNAMICTOP_PTR" => Global::new(Value::I32(dynamictop_ptr(STATIC_BUMP) as i32)), "tableBase" => Global::new(Value::I32(0)), "__table_base" => Global::new(Value::I32(0)), - "Infinity" => Global::new(Value::F64(f64::INFINITY)), - "NaN" => Global::new(Value::F64(f64::NAN)), "ABORT" => Global::new(Value::I32(0)), "memoryBase" => Global::new(Value::I32(STATIC_BASE)), "__memory_base" => Global::new(Value::I32(STATIC_BASE)), @@ -441,10 +439,13 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "_execve" => func!(crate::process::_execve), "_kill" => func!(crate::process::_kill), "_llvm_stackrestore" => func!(crate::process::_llvm_stackrestore), + "_llvm_stacksave" => func!(crate::process::_llvm_stacksave), "_raise" => func!(crate::process::_raise), "_sem_init" => func!(crate::process::_sem_init), "_sem_post" => func!(crate::process::_sem_post), "_sem_wait" => func!(crate::process::_sem_wait), + "_getgrent" => func!(crate::process::_getgrent), + "_sched_yield" => func!(crate::process::_sched_yield), "_setgrent" => func!(crate::process::_setgrent), "_setgroups" => func!(crate::process::_setgroups), "_setitimer" => func!(crate::process::_setitimer), @@ -452,6 +453,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "_utimes" => func!(crate::process::_utimes), "_waitpid" => func!(crate::process::_waitpid), + // Signal "_sigemptyset" => func!(crate::signal::_sigemptyset), "_sigaddset" => func!(crate::signal::_sigaddset), @@ -505,6 +507,10 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "_dlsym" => func!(crate::linking::_dlsym), }, + "global" => { + "NaN" => Global::new(Value::F64(f64::NAN)), + "Infinity" => Global::new(Value::F64(f64::INFINITY)), + }, "math" => { "pow" => func!(crate::math::pow), }, diff --git a/lib/emscripten/src/process.rs b/lib/emscripten/src/process.rs index c87715ce9..ec4fbc43f 100644 --- a/lib/emscripten/src/process.rs +++ b/lib/emscripten/src/process.rs @@ -57,6 +57,16 @@ pub fn _kill(_one: i32, _two: i32, _ctx: &mut Ctx) -> i32 { -1 } +pub fn _sched_yield(_ctx: &mut Ctx) -> i32 { + debug!("emscripten::_sched_yield"); + -1 +} + +pub fn _llvm_stacksave(_ctx: &mut Ctx) -> i32 { + debug!("emscripten::_llvm_stacksave"); + -1 +} + pub fn _llvm_stackrestore(_one: i32, _ctx: &mut Ctx) { debug!("emscripten::_llvm_stackrestore"); } @@ -81,6 +91,12 @@ pub fn _sem_wait(_one: i32, _ctx: &mut Ctx) -> i32 { -1 } +#[allow(clippy::cast_ptr_alignment)] +pub fn _getgrent(ctx: &mut Ctx) -> c_int { + debug!("emscripten::_getgrent {}", name_ptr); + -1 +} + pub fn _setgrent(_ctx: &mut Ctx) { debug!("emscripten::_setgrent"); } diff --git a/lib/emscripten/src/time.rs b/lib/emscripten/src/time.rs index be5369fb2..afa29a2c4 100644 --- a/lib/emscripten/src/time.rs +++ b/lib/emscripten/src/time.rs @@ -269,12 +269,12 @@ pub fn _localtime_r(time_p: u32, result: u32, ctx: &mut Ctx) -> c_int { /// emscripten: _time #[allow(clippy::cast_ptr_alignment)] -pub fn _time(time_p: u32, ctx: &mut Ctx) -> time_t { +pub fn _time(time_p: u32, ctx: &mut Ctx) -> i32 { debug!("emscripten::_time {}", time_p); unsafe { let time_p_addr = emscripten_memory_pointer!(ctx.memory(0), time_p) as *mut i64; - libc_time(time_p_addr) + libc_time(time_p_addr) as i32 // TODO review i64 } } @@ -285,7 +285,7 @@ pub fn _strftime( format_ptr: c_int, tm_ptr: c_int, _ctx: &mut Ctx, -) -> time_t { +) -> i32 { debug!( "emscripten::_strftime {} {} {} {}", s_ptr, maxsize, format_ptr, tm_ptr