get PHP kind of working...

This commit is contained in:
Mark McCaskey 2019-04-04 13:58:05 -07:00
parent e03a4a2065
commit cad4f9b544
6 changed files with 29 additions and 13 deletions

View File

@ -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()
}

View File

@ -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");

View File

@ -137,6 +137,9 @@ pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
pub fn _sysconf(_ctx: &mut Ctx, name: c_int) -> i32 {
debug!("emscripten::_sysconf {}", name);
// TODO: Implement like emscripten expects regarding memory/page size
unsafe { sysconf(name) as i32 } // TODO review i64
match name {
30 => 16384, // page size
_ => unsafe { sysconf(name) as i32 }, // TODO review i64
}
// TODO: Implement like emscripten expects regarding memory/page size
}

View File

@ -25,21 +25,33 @@ 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);
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);
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

View File

@ -512,7 +512,7 @@ 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),
"___syscall91" => func!(crate::syscalls::___syscall91),
"___syscall94" => func!(crate::syscalls::___syscall194),
"___syscall97" => func!(crate::syscalls::___syscall97),
"___syscall102" => func!(crate::syscalls::___syscall102),

View File

@ -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
@ -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