471: Added missing functions for `pyodide` r=syrusakbary a=piranna

Since Pyodide is focused on running on desktop, this pull-request lacks
Javascript runtime functions. It also sorted alphabetically some functions

Co-authored-by: Jesús Leganés-Combarro 'piranna <piranna@gmail.com>
Co-authored-by: Syrus <me@syrusakbary.com>
Co-authored-by: Syrus Akbary <me@syrusakbary.com>
This commit is contained in:
bors[bot] 2019-06-14 08:33:09 +00:00
commit 0f81cd47e3
18 changed files with 668 additions and 85 deletions

View File

@ -35,9 +35,9 @@ jobs:
name: Install lint deps name: Install lint deps
command: | command: |
git config --global --unset url."ssh://git@github.com".insteadOf || true git config --global --unset url."ssh://git@github.com".insteadOf || true
rustup toolchain install nightly-2019-02-27 rustup toolchain install nightly-2019-05-20
rustup component add rustfmt rustup component add rustfmt
rustup component add clippy --toolchain=nightly-2019-02-27 || cargo +nightly-2019-02-27 install --git https://github.com/rust-lang/rust-clippy/ --force clippy rustup component add clippy --toolchain=nightly-2019-05-20 || cargo +nightly-2019-05-20 install --git https://github.com/rust-lang/rust-clippy/ --force clippy
- run: - run:
name: Execute lints name: Execute lints
command: | command: |

View File

