From 49db149224a2da4bea7b7674bcbb5f2b6b500754 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Tue, 26 Mar 2019 14:37:47 -0700 Subject: [PATCH] fix arg passing to getcwd syscall --- lib/emscripten/src/bitwise.rs | 8 ++++++++ lib/emscripten/src/lib.rs | 4 ++++ lib/emscripten/src/syscalls/mod.rs | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/emscripten/src/bitwise.rs diff --git a/lib/emscripten/src/bitwise.rs b/lib/emscripten/src/bitwise.rs new file mode 100644 index 000000000..aa7fbab32 --- /dev/null +++ b/lib/emscripten/src/bitwise.rs @@ -0,0 +1,8 @@ +use wasmer_runtime_core::vm::Ctx; + +///emscripten: _llvm_bswap_i64 +pub fn _llvm_bswap_i64(_ctx: &mut Ctx, _low: i32, high: i32) -> i32 { + debug!("emscripten::_llvm_bswap_i64"); + // setTempRet0(low.swap_bytes) + high.swap_bytes() +} diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 1bf571c53..60923dea2 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -27,6 +27,7 @@ mod file_descriptor; pub mod stdio; // EMSCRIPTEN APIS +mod bitwise; mod emscripten_target; mod env; mod errno; @@ -622,6 +623,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject "_llvm_cos_f64" => func!(crate::math::_llvm_cos_f64), "_emscripten_random" => func!(crate::math::_emscripten_random), + // Bitwise + "_llvm_bswap_i64" => func!(crate::bitwise::_llvm_bswap_i64), + // Jump "__setjmp" => func!(crate::jmp::__setjmp), "__longjmp" => func!(crate::jmp::__longjmp), diff --git a/lib/emscripten/src/syscalls/mod.rs b/lib/emscripten/src/syscalls/mod.rs index de02b998d..36a1b0c7c 100644 --- a/lib/emscripten/src/syscalls/mod.rs +++ b/lib/emscripten/src/syscalls/mod.rs @@ -209,9 +209,11 @@ pub fn ___syscall110(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { } // getcwd -pub fn ___syscall183(ctx: &mut Ctx, buf_offset: u32, _size: u32) -> u32 { +pub fn ___syscall183(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 { debug!("emscripten::___syscall183"); use std::env; + let buf_offset: c_int = varargs.get(ctx); + let _size: c_int = varargs.get(ctx); let path = env::current_dir(); let path_string = path.unwrap().display().to_string(); let len = path_string.len();