Skip to content

Commit

Permalink
Merge #326
Browse files Browse the repository at this point in the history
326: get PHP kind of working r=MarkMcCaskey a=MarkMcCaskey



Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mackenzie Clark <mackenzie.a.z.c@gmail.com>
  • Loading branch information
3 people committed Apr 4, 2019
2 parents 77f8186 + b6492c5 commit 1041403
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
3 changes: 2 additions & 1 deletion lib/emscripten/src/bitwise.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::emscripten_target;
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)
emscripten_target::setTempRet0(_ctx, _low.swap_bytes());
high.swap_bytes()
}
4 changes: 2 additions & 2 deletions lib/emscripten/src/emscripten_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::env::get_emscripten_data;
use libc::getdtablesize;
use wasmer_runtime_core::vm::Ctx;

pub fn setTempRet0(_ctx: &mut Ctx, _a: i32) {
debug!("emscripten::setTempRet0");
pub fn setTempRet0(_ctx: &mut Ctx, _val: i32) {
debug!("emscripten::setTempRet0: {}", _val);
}
pub fn getTempRet0(_ctx: &mut Ctx) -> i32 {
debug!("emscripten::getTempRet0");
Expand Down
26 changes: 20 additions & 6 deletions lib/emscripten/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,35 @@ pub fn getprotobynumber(_ctx: &mut Ctx, _one: i32) -> i32 {
}

/// sigdelset
pub fn sigdelset(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
pub fn sigdelset(ctx: &mut Ctx, set: i32, signum: i32) -> i32 {
debug!("emscripten::sigdelset");
unimplemented!()
let memory = ctx.memory(0);
#[allow(clippy::cast_ptr_alignment)]
let ptr = emscripten_memory_pointer!(memory, set) as *mut i32;

unsafe { *ptr = *ptr & !(1 << (signum - 1)) }

0
}

/// sigfillset
pub fn sigfillset(_ctx: &mut Ctx, _one: i32) -> i32 {
pub fn sigfillset(ctx: &mut Ctx, set: i32) -> i32 {
debug!("emscripten::sigfillset");
unimplemented!()
let memory = ctx.memory(0);
#[allow(clippy::cast_ptr_alignment)]
let ptr = emscripten_memory_pointer!(memory, set) as *mut i32;

unsafe {
*ptr = -1;
}

0
}

/// tzset
pub fn tzset(_ctx: &mut Ctx) {
debug!("emscripten::tzset");
unimplemented!()
debug!("emscripten::tzset - stub");
//unimplemented!()
}

/// strptime
Expand Down
4 changes: 2 additions & 2 deletions lib/emscripten/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall77" => func!(crate::syscalls::___syscall77),
"___syscall83" => func!(crate::syscalls::___syscall83),
"___syscall85" => func!(crate::syscalls::___syscall85),
"___syscall91" => func!(crate::syscalls::___syscall191),
"___syscall94" => func!(crate::syscalls::___syscall194),
"___syscall91" => func!(crate::syscalls::___syscall91),
"___syscall94" => func!(crate::syscalls::___syscall94),
"___syscall97" => func!(crate::syscalls::___syscall97),
"___syscall102" => func!(crate::syscalls::___syscall102),
"___syscall110" => func!(crate::syscalls::___syscall110),
Expand Down
4 changes: 2 additions & 2 deletions lib/emscripten/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn _emscripten_memcpy_big(ctx: &mut Ctx, dest: u32, src: u32, len: u32) -> u
pub fn _emscripten_get_heap_size(_ctx: &mut Ctx) -> u32 {
debug!("emscripten::_emscripten_get_heap_size",);
// TODO: Fix implementation
16_777_216
162_107_392
}

/// emscripten: _emscripten_resize_heap
Expand All @@ -35,7 +35,7 @@ pub fn get_total_memory(_ctx: &mut Ctx) -> u32 {
debug!("emscripten::get_total_memory");
// instance.memories[0].current_pages()
// TODO: Fix implementation
16_777_216
_ctx.memory(0).size().bytes().0 as u32
}

/// emscripten: enlargeMemory
Expand Down

0 comments on commit 1041403

Please sign in to comment.