@ -6,6 +6,7 @@ Blocks of changes will separated by version increments.
## **[Unreleased]** ## **[Unreleased]**
- [#471](https://github.com/wasmerio/wasmer/pull/471) Added missing functions to run Python. Improved Emscripten bindings
- [#494](https://github.com/wasmerio/wasmer/pull/494) Remove deprecated type aliases from libc in the runtime C API - [#494](https://github.com/wasmerio/wasmer/pull/494) Remove deprecated type aliases from libc in the runtime C API
- [#493](https://github.com/wasmerio/wasmer/pull/493) `wasmer_module_instantiate` has better error messages in the runtime C API - [#493](https://github.com/wasmerio/wasmer/pull/493) `wasmer_module_instantiate` has better error messages in the runtime C API
- [#474](https://github.com/wasmerio/wasmer/pull/474) Set the install name of the dylib to `@rpath` - [#474](https://github.com/wasmerio/wasmer/pull/474) Set the install name of the dylib to `@rpath`

View File

@ -32,7 +32,7 @@ integration-tests: release
lint: lint:
cargo fmt --all -- --check cargo fmt --all -- --check
cargo +nightly-2019-02-27 clippy --all cargo +nightly-2019-05-20 clippy --all
precommit: lint test precommit: lint test

View File

@ -5,6 +5,15 @@ use crate::env::get_emscripten_data;
use libc::getdtablesize; use libc::getdtablesize;
use wasmer_runtime_core::vm::Ctx; use wasmer_runtime_core::vm::Ctx;
pub fn asm_const_i(_ctx: &mut Ctx, _val: i32) -> i32 {
debug!("emscripten::asm_const_i: {}", _val);
0
}
pub fn exit_with_live_runtime(_ctx: &mut Ctx) {
debug!("emscripten::exit_with_live_runtime");
}
pub fn setTempRet0(ctx: &mut Ctx, val: i32) { pub fn setTempRet0(ctx: &mut Ctx, val: i32) {
debug!("emscripten::setTempRet0: {}", val); debug!("emscripten::setTempRet0: {}", val);
get_emscripten_data(ctx).temp_ret_0 = val; get_emscripten_data(ctx).temp_ret_0 = val;
@ -59,10 +68,6 @@ pub fn _dladdr(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_dladdr"); debug!("emscripten::_dladdr");
0 0
} }
pub fn _pthread_attr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_attr_init({})", _a);
0
}
pub fn _pthread_attr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 { pub fn _pthread_attr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_attr_destroy"); debug!("emscripten::_pthread_attr_destroy");
0 0
@ -82,58 +87,24 @@ pub fn _pthread_attr_getstack(
// HEAP32[stacksize >> 2] = TOTAL_STACK; // HEAP32[stacksize >> 2] = TOTAL_STACK;
0 0
} }
pub fn _pthread_attr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_attr_init({})", _a);
0
}
pub fn _pthread_attr_setstacksize(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_attr_setstacksize");
0
}
pub fn _pthread_cleanup_pop(_ctx: &mut Ctx, _a: i32) -> () {
debug!("emscripten::_pthread_cleanup_pop");
}
pub fn _pthread_cleanup_push(_ctx: &mut Ctx, _a: i32, _b: i32) -> () {
debug!("emscripten::_pthread_cleanup_push");
}
pub fn _pthread_cond_destroy(_ctx: &mut Ctx, _a: i32) -> i32 { pub fn _pthread_cond_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_destroy"); debug!("emscripten::_pthread_cond_destroy");
0 0
} }
pub fn _pthread_cond_timedwait(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
debug!("emscripten::_pthread_cond_timedwait");
0
}
pub fn _pthread_getspecific(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_getspecific");
0
}
pub fn _pthread_getattr_np(_ctx: &mut Ctx, _thread: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr);
0
}
pub fn _pthread_setspecific(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_setspecific");
0
}
pub fn _pthread_once(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_once");
0
}
pub fn _pthread_key_create(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_key_create");
0
}
pub fn _pthread_rwlock_destroy(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_destroy({})", _rwlock);
0
}
pub fn _pthread_rwlock_init(_ctx: &mut Ctx, _rwlock: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr);
0
}
pub fn _pthread_rwlock_wrlock(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_wrlock({})", _rwlock);
0
}
pub fn _pthread_create(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 {
debug!("emscripten::_pthread_create");
0
}
pub fn _pthread_detach(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_detach");
0
}
pub fn _pthread_join(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_join");
0
}
pub fn _pthread_cond_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 { pub fn _pthread_cond_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_init"); debug!("emscripten::_pthread_cond_init");
0 0
@ -142,6 +113,10 @@ pub fn _pthread_cond_signal(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_signal"); debug!("emscripten::_pthread_cond_signal");
0 0
} }
pub fn _pthread_cond_timedwait(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
debug!("emscripten::_pthread_cond_timedwait");
0
}
pub fn _pthread_cond_wait(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 { pub fn _pthread_cond_wait(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_wait"); debug!("emscripten::_pthread_cond_wait");
0 0
@ -158,6 +133,37 @@ pub fn _pthread_condattr_setclock(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_condattr_setclock"); debug!("emscripten::_pthread_condattr_setclock");
0 0
} }
pub fn _pthread_create(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 {
debug!("emscripten::_pthread_create");
0
}
pub fn _pthread_detach(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_detach");
0
}
pub fn _pthread_equal(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_equal");
0
}
pub fn _pthread_exit(_ctx: &mut Ctx, _a: i32) -> () {
debug!("emscripten::_pthread_exit");
}
pub fn _pthread_getattr_np(_ctx: &mut Ctx, _thread: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr);
0
}
pub fn _pthread_getspecific(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_getspecific");
0
}
pub fn _pthread_join(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_join");
0
}
pub fn _pthread_key_create(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_key_create");
0
}
pub fn _pthread_mutex_destroy(_ctx: &mut Ctx, _a: i32) -> i32 { pub fn _pthread_mutex_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_mutex_destroy"); debug!("emscripten::_pthread_mutex_destroy");
0 0
@ -178,6 +184,18 @@ pub fn _pthread_mutexattr_settype(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_mutexattr_settype"); debug!("emscripten::_pthread_mutexattr_settype");
0 0
} }
pub fn _pthread_once(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_once");
0
}
pub fn _pthread_rwlock_destroy(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_destroy({})", _rwlock);
0
}
pub fn _pthread_rwlock_init(_ctx: &mut Ctx, _rwlock: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr);
0
}
pub fn _pthread_rwlock_rdlock(_ctx: &mut Ctx, _a: i32) -> i32 { pub fn _pthread_rwlock_rdlock(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_rdlock"); debug!("emscripten::_pthread_rwlock_rdlock");
0 0
@ -186,10 +204,22 @@ pub fn _pthread_rwlock_unlock(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_unlock"); debug!("emscripten::_pthread_rwlock_unlock");
0 0
} }
pub fn _pthread_rwlock_wrlock(_ctx: &mut Ctx, _rwlock: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_wrlock({})", _rwlock);
0
}
pub fn _pthread_setcancelstate(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 { pub fn _pthread_setcancelstate(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_setcancelstate"); debug!("emscripten::_pthread_setcancelstate");
0 0
} }
pub fn _pthread_setspecific(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_setspecific");
0
}
pub fn _pthread_sigmask(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
debug!("emscripten::_pthread_sigmask");
0
}
pub fn ___gxx_personality_v0( pub fn ___gxx_personality_v0(
_ctx: &mut Ctx, _ctx: &mut Ctx,
_a: i32, _a: i32,
@ -222,6 +252,10 @@ pub fn _gethostbyaddr(_ctx: &mut Ctx, _addr: i32, _addrlen: i32, _atype: i32) ->
debug!("emscripten::gethostbyaddr"); debug!("emscripten::gethostbyaddr");
0 0
} }
pub fn _gethostbyname(_ctx: &mut Ctx, _name: i32) -> i32 {
debug!("emscripten::gethostbyname_r");
0
}
pub fn _gethostbyname_r( pub fn _gethostbyname_r(
_ctx: &mut Ctx, _ctx: &mut Ctx,
_name: i32, _name: i32,

View File

@ -8,6 +8,26 @@ pub fn ___cxa_allocate_exception(ctx: &mut Ctx, size: u32) -> u32 {
env::call_malloc(ctx, size as _) env::call_malloc(ctx, size as _)
} }
pub fn ___cxa_current_primary_exception(_ctx: &mut Ctx) -> u32 {
debug!("emscripten::___cxa_current_primary_exception");
unimplemented!()
}
pub fn ___cxa_decrement_exception_refcount(_ctx: &mut Ctx, _a: u32) {
debug!("emscripten::___cxa_decrement_exception_refcount({})", _a);
unimplemented!()
}
pub fn ___cxa_increment_exception_refcount(_ctx: &mut Ctx, _a: u32) {
debug!("emscripten::___cxa_increment_exception_refcount({})", _a);
unimplemented!()
}
pub fn ___cxa_rethrow_primary_exception(_ctx: &mut Ctx, _a: u32) {
debug!("emscripten::___cxa_rethrow_primary_exception({})", _a);
unimplemented!()
}
/// emscripten: ___cxa_throw /// emscripten: ___cxa_throw
/// TODO: We don't have support for exceptions yet /// TODO: We don't have support for exceptions yet
pub fn ___cxa_throw(ctx: &mut Ctx, _ptr: u32, _ty: u32, _destructor: u32) { pub fn ___cxa_throw(ctx: &mut Ctx, _ptr: u32, _ty: u32, _destructor: u32) {

View File

@ -0,0 +1,6 @@
use wasmer_runtime_core::vm::Ctx;
pub fn addr(_ctx: &mut Ctx, _cp: i32) -> i32 {
debug!("inet::addr({})", _cp);
0
}

View File

@ -1,4 +1,7 @@
use libc::{chroot as _chroot, printf as _printf}; use super::super::env::call_malloc;
use super::super::utils::copy_cstr_into_wasm;
use libc::{chroot as _chroot, getpwuid as _getpwuid, printf as _printf};
use std::mem;
use wasmer_runtime_core::vm::Ctx; use wasmer_runtime_core::vm::Ctx;
@ -24,7 +27,40 @@ pub fn chroot(ctx: &mut Ctx, name_ptr: i32) -> i32 {
} }
/// getpwuid /// getpwuid
pub fn getpwuid(_ctx: &mut Ctx, _uid: i32) -> i32 { #[allow(clippy::cast_ptr_alignment)]
debug!("emscripten::getpwuid"); pub fn getpwuid(ctx: &mut Ctx, uid: i32) -> i32 {
0 debug!("emscripten::getpwuid {}", uid);
#[repr(C)]
struct GuestPasswd {
pw_name: u32,
pw_passwd: u32,
pw_uid: u32,
pw_gid: u32,
pw_gecos: u32,
pw_dir: u32,
pw_shell: u32,
}
unsafe {
let passwd = &*_getpwuid(uid as _);
let passwd_struct_offset = call_malloc(ctx, mem::size_of::<GuestPasswd>() as _);
let passwd_struct_ptr =
emscripten_memory_pointer!(ctx.memory(0), passwd_struct_offset) as *mut GuestPasswd;
assert_eq!(
passwd_struct_ptr as usize % std::mem::align_of::<GuestPasswd>(),
0
);
(*passwd_struct_ptr).pw_name = copy_cstr_into_wasm(ctx, passwd.pw_name);
(*passwd_struct_ptr).pw_passwd = copy_cstr_into_wasm(ctx, passwd.pw_passwd);
(*passwd_struct_ptr).pw_gecos = copy_cstr_into_wasm(ctx, passwd.pw_gecos);
(*passwd_struct_ptr).pw_dir = copy_cstr_into_wasm(ctx, passwd.pw_dir);
(*passwd_struct_ptr).pw_shell = copy_cstr_into_wasm(ctx, passwd.pw_shell);
(*passwd_struct_ptr).pw_uid = passwd.pw_uid;
(*passwd_struct_ptr).pw_gid = passwd.pw_gid;
passwd_struct_offset as _
}
// unsafe { _getpwuid(uid as _) as _}
// 0
} }

View File

@ -24,6 +24,13 @@ use wasmer_runtime_core::{
Func, Instance, IsExport, Module, Func, Instance, IsExport, Module,
}; };
#[cfg(unix)]
use ::libc::DIR as libcDIR;
// We use a placeholder for windows
#[cfg(not(unix))]
type libcDIR = u8;
#[macro_use] #[macro_use]
mod macros; mod macros;
@ -35,8 +42,10 @@ mod errno;
mod exception; mod exception;
mod exec; mod exec;
mod exit; mod exit;
mod inet;
mod io; mod io;
mod jmp; mod jmp;
mod libc;
mod linking; mod linking;
mod lock; mod lock;
mod math; mod math;
@ -47,6 +56,7 @@ mod storage;
mod syscalls; mod syscalls;
mod time; mod time;
mod ucontext; mod ucontext;
mod unistd;
mod utils; mod utils;
mod varargs; mod varargs;
@ -80,6 +90,7 @@ pub struct EmscriptenData<'a> {
pub memset: Func<'a, (u32, u32, u32), u32>, pub memset: Func<'a, (u32, u32, u32), u32>,
pub stack_alloc: Func<'a, u32, u32>, pub stack_alloc: Func<'a, u32, u32>,
pub jumps: Vec<UnsafeCell<[u32; 27]>>, pub jumps: Vec<UnsafeCell<[u32; 27]>>,
pub opened_dirs: HashMap<i32, Box<*mut libcDIR>>,
pub dyn_call_i: Option<Func<'a, i32, i32>>, pub dyn_call_i: Option<Func<'a, i32, i32>>,
pub dyn_call_ii: Option<Func<'a, (i32, i32), i32>>, pub dyn_call_ii: Option<Func<'a, (i32, i32), i32>>,
@ -221,6 +232,8 @@ impl<'a> EmscriptenData<'a> {
memset, memset,
stack_alloc, stack_alloc,
jumps: Vec::new(), jumps: Vec::new(),
opened_dirs: HashMap::new(),
dyn_call_i, dyn_call_i,
dyn_call_ii, dyn_call_ii,
dyn_call_iii, dyn_call_iii,
@ -508,13 +521,18 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"STACKTOP" => Global::new(Value::I32(globals.data.stacktop as i32)), "STACKTOP" => Global::new(Value::I32(globals.data.stacktop as i32)),
"STACK_MAX" => Global::new(Value::I32(globals.data.stack_max as i32)), "STACK_MAX" => Global::new(Value::I32(globals.data.stack_max as i32)),
"DYNAMICTOP_PTR" => Global::new(Value::I32(globals.data.dynamictop_ptr as i32)), "DYNAMICTOP_PTR" => Global::new(Value::I32(globals.data.dynamictop_ptr as i32)),
"fb" => Global::new(Value::I32(globals.data.table_base as i32)),
"tableBase" => Global::new(Value::I32(globals.data.table_base as i32)), "tableBase" => Global::new(Value::I32(globals.data.table_base as i32)),
"__table_base" => Global::new(Value::I32(globals.data.table_base as i32)), "__table_base" => Global::new(Value::I32(globals.data.table_base as i32)),
"ABORT" => Global::new(Value::I32(globals.data.abort as i32)), "ABORT" => Global::new(Value::I32(globals.data.abort as i32)),
"gb" => Global::new(Value::I32(globals.data.memory_base as i32)),
"memoryBase" => Global::new(Value::I32(globals.data.memory_base as i32)), "memoryBase" => Global::new(Value::I32(globals.data.memory_base as i32)),
"__memory_base" => Global::new(Value::I32(globals.data.memory_base as i32)), "__memory_base" => Global::new(Value::I32(globals.data.memory_base as i32)),
"tempDoublePtr" => Global::new(Value::I32(globals.data.temp_double_ptr as i32)), "tempDoublePtr" => Global::new(Value::I32(globals.data.temp_double_ptr as i32)),
// inet
"_inet_addr" => func!(crate::inet::addr),
// IO // IO
"printf" => func!(crate::io::printf), "printf" => func!(crate::io::printf),
"putchar" => func!(crate::io::putchar), "putchar" => func!(crate::io::putchar),
@ -565,15 +583,24 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall9" => func!(crate::syscalls::___syscall9), "___syscall9" => func!(crate::syscalls::___syscall9),
"___syscall10" => func!(crate::syscalls::___syscall10), "___syscall10" => func!(crate::syscalls::___syscall10),
"___syscall12" => func!(crate::syscalls::___syscall12), "___syscall12" => func!(crate::syscalls::___syscall12),
"___syscall14" => func!(crate::syscalls::___syscall14),
"___syscall15" => func!(crate::syscalls::___syscall15), "___syscall15" => func!(crate::syscalls::___syscall15),
"___syscall20" => func!(crate::syscalls::___syscall20), "___syscall20" => func!(crate::syscalls::___syscall20),
"___syscall21" => func!(crate::syscalls::___syscall21),
"___syscall25" => func!(crate::syscalls::___syscall25),
"___syscall29" => func!(crate::syscalls::___syscall29),
"___syscall32" => func!(crate::syscalls::___syscall32),
"___syscall33" => func!(crate::syscalls::___syscall33), "___syscall33" => func!(crate::syscalls::___syscall33),
"___syscall34" => func!(crate::syscalls::___syscall34), "___syscall34" => func!(crate::syscalls::___syscall34),
"___syscall36" => func!(crate::syscalls::___syscall36),
"___syscall39" => func!(crate::syscalls::___syscall39), "___syscall39" => func!(crate::syscalls::___syscall39),
"___syscall38" => func!(crate::syscalls::___syscall38), "___syscall38" => func!(crate::syscalls::___syscall38),
"___syscall40" => func!(crate::syscalls::___syscall40), "___syscall40" => func!(crate::syscalls::___syscall40),
"___syscall41" => func!(crate::syscalls::___syscall41), "___syscall41" => func!(crate::syscalls::___syscall41),
"___syscall42" => func!(crate::syscalls::___syscall42), "___syscall42" => func!(crate::syscalls::___syscall42),
"___syscall51" => func!(crate::syscalls::___syscall51),
"___syscall52" => func!(crate::syscalls::___syscall52),
"___syscall53" => func!(crate::syscalls::___syscall53),
"___syscall54" => func!(crate::syscalls::___syscall54), "___syscall54" => func!(crate::syscalls::___syscall54),
"___syscall57" => func!(crate::syscalls::___syscall57), "___syscall57" => func!(crate::syscalls::___syscall57),
"___syscall60" => func!(crate::syscalls::___syscall60), "___syscall60" => func!(crate::syscalls::___syscall60),
@ -586,23 +613,36 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall85" => func!(crate::syscalls::___syscall85), "___syscall85" => func!(crate::syscalls::___syscall85),
"___syscall91" => func!(crate::syscalls::___syscall91), "___syscall91" => func!(crate::syscalls::___syscall91),
"___syscall94" => func!(crate::syscalls::___syscall94), "___syscall94" => func!(crate::syscalls::___syscall94),
"___syscall96" => func!(crate::syscalls::___syscall96),
"___syscall97" => func!(crate::syscalls::___syscall97), "___syscall97" => func!(crate::syscalls::___syscall97),
"___syscall102" => func!(crate::syscalls::___syscall102), "___syscall102" => func!(crate::syscalls::___syscall102),
"___syscall110" => func!(crate::syscalls::___syscall110), "___syscall110" => func!(crate::syscalls::___syscall110),
"___syscall114" => func!(crate::syscalls::___syscall114), "___syscall114" => func!(crate::syscalls::___syscall114),
"___syscall118" => func!(crate::syscalls::___syscall118), "___syscall118" => func!(crate::syscalls::___syscall118),
"___syscall121" => func!(crate::syscalls::___syscall121),
"___syscall122" => func!(crate::syscalls::___syscall122), "___syscall122" => func!(crate::syscalls::___syscall122),
"___syscall125" => func!(crate::syscalls::___syscall125),
"___syscall132" => func!(crate::syscalls::___syscall132),
"___syscall133" => func!(crate::syscalls::___syscall133),
"___syscall140" => func!(crate::syscalls::___syscall140), "___syscall140" => func!(crate::syscalls::___syscall140),
"___syscall142" => func!(crate::syscalls::___syscall142), "___syscall142" => func!(crate::syscalls::___syscall142),
"___syscall144" => func!(crate::syscalls::___syscall144),
"___syscall145" => func!(crate::syscalls::___syscall145), "___syscall145" => func!(crate::syscalls::___syscall145),
"___syscall146" => func!(crate::syscalls::___syscall146), "___syscall146" => func!(crate::syscalls::___syscall146),
"___syscall147" => func!(crate::syscalls::___syscall147),
"___syscall148" => func!(crate::syscalls::___syscall148), "___syscall148" => func!(crate::syscalls::___syscall148),
"___syscall150" => func!(crate::syscalls::___syscall150),
"___syscall151" => func!(crate::syscalls::___syscall151),
"___syscall152" => func!(crate::syscalls::___syscall152),
"___syscall153" => func!(crate::syscalls::___syscall153),
"___syscall163" => func!(crate::syscalls::___syscall163),
"___syscall168" => func!(crate::syscalls::___syscall168), "___syscall168" => func!(crate::syscalls::___syscall168),
"___syscall180" => func!(crate::syscalls::___syscall180), "___syscall180" => func!(crate::syscalls::___syscall180),
"___syscall181" => func!(crate::syscalls::___syscall181), "___syscall181" => func!(crate::syscalls::___syscall181),
"___syscall183" => func!(crate::syscalls::___syscall183), "___syscall183" => func!(crate::syscalls::___syscall183),
"___syscall191" => func!(crate::syscalls::___syscall191), "___syscall191" => func!(crate::syscalls::___syscall191),
"___syscall192" => func!(crate::syscalls::___syscall192), "___syscall192" => func!(crate::syscalls::___syscall192),
"___syscall193" => func!(crate::syscalls::___syscall193),
"___syscall194" => func!(crate::syscalls::___syscall194), "___syscall194" => func!(crate::syscalls::___syscall194),
"___syscall195" => func!(crate::syscalls::___syscall195), "___syscall195" => func!(crate::syscalls::___syscall195),
"___syscall196" => func!(crate::syscalls::___syscall196), "___syscall196" => func!(crate::syscalls::___syscall196),
@ -614,19 +654,38 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall202" => func!(crate::syscalls::___syscall202), "___syscall202" => func!(crate::syscalls::___syscall202),
"___syscall205" => func!(crate::syscalls::___syscall205), "___syscall205" => func!(crate::syscalls::___syscall205),
"___syscall207" => func!(crate::syscalls::___syscall207), "___syscall207" => func!(crate::syscalls::___syscall207),
"___syscall209" => func!(crate::syscalls::___syscall209),
"___syscall211" => func!(crate::syscalls::___syscall211),
"___syscall212" => func!(crate::syscalls::___syscall212), "___syscall212" => func!(crate::syscalls::___syscall212),
"___syscall218" => func!(crate::syscalls::___syscall218),
"___syscall219" => func!(crate::syscalls::___syscall219), "___syscall219" => func!(crate::syscalls::___syscall219),
"___syscall220" => func!(crate::syscalls::___syscall220), "___syscall220" => func!(crate::syscalls::___syscall220),
"___syscall221" => func!(crate::syscalls::___syscall221), "___syscall221" => func!(crate::syscalls::___syscall221),
"___syscall268" => func!(crate::syscalls::___syscall268), "___syscall268" => func!(crate::syscalls::___syscall268),
"___syscall269" => func!(crate::syscalls::___syscall269),
"___syscall272" => func!(crate::syscalls::___syscall272), "___syscall272" => func!(crate::syscalls::___syscall272),
"___syscall295" => func!(crate::syscalls::___syscall295), "___syscall295" => func!(crate::syscalls::___syscall295),
"___syscall296" => func!(crate::syscalls::___syscall296),
"___syscall297" => func!(crate::syscalls::___syscall297),
"___syscall298" => func!(crate::syscalls::___syscall298),
"___syscall300" => func!(crate::syscalls::___syscall300), "___syscall300" => func!(crate::syscalls::___syscall300),
"___syscall301" => func!(crate::syscalls::___syscall301),
"___syscall302" => func!(crate::syscalls::___syscall302),
"___syscall303" => func!(crate::syscalls::___syscall303),
"___syscall304" => func!(crate::syscalls::___syscall304),
"___syscall305" => func!(crate::syscalls::___syscall305),
"___syscall306" => func!(crate::syscalls::___syscall306),
"___syscall307" => func!(crate::syscalls::___syscall307),
"___syscall308" => func!(crate::syscalls::___syscall308),
"___syscall320" => func!(crate::syscalls::___syscall320), "___syscall320" => func!(crate::syscalls::___syscall320),
"___syscall324" => func!(crate::syscalls::___syscall324), "___syscall324" => func!(crate::syscalls::___syscall324),
"___syscall330" => func!(crate::syscalls::___syscall330), "___syscall330" => func!(crate::syscalls::___syscall330),
"___syscall331" => func!(crate::syscalls::___syscall331),
"___syscall333" => func!(crate::syscalls::___syscall333),
"___syscall334" => func!(crate::syscalls::___syscall334), "___syscall334" => func!(crate::syscalls::___syscall334),
"___syscall337" => func!(crate::syscalls::___syscall337),
"___syscall340" => func!(crate::syscalls::___syscall340), "___syscall340" => func!(crate::syscalls::___syscall340),
"___syscall345" => func!(crate::syscalls::___syscall345),
// Process // Process
"abort" => func!(crate::process::em_abort), "abort" => func!(crate::process::em_abort),
@ -655,9 +714,17 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"_setitimer" => func!(crate::process::_setitimer), "_setitimer" => func!(crate::process::_setitimer),
"_usleep" => func!(crate::process::_usleep), "_usleep" => func!(crate::process::_usleep),
"_nanosleep" => func!(crate::process::_nanosleep), "_nanosleep" => func!(crate::process::_nanosleep),
"_utime" => func!(crate::process::_utime),
"_utimes" => func!(crate::process::_utimes), "_utimes" => func!(crate::process::_utimes),
"_wait" => func!(crate::process::_wait),
"_wait3" => func!(crate::process::_wait3),
"_wait4" => func!(crate::process::_wait4),
"_waitid" => func!(crate::process::_waitid),
"_waitpid" => func!(crate::process::_waitpid), "_waitpid" => func!(crate::process::_waitpid),
// Emscripten
"_emscripten_asm_const_i" => func!(crate::emscripten_target::asm_const_i),
"_emscripten_exit_with_live_runtime" => func!(crate::emscripten_target::exit_with_live_runtime),
// Signal // Signal
"_sigemptyset" => func!(crate::signal::_sigemptyset), "_sigemptyset" => func!(crate::signal::_sigemptyset),
@ -681,6 +748,10 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
// Exception // Exception
"___cxa_allocate_exception" => func!(crate::exception::___cxa_allocate_exception), "___cxa_allocate_exception" => func!(crate::exception::___cxa_allocate_exception),
"___cxa_current_primary_exception" => func!(crate::exception::___cxa_current_primary_exception),
"___cxa_decrement_exception_refcount" => func!(crate::exception::___cxa_decrement_exception_refcount),
"___cxa_increment_exception_refcount" => func!(crate::exception::___cxa_increment_exception_refcount),
"___cxa_rethrow_primary_exception" => func!(crate::exception::___cxa_rethrow_primary_exception),
"___cxa_throw" => func!(crate::exception::___cxa_throw), "___cxa_throw" => func!(crate::exception::___cxa_throw),
"___cxa_begin_catch" => func!(crate::exception::___cxa_begin_catch), "___cxa_begin_catch" => func!(crate::exception::___cxa_begin_catch),
"___cxa_end_catch" => func!(crate::exception::___cxa_end_catch), "___cxa_end_catch" => func!(crate::exception::___cxa_end_catch),
@ -689,7 +760,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
// Time // Time
"_gettimeofday" => func!(crate::time::_gettimeofday), "_gettimeofday" => func!(crate::time::_gettimeofday),
"_clock_getres" => func!(crate::time::_clock_getres),
"_clock_gettime" => func!(crate::time::_clock_gettime), "_clock_gettime" => func!(crate::time::_clock_gettime),
"_clock_settime" => func!(crate::time::_clock_settime),
"___clock_gettime" => func!(crate::time::_clock_gettime), "___clock_gettime" => func!(crate::time::_clock_gettime),
"_clock" => func!(crate::time::_clock), "_clock" => func!(crate::time::_clock),
"_difftime" => func!(crate::time::_difftime), "_difftime" => func!(crate::time::_difftime),
@ -707,6 +780,8 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
// Math // Math
"f64-rem" => func!(crate::math::f64_rem), "f64-rem" => func!(crate::math::f64_rem),
"_llvm_copysign_f32" => func!(crate::math::_llvm_copysign_f32),
"_llvm_copysign_f64" => func!(crate::math::_llvm_copysign_f64),
"_llvm_log10_f64" => func!(crate::math::_llvm_log10_f64), "_llvm_log10_f64" => func!(crate::math::_llvm_log10_f64),
"_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64), "_llvm_log2_f64" => func!(crate::math::_llvm_log2_f64),
"_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32), "_llvm_log10_f32" => func!(crate::math::_llvm_log10_f32),
@ -728,6 +803,22 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
// Bitwise // Bitwise
"_llvm_bswap_i64" => func!(crate::bitwise::_llvm_bswap_i64), "_llvm_bswap_i64" => func!(crate::bitwise::_llvm_bswap_i64),
// libc
"_execv" => func!(crate::libc::execv),
"_endpwent" => func!(crate::libc::endpwent),
"_fexecve" => func!(crate::libc::fexecve),
"_fpathconf" => func!(crate::libc::fpathconf),
"_getitimer" => func!(crate::libc::getitimer),
"_getpwent" => func!(crate::libc::getpwent),
"_killpg" => func!(crate::libc::killpg),
"_pathconf" => func!(crate::libc::pathconf),
"_siginterrupt" => func!(crate::signal::_siginterrupt),
"_setpwent" => func!(crate::libc::setpwent),
"_sigismember" => func!(crate::libc::sigismember),
"_sigpending" => func!(crate::libc::sigpending),
"___libc_current_sigrtmax" => func!(crate::libc::current_sigrtmax),
"___libc_current_sigrtmin" => func!(crate::libc::current_sigrtmin),
// Linking // Linking
"_dlclose" => func!(crate::linking::_dlclose), "_dlclose" => func!(crate::linking::_dlclose),
"_dlerror" => func!(crate::linking::_dlerror), "_dlerror" => func!(crate::linking::_dlerror),
@ -759,40 +850,47 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___cxa_free_exception" => func!(crate::emscripten_target::___cxa_free_exception), "___cxa_free_exception" => func!(crate::emscripten_target::___cxa_free_exception),
"___resumeException" => func!(crate::emscripten_target::___resumeException), "___resumeException" => func!(crate::emscripten_target::___resumeException),
"_dladdr" => func!(crate::emscripten_target::_dladdr), "_dladdr" => func!(crate::emscripten_target::_dladdr),
"_pthread_create" => func!(crate::emscripten_target::_pthread_create),
"_pthread_detach" => func!(crate::emscripten_target::_pthread_detach),
"_pthread_join" => func!(crate::emscripten_target::_pthread_join),
"_pthread_attr_init" => func!(crate::emscripten_target::_pthread_attr_init),
"_pthread_attr_destroy" => func!(crate::emscripten_target::_pthread_attr_destroy), "_pthread_attr_destroy" => func!(crate::emscripten_target::_pthread_attr_destroy),
"_pthread_attr_getstack" => func!(crate::emscripten_target::_pthread_attr_getstack), "_pthread_attr_getstack" => func!(crate::emscripten_target::_pthread_attr_getstack),
"_pthread_cond_init" => func!(crate::emscripten_target::_pthread_cond_init), "_pthread_attr_init" => func!(crate::emscripten_target::_pthread_attr_init),
"_pthread_attr_setstacksize" => func!(crate::emscripten_target::_pthread_attr_setstacksize),
"_pthread_cleanup_pop" => func!(crate::emscripten_target::_pthread_cleanup_pop),
"_pthread_cleanup_push" => func!(crate::emscripten_target::_pthread_cleanup_push),
"_pthread_cond_destroy" => func!(crate::emscripten_target::_pthread_cond_destroy), "_pthread_cond_destroy" => func!(crate::emscripten_target::_pthread_cond_destroy),
"_pthread_cond_init" => func!(crate::emscripten_target::_pthread_cond_init),
"_pthread_cond_signal" => func!(crate::emscripten_target::_pthread_cond_signal), "_pthread_cond_signal" => func!(crate::emscripten_target::_pthread_cond_signal),
"_pthread_cond_timedwait" => func!(crate::emscripten_target::_pthread_cond_timedwait), "_pthread_cond_timedwait" => func!(crate::emscripten_target::_pthread_cond_timedwait),
"_pthread_cond_wait" => func!(crate::emscripten_target::_pthread_cond_wait), "_pthread_cond_wait" => func!(crate::emscripten_target::_pthread_cond_wait),
"_pthread_condattr_destroy" => func!(crate::emscripten_target::_pthread_condattr_destroy), "_pthread_condattr_destroy" => func!(crate::emscripten_target::_pthread_condattr_destroy),
"_pthread_condattr_init" => func!(crate::emscripten_target::_pthread_condattr_init), "_pthread_condattr_init" => func!(crate::emscripten_target::_pthread_condattr_init),
"_pthread_condattr_setclock" => func!(crate::emscripten_target::_pthread_condattr_setclock), "_pthread_condattr_setclock" => func!(crate::emscripten_target::_pthread_condattr_setclock),
"_pthread_create" => func!(crate::emscripten_target::_pthread_create),
"_pthread_detach" => func!(crate::emscripten_target::_pthread_detach),
"_pthread_equal" => func!(crate::emscripten_target::_pthread_equal),
"_pthread_exit" => func!(crate::emscripten_target::_pthread_exit),
"_pthread_getattr_np" => func!(crate::emscripten_target::_pthread_getattr_np),
"_pthread_getspecific" => func!(crate::emscripten_target::_pthread_getspecific),
"_pthread_join" => func!(crate::emscripten_target::_pthread_join),
"_pthread_key_create" => func!(crate::emscripten_target::_pthread_key_create),
"_pthread_mutex_destroy" => func!(crate::emscripten_target::_pthread_mutex_destroy), "_pthread_mutex_destroy" => func!(crate::emscripten_target::_pthread_mutex_destroy),
"_pthread_mutex_init" => func!(crate::emscripten_target::_pthread_mutex_init), "_pthread_mutex_init" => func!(crate::emscripten_target::_pthread_mutex_init),
"_pthread_mutexattr_destroy" => func!(crate::emscripten_target::_pthread_mutexattr_destroy), "_pthread_mutexattr_destroy" => func!(crate::emscripten_target::_pthread_mutexattr_destroy),
"_pthread_mutexattr_init" => func!(crate::emscripten_target::_pthread_mutexattr_init), "_pthread_mutexattr_init" => func!(crate::emscripten_target::_pthread_mutexattr_init),
"_pthread_mutexattr_settype" => func!(crate::emscripten_target::_pthread_mutexattr_settype), "_pthread_mutexattr_settype" => func!(crate::emscripten_target::_pthread_mutexattr_settype),
"_pthread_rwlock_rdlock" => func!(crate::emscripten_target::_pthread_rwlock_rdlock),
"_pthread_rwlock_unlock" => func!(crate::emscripten_target::_pthread_rwlock_unlock),
"_pthread_setcancelstate" => func!(crate::emscripten_target::_pthread_setcancelstate),
"_pthread_getspecific" => func!(crate::emscripten_target::_pthread_getspecific),
"_pthread_getattr_np" => func!(crate::emscripten_target::_pthread_getattr_np),
"_pthread_setspecific" => func!(crate::emscripten_target::_pthread_setspecific),
"_pthread_once" => func!(crate::emscripten_target::_pthread_once), "_pthread_once" => func!(crate::emscripten_target::_pthread_once),
"_pthread_key_create" => func!(crate::emscripten_target::_pthread_key_create),
"_pthread_rwlock_destroy" => func!(crate::emscripten_target::_pthread_rwlock_destroy), "_pthread_rwlock_destroy" => func!(crate::emscripten_target::_pthread_rwlock_destroy),
"_pthread_rwlock_init" => func!(crate::emscripten_target::_pthread_rwlock_init), "_pthread_rwlock_init" => func!(crate::emscripten_target::_pthread_rwlock_init),
"_pthread_rwlock_rdlock" => func!(crate::emscripten_target::_pthread_rwlock_rdlock),
"_pthread_rwlock_unlock" => func!(crate::emscripten_target::_pthread_rwlock_unlock),
"_pthread_rwlock_wrlock" => func!(crate::emscripten_target::_pthread_rwlock_wrlock), "_pthread_rwlock_wrlock" => func!(crate::emscripten_target::_pthread_rwlock_wrlock),
"_pthread_setcancelstate" => func!(crate::emscripten_target::_pthread_setcancelstate),
"_pthread_setspecific" => func!(crate::emscripten_target::_pthread_setspecific),
"_pthread_sigmask" => func!(crate::emscripten_target::_pthread_sigmask),
"___gxx_personality_v0" => func!(crate::emscripten_target::___gxx_personality_v0), "___gxx_personality_v0" => func!(crate::emscripten_target::___gxx_personality_v0),
"_gai_strerror" => func!(crate::emscripten_target::_gai_strerror), "_gai_strerror" => func!(crate::emscripten_target::_gai_strerror),
"_getdtablesize" => func!(crate::emscripten_target::_getdtablesize), "_getdtablesize" => func!(crate::emscripten_target::_getdtablesize),
"_gethostbyaddr" => func!(crate::emscripten_target::_gethostbyaddr), "_gethostbyaddr" => func!(crate::emscripten_target::_gethostbyaddr),
"_gethostbyname" => func!(crate::emscripten_target::_gethostbyname),
"_gethostbyname_r" => func!(crate::emscripten_target::_gethostbyname_r), "_gethostbyname_r" => func!(crate::emscripten_target::_gethostbyname_r),
"_getloadavg" => func!(crate::emscripten_target::_getloadavg), "_getloadavg" => func!(crate::emscripten_target::_getloadavg),
"_getnameinfo" => func!(crate::emscripten_target::_getnameinfo), "_getnameinfo" => func!(crate::emscripten_target::_getnameinfo),
@ -841,6 +939,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"_makecontext" => func!(crate::ucontext::_makecontext), "_makecontext" => func!(crate::ucontext::_makecontext),
"_setcontext" => func!(crate::ucontext::_setcontext), "_setcontext" => func!(crate::ucontext::_setcontext),
"_swapcontext" => func!(crate::ucontext::_swapcontext), "_swapcontext" => func!(crate::ucontext::_swapcontext),
// unistd
"_confstr" => func!(crate::unistd::confstr),
}; };
for null_func_name in globals.null_func_names.iter() { for null_func_name in globals.null_func_names.iter() {

View File

@ -0,0 +1,78 @@
extern crate libc;
extern crate wasmer_runtime_core;
#[cfg(unix)]
use std::convert::TryInto;
use wasmer_runtime_core::vm::Ctx;
pub fn current_sigrtmax(_ctx: &mut Ctx) -> i32 {
debug!("emscripten::current_sigrtmax");
0
}
pub fn current_sigrtmin(_ctx: &mut Ctx) -> i32 {
debug!("emscripten::current_sigrtmin");
0
}
pub fn endpwent(_ctx: &mut Ctx) {
debug!("emscripten::endpwent");
}
pub fn execv(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::execv");
0
}
pub fn fexecve(_ctx: &mut Ctx, _a: i32, _b: i32, _c: i32) -> i32 {
debug!("emscripten::fexecve");
0
}
pub fn fpathconf(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::fpathconf");
0
}
pub fn getitimer(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::getitimer");
0
}
pub fn getpwent(_ctx: &mut Ctx) -> i32 {
debug!("emscripten::getpwent");
0
}
pub fn killpg(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::killpg");
0
}
#[cfg(unix)]
pub fn pathconf(ctx: &mut Ctx, path_ptr: i32, name: i32) -> i32 {
debug!("emscripten::pathconf");
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
unsafe { libc::pathconf(path, name).try_into().unwrap() }
}
#[cfg(not(unix))]
pub fn pathconf(_ctx: &mut Ctx, _path_ptr: i32, _name: i32) -> i32 {
debug!("emscripten::pathconf");
0
}
pub fn setpwent(_ctx: &mut Ctx) {
debug!("emscripten::setpwent");
}
pub fn sigismember(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::sigismember");
0
}
pub fn sigpending(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::sigpending");
0
}

View File

@ -0,0 +1,9 @@
extern crate libm;
extern crate wasmer_runtime_core;
use libm::fma;
use wasmer_runtime_core::vm::Ctx;
pub fn fma_f64(_ctx: &mut Ctx, x: f64, y: f64, z: f64) -> f64 {
fma(x, y, z)
}

View File

@ -1,5 +1,13 @@
use wasmer_runtime_core::vm::Ctx; use wasmer_runtime_core::vm::Ctx;
pub fn _llvm_copysign_f32(_ctx: &mut Ctx, x: f64, y: f64) -> f64 {
x.copysign(y)
}
pub fn _llvm_copysign_f64(_ctx: &mut Ctx, x: f64, y: f64) -> f64 {
x.copysign(y)
}
/// emscripten: _llvm_log10_f64 /// emscripten: _llvm_log10_f64
pub fn _llvm_log10_f64(_ctx: &mut Ctx, value: f64) -> f64 { pub fn _llvm_log10_f64(_ctx: &mut Ctx, value: f64) -> f64 {
debug!("emscripten::_llvm_log10_f64"); debug!("emscripten::_llvm_log10_f64");

View File

@ -131,11 +131,36 @@ pub fn _nanosleep(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1 -1
} }
pub fn _utime(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_utime");
-1
}
pub fn _utimes(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn _utimes(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_utimes"); debug!("emscripten::_utimes");
-1 -1
} }
pub fn _wait(_ctx: &mut Ctx, _one: i32) -> i32 {
debug!("emscripten::_wait");
-1
}
pub fn _wait3(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_wait3");
-1
}
pub fn _wait4(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
debug!("emscripten::_wait4");
-1
}
pub fn _waitid(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
debug!("emscripten::_waitid");
-1
}
pub fn _waitpid(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 { pub fn _waitpid(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_waitpid"); debug!("emscripten::_waitpid");
-1 -1

View File

@ -16,6 +16,11 @@ pub fn _sigaction(_ctx: &mut Ctx, _signum: u32, _act: u32, _oldact: u32) -> i32
0 0
} }
pub fn _siginterrupt(_ctx: &mut Ctx, _a: u32, _b: u32) -> i32 {
debug!("emscripten::_siginterrupt {}, {}", _a, _b);
0
}
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _sigaddset(ctx: &mut Ctx, set: u32, signum: u32) -> i32 { pub fn _sigaddset(ctx: &mut Ctx, set: u32, signum: u32) -> i32 {
debug!("emscripten::_sigaddset {}, {}", set, signum); debug!("emscripten::_sigaddset {}, {}", set, signum);

View File

@ -27,6 +27,7 @@ use libc::{
exit, exit,
fstat, fstat,
getpid, getpid,
// readlink,
// iovec, // iovec,
lseek, lseek,
off_t, off_t,
@ -39,7 +40,6 @@ use libc::{
// writev, // writev,
stat, stat,
write, write,
// readlink,
}; };
use wasmer_runtime_core::{ use wasmer_runtime_core::{
memory::ptr::{Array, WasmPtr}, memory::ptr::{Array, WasmPtr},
@ -119,6 +119,11 @@ pub fn ___syscall10(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1 -1
} }
pub fn ___syscall14(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall14");
-1
}
pub fn ___syscall15(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall15(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall15"); debug!("emscripten::___syscall15");
-1 -1
@ -130,6 +135,36 @@ pub fn ___syscall20(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
unsafe { getpid() } unsafe { getpid() }
} }
pub fn ___syscall21(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall21");
-1
}
pub fn ___syscall25(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall25");
-1
}
pub fn ___syscall29(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall29");
-1
}
pub fn ___syscall32(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall32");
-1
}
pub fn ___syscall33(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall33");
-1
}
pub fn ___syscall36(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall36");
-1
}
// rename // rename
pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 { pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall38 (rename)"); debug!("emscripten::___syscall38 (rename)");
@ -196,6 +231,21 @@ pub fn ___syscall42(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
result result
} }
pub fn ___syscall51(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall51");
-1
}
pub fn ___syscall52(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall52");
-1
}
pub fn ___syscall53(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall53");
-1
}
pub fn ___syscall60(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall60(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall60"); debug!("emscripten::___syscall60");
-1 -1
@ -260,6 +310,11 @@ pub fn ___syscall91(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
0 0
} }
pub fn ___syscall96(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall96");
-1
}
pub fn ___syscall97(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall97(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall97"); debug!("emscripten::___syscall97");
-1 -1
@ -270,6 +325,61 @@ pub fn ___syscall110(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1 -1
} }
pub fn ___syscall121(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall121");
-1
}
pub fn ___syscall125(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall125");
-1
}
pub fn ___syscall132(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall132");
-1
}
pub fn ___syscall133(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall133");
-1
}
pub fn ___syscall144(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall144");
-1
}
pub fn ___syscall147(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall147");
-1
}
pub fn ___syscall150(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall150");
-1
}
pub fn ___syscall151(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall151");
-1
}
pub fn ___syscall152(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall152");
-1
}
pub fn ___syscall153(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall153");
-1
}
pub fn ___syscall163(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall163");
-1
}
// getcwd // getcwd
pub fn ___syscall183(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 { pub fn ___syscall183(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall183"); debug!("emscripten::___syscall183");
@ -446,8 +556,8 @@ pub fn ___syscall191(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
0 0
} }
pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall193(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall199 - stub"); debug!("emscripten::___syscall193");
-1 -1
} }
@ -501,6 +611,21 @@ pub fn ___syscall197(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
0 0
} }
pub fn ___syscall209(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall209");
-1
}
pub fn ___syscall211(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall211");
-1
}
pub fn ___syscall218(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall218");
-1
}
// fcntl64 // fcntl64
pub fn ___syscall221(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall221(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall221 (fcntl64) {}", _which); debug!("emscripten::___syscall221 (fcntl64) {}", _which);
@ -524,6 +649,11 @@ pub fn ___syscall268(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1 -1
} }
pub fn ___syscall269(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall269");
-1
}
pub fn ___syscall272(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall272(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall272"); debug!("emscripten::___syscall272");
-1 -1
@ -534,22 +664,92 @@ pub fn ___syscall295(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1 -1
} }
pub fn ___syscall296(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall296");
-1
}
pub fn ___syscall297(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall297");
-1
}
pub fn ___syscall298(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall298");
-1
}
pub fn ___syscall300(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall300(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall300"); debug!("emscripten::___syscall300");
-1 -1
} }
pub fn ___syscall301(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall301");
-1
}
pub fn ___syscall302(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall302");
-1
}
pub fn ___syscall303(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall303");
-1
}
pub fn ___syscall304(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall304");
-1
}
pub fn ___syscall305(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall305");
-1
}
pub fn ___syscall306(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall306");
-1
}
pub fn ___syscall307(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall307");
-1
}
pub fn ___syscall308(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall308");
-1
}
// utimensat // utimensat
pub fn ___syscall320(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall320(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall320 (utimensat), {}", _which); debug!("emscripten::___syscall320 (utimensat), {}", _which);
0 0
} }
pub fn ___syscall331(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall331");
-1
}
pub fn ___syscall333(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall333");
-1
}
pub fn ___syscall334(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall334(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall334"); debug!("emscripten::___syscall334");
-1 -1
} }
pub fn ___syscall337(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall337");
-1
}
// prlimit64 // prlimit64
pub fn ___syscall340(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall340(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall340 (prlimit64), {}", _which); debug!("emscripten::___syscall340 (prlimit64), {}", _which);
@ -576,3 +776,8 @@ pub fn ___syscall340(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
0 0
} }
pub fn ___syscall345(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall345");
-1
}

View File

@ -26,6 +26,7 @@ use libc::{
getrusage, getrusage,
getsockname, getsockname,
getsockopt, getsockopt,
getuid,
gid_t, gid_t,
in_addr_t, in_addr_t,
in_port_t, in_port_t,
@ -74,6 +75,9 @@ use libc::{
SO_REUSEADDR, SO_REUSEADDR,
TIOCGWINSZ, TIOCGWINSZ,
}; };
#[allow(unused_imports)]
use std::ffi::CStr;
use wasmer_runtime_core::vm::Ctx; use wasmer_runtime_core::vm::Ctx;
use crate::utils; use crate::utils;
@ -845,39 +849,65 @@ pub fn ___syscall196(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
0 0
} }
// getuid
pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall199 (getuid)");
let uid = unsafe { getuid() as _ };
debug!(" => {}", uid);
uid
}
// getdents // getdents
// dirent structure is // dirent structure is
// i64, i64, u16 (280), i8, [i8; 256] // i64, i64, u16 (280), i8, [i8; 256]
pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall220(ctx: &mut Ctx, _which: i32, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall220"); use super::super::env::get_emscripten_data;
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
let dirp_addr: i32 = varargs.get(ctx); let dirp_addr: i32 = varargs.get(ctx);
let count: u32 = varargs.get(ctx); let count: u32 = varargs.get(ctx);
debug!(
"emscripten::___syscall220 (getdents) {} {} {}",
fd, dirp_addr, count
);
let dirp = emscripten_memory_pointer!(ctx.memory(0), dirp_addr) as *mut u8; let dirp = emscripten_memory_pointer!(ctx.memory(0), dirp_addr) as *mut u8;
let mut opened_dirs = &mut get_emscripten_data(ctx).opened_dirs;
// need to persist stream across calls? // need to persist stream across calls?
let dir: *mut libc::DIR = unsafe { libc::fdopendir(fd) }; // let dir: *mut libc::DIR = unsafe { libc::fdopendir(fd) };
let mut dir = &*opened_dirs
.entry(fd)
.or_insert_with(|| unsafe { Box::new(libc::fdopendir(fd)) });
let mut pos = 0; let mut pos = 0;
let offset = 280; let offset = 256 + 12;
while pos + offset <= count as usize { while pos + offset <= count as usize {
let dirent = unsafe { readdir(dir) }; let dirent = unsafe { readdir(**dir) };
if dirent.is_null() { if dirent.is_null() {
break; break;
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
unsafe { unsafe {
*(dirp.add(pos) as *mut u64) = (*dirent).d_ino; *(dirp.add(pos) as *mut u32) = (*dirent).d_ino as u32;
*(dirp.add(pos + 8) as *mut u64) = pos as u64 + offset as u64; *(dirp.add(pos + 4) as *mut u32) = pos as u32;
*(dirp.add(pos + 16) as *mut u16) = offset as u16; *(dirp.add(pos + 8) as *mut u16) = offset as u16;
*(dirp.add(pos + 18) as *mut u8) = (*dirent).d_type; *(dirp.add(pos + 10) as *mut u8) = (*dirent).d_type;
let upper_bound = std::cmp::min((*dirent).d_reclen, 254) as usize; let upper_bound = std::cmp::min((*dirent).d_reclen, 255) as usize;
let mut i = 0; let mut i = 0;
while i < upper_bound { while i < upper_bound {
*(dirp.add(pos + 19 + i) as *mut i8) = (*dirent).d_name[i]; *(dirp.add(pos + 11 + i) as *mut i8) = (*dirent).d_name[i];
i += 1; i += 1;
} }
*(dirp.add(pos + 19 + i) as *mut i8) = 0 as i8; // We set the termination string char
*(dirp.add(pos + 11 + i) as *mut i8) = 0 as i8;
debug!(
" => file {}",
CStr::from_ptr(dirp.add(pos + 11) as *const i8)
.to_str()
.unwrap()
);
} }
pos += offset; pos += offset;
} }

View File

@ -261,6 +261,12 @@ pub fn ___syscall196(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1 -1
} }
// getuid
pub fn ___syscall199(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall199 (getuid)");
-1
}
// getdents // getdents
pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 { pub fn ___syscall220(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall220"); debug!("emscripten::___syscall220");

View File

@ -1,5 +1,6 @@
use super::utils::{copy_cstr_into_wasm, write_to_buf}; use super::utils::{copy_cstr_into_wasm, write_to_buf};
use libc::{c_char, c_int}; use libc::{c_char, c_int};
// use libc::{c_char, c_int, clock_getres, clock_settime};
use std::mem; use std::mem;
use std::time::SystemTime; use std::time::SystemTime;
@ -69,6 +70,12 @@ pub fn _gettimeofday(ctx: &mut Ctx, tp: c_int, tz: c_int) -> c_int {
0 0
} }
pub fn _clock_getres(_ctx: &mut Ctx, _clk_id: i32, _tp: i32) -> i32 {
debug!("emscripten::_clock_getres");
// clock_getres(clk_id, tp)
0
}
/// emscripten: _clock_gettime /// emscripten: _clock_gettime
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int { pub fn _clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int {
@ -103,6 +110,12 @@ pub fn _clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int {
0 0
} }
pub fn _clock_settime(_ctx: &mut Ctx, _clk_id: i32, _tp: i32) -> i32 {
debug!("emscripten::_clock_settime");
// clock_settime(clk_id, tp)
0
}
/// emscripten: ___clock_gettime /// emscripten: ___clock_gettime
pub fn ___clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int { pub fn ___clock_gettime(ctx: &mut Ctx, clk_id: clockid_t, tp: c_int) -> c_int {
debug!("emscripten::___clock_gettime {} {}", clk_id, tp); debug!("emscripten::___clock_gettime {} {}", clk_id, tp);

View File

@ -0,0 +1,6 @@
use wasmer_runtime_core::vm::Ctx;
pub fn confstr(_ctx: &mut Ctx, _name: i32, _buf_pointer: i32, _len: i32) -> i32 {
debug!("unistd::confstr({}, {}, {})", _name, _buf_pointer, _len);
0
}