Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix arg passing to getcwd syscall #292

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/emscripten/src/bitwise.rs
Original file line number Diff line number Diff line change
@@ -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()
}
4 changes: 4 additions & 0 deletions lib/emscripten/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ mod file_descriptor;
pub mod stdio;

// EMSCRIPTEN APIS
mod bitwise;
mod emscripten_target;
mod env;
mod errno;
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion lib/emscripten/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down