mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
First draft of functions owning their envs
This commit is contained in:
14
lib/api/src/externals/function.rs
vendored
14
lib/api/src/externals/function.rs
vendored
@@ -5,6 +5,7 @@ use crate::types::Val;
|
|||||||
use crate::FunctionType;
|
use crate::FunctionType;
|
||||||
use crate::NativeFunc;
|
use crate::NativeFunc;
|
||||||
use crate::RuntimeError;
|
use crate::RuntimeError;
|
||||||
|
use std::cell::Cell;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use wasm_common::{HostFunction, WasmTypeList, WithEnv, WithoutEnv};
|
use wasm_common::{HostFunction, WasmTypeList, WithEnv, WithoutEnv};
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime::{
|
||||||
@@ -93,13 +94,13 @@ impl Function {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub fn new_dynamic_env<F, Env>(store: &Store, ty: &FunctionType, env: &mut Env, func: F) -> Self
|
pub fn new_dynamic_env<F, Env>(store: &Store, ty: &FunctionType, env: Env, func: F) -> Self
|
||||||
where
|
where
|
||||||
F: Fn(&mut Env, &[Val]) -> Result<Vec<Val>, RuntimeError> + 'static,
|
F: Fn(&mut Env, &[Val]) -> Result<Vec<Val>, RuntimeError> + 'static,
|
||||||
Env: Sized,
|
Env: Sized,
|
||||||
{
|
{
|
||||||
let dynamic_ctx = VMDynamicFunctionImportContext::from_context(VMDynamicFunctionWithEnv {
|
let dynamic_ctx = VMDynamicFunctionImportContext::from_context(VMDynamicFunctionWithEnv {
|
||||||
env,
|
env: Cell::new(env),
|
||||||
func: Box::new(func),
|
func: Box::new(func),
|
||||||
function_type: ty.clone(),
|
function_type: ty.clone(),
|
||||||
});
|
});
|
||||||
@@ -123,7 +124,7 @@ impl Function {
|
|||||||
/// * `store` - a global cache to store information in.
|
/// * `store` - a global cache to store information in.
|
||||||
/// * `env` - the function environment.
|
/// * `env` - the function environment.
|
||||||
/// * `func` - the function.
|
/// * `func` - the function.
|
||||||
pub fn new_env<F, Args, Rets, Env>(store: &Store, env: &mut Env, func: F) -> Self
|
pub fn new_env<F, Args, Rets, Env>(store: &Store, env: Env, func: F) -> Self
|
||||||
where
|
where
|
||||||
F: HostFunction<Args, Rets, WithEnv, Env>,
|
F: HostFunction<Args, Rets, WithEnv, Env>,
|
||||||
Args: WasmTypeList,
|
Args: WasmTypeList,
|
||||||
@@ -137,7 +138,8 @@ impl Function {
|
|||||||
// Wasm-defined functions have a `VMContext`.
|
// Wasm-defined functions have a `VMContext`.
|
||||||
// In the case of Host-defined functions `VMContext` is whatever environment
|
// In the case of Host-defined functions `VMContext` is whatever environment
|
||||||
// the user want to attach to the function.
|
// the user want to attach to the function.
|
||||||
let vmctx = env as *mut _ as *mut VMContext;
|
let box_env = Box::new(env);
|
||||||
|
let vmctx = Box::into_raw(box_env) as *mut _ as *mut VMContext;
|
||||||
let signature = func.ty();
|
let signature = func.ty();
|
||||||
Self {
|
Self {
|
||||||
store: store.clone(),
|
store: store.clone(),
|
||||||
@@ -356,7 +358,7 @@ where
|
|||||||
{
|
{
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
func: Box<dyn Fn(&mut Env, &[Val]) -> Result<Vec<Val>, RuntimeError> + 'static>,
|
func: Box<dyn Fn(&mut Env, &[Val]) -> Result<Vec<Val>, RuntimeError> + 'static>,
|
||||||
env: *mut Env,
|
env: Cell<Env>,
|
||||||
function_type: FunctionType,
|
function_type: FunctionType,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +367,7 @@ where
|
|||||||
Env: Sized,
|
Env: Sized,
|
||||||
{
|
{
|
||||||
fn call(&self, args: &[Val]) -> Result<Vec<Val>, RuntimeError> {
|
fn call(&self, args: &[Val]) -> Result<Vec<Val>, RuntimeError> {
|
||||||
unsafe { (*self.func)(&mut *self.env, &args) }
|
unsafe { (*self.func)(&mut *self.env.as_ptr(), &args) }
|
||||||
}
|
}
|
||||||
fn function_type(&self) -> &FunctionType {
|
fn function_type(&self) -> &FunctionType {
|
||||||
&self.function_type
|
&self.function_type
|
||||||
|
|||||||
@@ -68,13 +68,14 @@ pub use self::utils::{
|
|||||||
get_emscripten_table_size, is_emscripten_module,
|
get_emscripten_table_size, is_emscripten_module,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
/// The environment provided to the Emscripten imports.
|
/// The environment provided to the Emscripten imports.
|
||||||
pub struct EmEnv {
|
pub struct EmEnv<'a> {
|
||||||
memory: Option<Memory>,
|
memory: Option<&'a Memory>,
|
||||||
data: *mut EmscriptenData<'static>,
|
data: *mut EmscriptenData<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmEnv {
|
impl<'a> EmEnv<'a> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
memory: None,
|
memory: None,
|
||||||
@@ -82,7 +83,7 @@ impl EmEnv {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_memory(&mut self, memory: Memory) {
|
pub fn set_memory(&mut self, memory: &'a Memory) {
|
||||||
self.memory = Some(memory)
|
self.memory = Some(memory)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +92,8 @@ impl EmEnv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a reference to the memory
|
/// Get a reference to the memory
|
||||||
pub fn memory(&self, _mem_idx: u32) -> &Memory {
|
pub fn memory(&self, _mem_idx: u32) -> &'a Memory {
|
||||||
self.memory.as_ref().unwrap()
|
self.memory.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,17 +464,17 @@ pub fn emscripten_call_main(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Top level function to execute emscripten
|
/// Top level function to execute emscripten
|
||||||
pub fn run_emscripten_instance(
|
pub fn run_emscripten_instance<'a>(
|
||||||
instance: &mut Instance,
|
instance: &mut Instance,
|
||||||
env: &mut EmEnv,
|
env: &mut EmEnv<'a>,
|
||||||
globals: &mut EmscriptenGlobals,
|
globals: &'a mut EmscriptenGlobals,
|
||||||
path: &str,
|
path: &str,
|
||||||
args: Vec<&str>,
|
args: Vec<&str>,
|
||||||
entrypoint: Option<String>,
|
entrypoint: Option<String>,
|
||||||
mapped_dirs: Vec<(String, PathBuf)>,
|
mapped_dirs: Vec<(String, PathBuf)>,
|
||||||
) -> Result<(), RuntimeError> {
|
) -> Result<(), RuntimeError> {
|
||||||
let mut data = EmscriptenData::new(instance, &globals.data, mapped_dirs.into_iter().collect());
|
let mut data = EmscriptenData::new(instance, &globals.data, mapped_dirs.into_iter().collect());
|
||||||
env.set_memory(globals.memory.clone());
|
env.set_memory(&globals.memory);
|
||||||
env.set_data(&mut data as *mut _ as *mut c_void);
|
env.set_data(&mut data as *mut _ as *mut c_void);
|
||||||
set_up_emscripten(instance)?;
|
set_up_emscripten(instance)?;
|
||||||
|
|
||||||
@@ -646,9 +647,17 @@ pub fn generate_emscripten_env(
|
|||||||
env: &mut EmEnv,
|
env: &mut EmEnv,
|
||||||
) -> ImportObject {
|
) -> ImportObject {
|
||||||
let abort_on_cannot_grow_memory_export = if globals.data.use_old_abort_on_cannot_grow_memory {
|
let abort_on_cannot_grow_memory_export = if globals.data.use_old_abort_on_cannot_grow_memory {
|
||||||
Function::new_env(store, env, crate::memory::abort_on_cannot_grow_memory_old)
|
Function::new_env(
|
||||||
|
store,
|
||||||
|
env.clone(),
|
||||||
|
crate::memory::abort_on_cannot_grow_memory_old,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Function::new_env(store, env, crate::memory::abort_on_cannot_grow_memory)
|
Function::new_env(
|
||||||
|
store,
|
||||||
|
env.clone(),
|
||||||
|
crate::memory::abort_on_cannot_grow_memory,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut env_ns: Exports = namespace! {
|
let mut env_ns: Exports = namespace! {
|
||||||
@@ -669,256 +678,256 @@ pub fn generate_emscripten_env(
|
|||||||
"tempDoublePtr" => Global::new(store, Val::I32(globals.data.temp_double_ptr as i32)),
|
"tempDoublePtr" => Global::new(store, Val::I32(globals.data.temp_double_ptr as i32)),
|
||||||
|
|
||||||
// inet
|
// inet
|
||||||
"_inet_addr" => Function::new_env(store, env, crate::inet::addr),
|
"_inet_addr" => Function::new_env(store, env.clone(), crate::inet::addr),
|
||||||
|
|
||||||
// IO
|
// IO
|
||||||
"printf" => Function::new_env(store, env, crate::io::printf),
|
"printf" => Function::new_env(store, env.clone(), crate::io::printf),
|
||||||
"putchar" => Function::new_env(store, env, crate::io::putchar),
|
"putchar" => Function::new_env(store, env.clone(), crate::io::putchar),
|
||||||
"___lock" => Function::new_env(store, env, crate::lock::___lock),
|
"___lock" => Function::new_env(store, env.clone(), crate::lock::___lock),
|
||||||
"___unlock" => Function::new_env(store, env, crate::lock::___unlock),
|
"___unlock" => Function::new_env(store, env.clone(), crate::lock::___unlock),
|
||||||
"___wait" => Function::new_env(store, env, crate::lock::___wait),
|
"___wait" => Function::new_env(store, env.clone(), crate::lock::___wait),
|
||||||
"_flock" => Function::new_env(store, env, crate::lock::_flock),
|
"_flock" => Function::new_env(store, env.clone(), crate::lock::_flock),
|
||||||
"_chroot" => Function::new_env(store, env, crate::io::chroot),
|
"_chroot" => Function::new_env(store, env.clone(), crate::io::chroot),
|
||||||
"_getprotobyname" => Function::new_env(store, env, crate::io::getprotobyname),
|
"_getprotobyname" => Function::new_env(store, env.clone(), crate::io::getprotobyname),
|
||||||
"_getprotobynumber" => Function::new_env(store, env, crate::io::getprotobynumber),
|
"_getprotobynumber" => Function::new_env(store, env.clone(), crate::io::getprotobynumber),
|
||||||
"_getpwuid" => Function::new_env(store, env, crate::io::getpwuid),
|
"_getpwuid" => Function::new_env(store, env.clone(), crate::io::getpwuid),
|
||||||
"_sigdelset" => Function::new_env(store, env, crate::io::sigdelset),
|
"_sigdelset" => Function::new_env(store, env.clone(), crate::io::sigdelset),
|
||||||
"_sigfillset" => Function::new_env(store, env, crate::io::sigfillset),
|
"_sigfillset" => Function::new_env(store, env.clone(), crate::io::sigfillset),
|
||||||
"_tzset" => Function::new_env(store, env, crate::io::tzset),
|
"_tzset" => Function::new_env(store, env.clone(), crate::io::tzset),
|
||||||
"_strptime" => Function::new_env(store, env, crate::io::strptime),
|
"_strptime" => Function::new_env(store, env.clone(), crate::io::strptime),
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
"_execvp" => Function::new_env(store, env, crate::exec::execvp),
|
"_execvp" => Function::new_env(store, env.clone(), crate::exec::execvp),
|
||||||
"_execl" => Function::new_env(store, env, crate::exec::execl),
|
"_execl" => Function::new_env(store, env.clone(), crate::exec::execl),
|
||||||
"_execle" => Function::new_env(store, env, crate::exec::execle),
|
"_execle" => Function::new_env(store, env.clone(), crate::exec::execle),
|
||||||
|
|
||||||
// exit
|
// exit
|
||||||
"__exit" => Function::new_env(store, env, crate::exit::exit),
|
"__exit" => Function::new_env(store, env.clone(), crate::exit::exit),
|
||||||
|
|
||||||
// Env
|
// Env
|
||||||
"___assert_fail" => Function::new_env(store, env, crate::env::___assert_fail),
|
"___assert_fail" => Function::new_env(store, env.clone(), crate::env::___assert_fail),
|
||||||
"_getenv" => Function::new_env(store, env, crate::env::_getenv),
|
"_getenv" => Function::new_env(store, env.clone(), crate::env::_getenv),
|
||||||
"_setenv" => Function::new_env(store, env, crate::env::_setenv),
|
"_setenv" => Function::new_env(store, env.clone(), crate::env::_setenv),
|
||||||
"_putenv" => Function::new_env(store, env, crate::env::_putenv),
|
"_putenv" => Function::new_env(store, env.clone(), crate::env::_putenv),
|
||||||
"_unsetenv" => Function::new_env(store, env, crate::env::_unsetenv),
|
"_unsetenv" => Function::new_env(store, env.clone(), crate::env::_unsetenv),
|
||||||
"_getpwnam" => Function::new_env(store, env, crate::env::_getpwnam),
|
"_getpwnam" => Function::new_env(store, env.clone(), crate::env::_getpwnam),
|
||||||
"_getgrnam" => Function::new_env(store, env, crate::env::_getgrnam),
|
"_getgrnam" => Function::new_env(store, env.clone(), crate::env::_getgrnam),
|
||||||
"___buildEnvironment" => Function::new_env(store, env, crate::env::___build_environment),
|
"___buildEnvironment" => Function::new_env(store, env.clone(), crate::env::___build_environment),
|
||||||
"___setErrNo" => Function::new_env(store, env, crate::errno::___seterrno),
|
"___setErrNo" => Function::new_env(store, env.clone(), crate::errno::___seterrno),
|
||||||
"_getpagesize" => Function::new_env(store, env, crate::env::_getpagesize),
|
"_getpagesize" => Function::new_env(store, env.clone(), crate::env::_getpagesize),
|
||||||
"_sysconf" => Function::new_env(store, env, crate::env::_sysconf),
|
"_sysconf" => Function::new_env(store, env.clone(), crate::env::_sysconf),
|
||||||
"_getaddrinfo" => Function::new_env(store, env, crate::env::_getaddrinfo),
|
"_getaddrinfo" => Function::new_env(store, env.clone(), crate::env::_getaddrinfo),
|
||||||
"_times" => Function::new_env(store, env, crate::env::_times),
|
"_times" => Function::new_env(store, env.clone(), crate::env::_times),
|
||||||
"_pathconf" => Function::new_env(store, env, crate::env::_pathconf),
|
"_pathconf" => Function::new_env(store, env.clone(), crate::env::_pathconf),
|
||||||
"_fpathconf" => Function::new_env(store, env, crate::env::_fpathconf),
|
"_fpathconf" => Function::new_env(store, env.clone(), crate::env::_fpathconf),
|
||||||
|
|
||||||
// Syscalls
|
// Syscalls
|
||||||
"___syscall1" => Function::new_env(store, env, crate::syscalls::___syscall1),
|
"___syscall1" => Function::new_env(store, env.clone(), crate::syscalls::___syscall1),
|
||||||
"___syscall3" => Function::new_env(store, env, crate::syscalls::___syscall3),
|
"___syscall3" => Function::new_env(store, env.clone(), crate::syscalls::___syscall3),
|
||||||
"___syscall4" => Function::new_env(store, env, crate::syscalls::___syscall4),
|
"___syscall4" => Function::new_env(store, env.clone(), crate::syscalls::___syscall4),
|
||||||
"___syscall5" => Function::new_env(store, env, crate::syscalls::___syscall5),
|
"___syscall5" => Function::new_env(store, env.clone(), crate::syscalls::___syscall5),
|
||||||
"___syscall6" => Function::new_env(store, env, crate::syscalls::___syscall6),
|
"___syscall6" => Function::new_env(store, env.clone(), crate::syscalls::___syscall6),
|
||||||
"___syscall9" => Function::new_env(store, env, crate::syscalls::___syscall9),
|
"___syscall9" => Function::new_env(store, env.clone(), crate::syscalls::___syscall9),
|
||||||
"___syscall10" => Function::new_env(store, env, crate::syscalls::___syscall10),
|
"___syscall10" => Function::new_env(store, env.clone(), crate::syscalls::___syscall10),
|
||||||
"___syscall12" => Function::new_env(store, env, crate::syscalls::___syscall12),
|
"___syscall12" => Function::new_env(store, env.clone(), crate::syscalls::___syscall12),
|
||||||
"___syscall14" => Function::new_env(store, env, crate::syscalls::___syscall14),
|
"___syscall14" => Function::new_env(store, env.clone(), crate::syscalls::___syscall14),
|
||||||
"___syscall15" => Function::new_env(store, env, crate::syscalls::___syscall15),
|
"___syscall15" => Function::new_env(store, env.clone(), crate::syscalls::___syscall15),
|
||||||
"___syscall20" => Function::new_env(store, env, crate::syscalls::___syscall20),
|
"___syscall20" => Function::new_env(store, env.clone(), crate::syscalls::___syscall20),
|
||||||
"___syscall21" => Function::new_env(store, env, crate::syscalls::___syscall21),
|
"___syscall21" => Function::new_env(store, env.clone(), crate::syscalls::___syscall21),
|
||||||
"___syscall25" => Function::new_env(store, env, crate::syscalls::___syscall25),
|
"___syscall25" => Function::new_env(store, env.clone(), crate::syscalls::___syscall25),
|
||||||
"___syscall29" => Function::new_env(store, env, crate::syscalls::___syscall29),
|
"___syscall29" => Function::new_env(store, env.clone(), crate::syscalls::___syscall29),
|
||||||
"___syscall32" => Function::new_env(store, env, crate::syscalls::___syscall32),
|
"___syscall32" => Function::new_env(store, env.clone(), crate::syscalls::___syscall32),
|
||||||
"___syscall33" => Function::new_env(store, env, crate::syscalls::___syscall33),
|
"___syscall33" => Function::new_env(store, env.clone(), crate::syscalls::___syscall33),
|
||||||
"___syscall34" => Function::new_env(store, env, crate::syscalls::___syscall34),
|
"___syscall34" => Function::new_env(store, env.clone(), crate::syscalls::___syscall34),
|
||||||
"___syscall36" => Function::new_env(store, env, crate::syscalls::___syscall36),
|
"___syscall36" => Function::new_env(store, env.clone(), crate::syscalls::___syscall36),
|
||||||
"___syscall39" => Function::new_env(store, env, crate::syscalls::___syscall39),
|
"___syscall39" => Function::new_env(store, env.clone(), crate::syscalls::___syscall39),
|
||||||
"___syscall38" => Function::new_env(store, env, crate::syscalls::___syscall38),
|
"___syscall38" => Function::new_env(store, env.clone(), crate::syscalls::___syscall38),
|
||||||
"___syscall40" => Function::new_env(store, env, crate::syscalls::___syscall40),
|
"___syscall40" => Function::new_env(store, env.clone(), crate::syscalls::___syscall40),
|
||||||
"___syscall41" => Function::new_env(store, env, crate::syscalls::___syscall41),
|
"___syscall41" => Function::new_env(store, env.clone(), crate::syscalls::___syscall41),
|
||||||
"___syscall42" => Function::new_env(store, env, crate::syscalls::___syscall42),
|
"___syscall42" => Function::new_env(store, env.clone(), crate::syscalls::___syscall42),
|
||||||
"___syscall51" => Function::new_env(store, env, crate::syscalls::___syscall51),
|
"___syscall51" => Function::new_env(store, env.clone(), crate::syscalls::___syscall51),
|
||||||
"___syscall52" => Function::new_env(store, env, crate::syscalls::___syscall52),
|
"___syscall52" => Function::new_env(store, env.clone(), crate::syscalls::___syscall52),
|
||||||
"___syscall53" => Function::new_env(store, env, crate::syscalls::___syscall53),
|
"___syscall53" => Function::new_env(store, env.clone(), crate::syscalls::___syscall53),
|
||||||
"___syscall54" => Function::new_env(store, env, crate::syscalls::___syscall54),
|
"___syscall54" => Function::new_env(store, env.clone(), crate::syscalls::___syscall54),
|
||||||
"___syscall57" => Function::new_env(store, env, crate::syscalls::___syscall57),
|
"___syscall57" => Function::new_env(store, env.clone(), crate::syscalls::___syscall57),
|
||||||
"___syscall60" => Function::new_env(store, env, crate::syscalls::___syscall60),
|
"___syscall60" => Function::new_env(store, env.clone(), crate::syscalls::___syscall60),
|
||||||
"___syscall63" => Function::new_env(store, env, crate::syscalls::___syscall63),
|
"___syscall63" => Function::new_env(store, env.clone(), crate::syscalls::___syscall63),
|
||||||
"___syscall64" => Function::new_env(store, env, crate::syscalls::___syscall64),
|
"___syscall64" => Function::new_env(store, env.clone(), crate::syscalls::___syscall64),
|
||||||
"___syscall66" => Function::new_env(store, env, crate::syscalls::___syscall66),
|
"___syscall66" => Function::new_env(store, env.clone(), crate::syscalls::___syscall66),
|
||||||
"___syscall75" => Function::new_env(store, env, crate::syscalls::___syscall75),
|
"___syscall75" => Function::new_env(store, env.clone(), crate::syscalls::___syscall75),
|
||||||
"___syscall77" => Function::new_env(store, env, crate::syscalls::___syscall77),
|
"___syscall77" => Function::new_env(store, env.clone(), crate::syscalls::___syscall77),
|
||||||
"___syscall83" => Function::new_env(store, env, crate::syscalls::___syscall83),
|
"___syscall83" => Function::new_env(store, env.clone(), crate::syscalls::___syscall83),
|
||||||
"___syscall85" => Function::new_env(store, env, crate::syscalls::___syscall85),
|
"___syscall85" => Function::new_env(store, env.clone(), crate::syscalls::___syscall85),
|
||||||
"___syscall91" => Function::new_env(store, env, crate::syscalls::___syscall91),
|
"___syscall91" => Function::new_env(store, env.clone(), crate::syscalls::___syscall91),
|
||||||
"___syscall94" => Function::new_env(store, env, crate::syscalls::___syscall94),
|
"___syscall94" => Function::new_env(store, env.clone(), crate::syscalls::___syscall94),
|
||||||
"___syscall96" => Function::new_env(store, env, crate::syscalls::___syscall96),
|
"___syscall96" => Function::new_env(store, env.clone(), crate::syscalls::___syscall96),
|
||||||
"___syscall97" => Function::new_env(store, env, crate::syscalls::___syscall97),
|
"___syscall97" => Function::new_env(store, env.clone(), crate::syscalls::___syscall97),
|
||||||
"___syscall102" => Function::new_env(store, env, crate::syscalls::___syscall102),
|
"___syscall102" => Function::new_env(store, env.clone(), crate::syscalls::___syscall102),
|
||||||
"___syscall110" => Function::new_env(store, env, crate::syscalls::___syscall110),
|
"___syscall110" => Function::new_env(store, env.clone(), crate::syscalls::___syscall110),
|
||||||
"___syscall114" => Function::new_env(store, env, crate::syscalls::___syscall114),
|
"___syscall114" => Function::new_env(store, env.clone(), crate::syscalls::___syscall114),
|
||||||
"___syscall118" => Function::new_env(store, env, crate::syscalls::___syscall118),
|
"___syscall118" => Function::new_env(store, env.clone(), crate::syscalls::___syscall118),
|
||||||
"___syscall121" => Function::new_env(store, env, crate::syscalls::___syscall121),
|
"___syscall121" => Function::new_env(store, env.clone(), crate::syscalls::___syscall121),
|
||||||
"___syscall122" => Function::new_env(store, env, crate::syscalls::___syscall122),
|
"___syscall122" => Function::new_env(store, env.clone(), crate::syscalls::___syscall122),
|
||||||
"___syscall125" => Function::new_env(store, env, crate::syscalls::___syscall125),
|
"___syscall125" => Function::new_env(store, env.clone(), crate::syscalls::___syscall125),
|
||||||
"___syscall132" => Function::new_env(store, env, crate::syscalls::___syscall132),
|
"___syscall132" => Function::new_env(store, env.clone(), crate::syscalls::___syscall132),
|
||||||
"___syscall133" => Function::new_env(store, env, crate::syscalls::___syscall133),
|
"___syscall133" => Function::new_env(store, env.clone(), crate::syscalls::___syscall133),
|
||||||
"___syscall140" => Function::new_env(store, env, crate::syscalls::___syscall140),
|
"___syscall140" => Function::new_env(store, env.clone(), crate::syscalls::___syscall140),
|
||||||
"___syscall142" => Function::new_env(store, env, crate::syscalls::___syscall142),
|
"___syscall142" => Function::new_env(store, env.clone(), crate::syscalls::___syscall142),
|
||||||
"___syscall144" => Function::new_env(store, env, crate::syscalls::___syscall144),
|
"___syscall144" => Function::new_env(store, env.clone(), crate::syscalls::___syscall144),
|
||||||
"___syscall145" => Function::new_env(store, env, crate::syscalls::___syscall145),
|
"___syscall145" => Function::new_env(store, env.clone(), crate::syscalls::___syscall145),
|
||||||
"___syscall146" => Function::new_env(store, env, crate::syscalls::___syscall146),
|
"___syscall146" => Function::new_env(store, env.clone(), crate::syscalls::___syscall146),
|
||||||
"___syscall147" => Function::new_env(store, env, crate::syscalls::___syscall147),
|
"___syscall147" => Function::new_env(store, env.clone(), crate::syscalls::___syscall147),
|
||||||
"___syscall148" => Function::new_env(store, env, crate::syscalls::___syscall148),
|
"___syscall148" => Function::new_env(store, env.clone(), crate::syscalls::___syscall148),
|
||||||
"___syscall150" => Function::new_env(store, env, crate::syscalls::___syscall150),
|
"___syscall150" => Function::new_env(store, env.clone(), crate::syscalls::___syscall150),
|
||||||
"___syscall151" => Function::new_env(store, env, crate::syscalls::___syscall151),
|
"___syscall151" => Function::new_env(store, env.clone(), crate::syscalls::___syscall151),
|
||||||
"___syscall152" => Function::new_env(store, env, crate::syscalls::___syscall152),
|
"___syscall152" => Function::new_env(store, env.clone(), crate::syscalls::___syscall152),
|
||||||
"___syscall153" => Function::new_env(store, env, crate::syscalls::___syscall153),
|
"___syscall153" => Function::new_env(store, env.clone(), crate::syscalls::___syscall153),
|
||||||
"___syscall163" => Function::new_env(store, env, crate::syscalls::___syscall163),
|
"___syscall163" => Function::new_env(store, env.clone(), crate::syscalls::___syscall163),
|
||||||
"___syscall168" => Function::new_env(store, env, crate::syscalls::___syscall168),
|
"___syscall168" => Function::new_env(store, env.clone(), crate::syscalls::___syscall168),
|
||||||
"___syscall180" => Function::new_env(store, env, crate::syscalls::___syscall180),
|
"___syscall180" => Function::new_env(store, env.clone(), crate::syscalls::___syscall180),
|
||||||
"___syscall181" => Function::new_env(store, env, crate::syscalls::___syscall181),
|
"___syscall181" => Function::new_env(store, env.clone(), crate::syscalls::___syscall181),
|
||||||
"___syscall183" => Function::new_env(store, env, crate::syscalls::___syscall183),
|
"___syscall183" => Function::new_env(store, env.clone(), crate::syscalls::___syscall183),
|
||||||
"___syscall191" => Function::new_env(store, env, crate::syscalls::___syscall191),
|
"___syscall191" => Function::new_env(store, env.clone(), crate::syscalls::___syscall191),
|
||||||
"___syscall192" => Function::new_env(store, env, crate::syscalls::___syscall192),
|
"___syscall192" => Function::new_env(store, env.clone(), crate::syscalls::___syscall192),
|
||||||
"___syscall193" => Function::new_env(store, env, crate::syscalls::___syscall193),
|
"___syscall193" => Function::new_env(store, env.clone(), crate::syscalls::___syscall193),
|
||||||
"___syscall194" => Function::new_env(store, env, crate::syscalls::___syscall194),
|
"___syscall194" => Function::new_env(store, env.clone(), crate::syscalls::___syscall194),
|
||||||
"___syscall195" => Function::new_env(store, env, crate::syscalls::___syscall195),
|
"___syscall195" => Function::new_env(store, env.clone(), crate::syscalls::___syscall195),
|
||||||
"___syscall196" => Function::new_env(store, env, crate::syscalls::___syscall196),
|
"___syscall196" => Function::new_env(store, env.clone(), crate::syscalls::___syscall196),
|
||||||
"___syscall197" => Function::new_env(store, env, crate::syscalls::___syscall197),
|
"___syscall197" => Function::new_env(store, env.clone(), crate::syscalls::___syscall197),
|
||||||
"___syscall198" => Function::new_env(store, env, crate::syscalls::___syscall198),
|
"___syscall198" => Function::new_env(store, env.clone(), crate::syscalls::___syscall198),
|
||||||
"___syscall199" => Function::new_env(store, env, crate::syscalls::___syscall199),
|
"___syscall199" => Function::new_env(store, env.clone(), crate::syscalls::___syscall199),
|
||||||
"___syscall200" => Function::new_env(store, env, crate::syscalls::___syscall200),
|
"___syscall200" => Function::new_env(store, env.clone(), crate::syscalls::___syscall200),
|
||||||
"___syscall201" => Function::new_env(store, env, crate::syscalls::___syscall201),
|
"___syscall201" => Function::new_env(store, env.clone(), crate::syscalls::___syscall201),
|
||||||
"___syscall202" => Function::new_env(store, env, crate::syscalls::___syscall202),
|
"___syscall202" => Function::new_env(store, env.clone(), crate::syscalls::___syscall202),
|
||||||
"___syscall205" => Function::new_env(store, env, crate::syscalls::___syscall205),
|
"___syscall205" => Function::new_env(store, env.clone(), crate::syscalls::___syscall205),
|
||||||
"___syscall207" => Function::new_env(store, env, crate::syscalls::___syscall207),
|
"___syscall207" => Function::new_env(store, env.clone(), crate::syscalls::___syscall207),
|
||||||
"___syscall209" => Function::new_env(store, env, crate::syscalls::___syscall209),
|
"___syscall209" => Function::new_env(store, env.clone(), crate::syscalls::___syscall209),
|
||||||
"___syscall211" => Function::new_env(store, env, crate::syscalls::___syscall211),
|
"___syscall211" => Function::new_env(store, env.clone(), crate::syscalls::___syscall211),
|
||||||
"___syscall212" => Function::new_env(store, env, crate::syscalls::___syscall212),
|
"___syscall212" => Function::new_env(store, env.clone(), crate::syscalls::___syscall212),
|
||||||
"___syscall218" => Function::new_env(store, env, crate::syscalls::___syscall218),
|
"___syscall218" => Function::new_env(store, env.clone(), crate::syscalls::___syscall218),
|
||||||
"___syscall219" => Function::new_env(store, env, crate::syscalls::___syscall219),
|
"___syscall219" => Function::new_env(store, env.clone(), crate::syscalls::___syscall219),
|
||||||
"___syscall220" => Function::new_env(store, env, crate::syscalls::___syscall220),
|
"___syscall220" => Function::new_env(store, env.clone(), crate::syscalls::___syscall220),
|
||||||
"___syscall221" => Function::new_env(store, env, crate::syscalls::___syscall221),
|
"___syscall221" => Function::new_env(store, env.clone(), crate::syscalls::___syscall221),
|
||||||
"___syscall268" => Function::new_env(store, env, crate::syscalls::___syscall268),
|
"___syscall268" => Function::new_env(store, env.clone(), crate::syscalls::___syscall268),
|
||||||
"___syscall269" => Function::new_env(store, env, crate::syscalls::___syscall269),
|
"___syscall269" => Function::new_env(store, env.clone(), crate::syscalls::___syscall269),
|
||||||
"___syscall272" => Function::new_env(store, env, crate::syscalls::___syscall272),
|
"___syscall272" => Function::new_env(store, env.clone(), crate::syscalls::___syscall272),
|
||||||
"___syscall295" => Function::new_env(store, env, crate::syscalls::___syscall295),
|
"___syscall295" => Function::new_env(store, env.clone(), crate::syscalls::___syscall295),
|
||||||
"___syscall296" => Function::new_env(store, env, crate::syscalls::___syscall296),
|
"___syscall296" => Function::new_env(store, env.clone(), crate::syscalls::___syscall296),
|
||||||
"___syscall297" => Function::new_env(store, env, crate::syscalls::___syscall297),
|
"___syscall297" => Function::new_env(store, env.clone(), crate::syscalls::___syscall297),
|
||||||
"___syscall298" => Function::new_env(store, env, crate::syscalls::___syscall298),
|
"___syscall298" => Function::new_env(store, env.clone(), crate::syscalls::___syscall298),
|
||||||
"___syscall300" => Function::new_env(store, env, crate::syscalls::___syscall300),
|
"___syscall300" => Function::new_env(store, env.clone(), crate::syscalls::___syscall300),
|
||||||
"___syscall301" => Function::new_env(store, env, crate::syscalls::___syscall301),
|
"___syscall301" => Function::new_env(store, env.clone(), crate::syscalls::___syscall301),
|
||||||
"___syscall302" => Function::new_env(store, env, crate::syscalls::___syscall302),
|
"___syscall302" => Function::new_env(store, env.clone(), crate::syscalls::___syscall302),
|
||||||
"___syscall303" => Function::new_env(store, env, crate::syscalls::___syscall303),
|
"___syscall303" => Function::new_env(store, env.clone(), crate::syscalls::___syscall303),
|
||||||
"___syscall304" => Function::new_env(store, env, crate::syscalls::___syscall304),
|
"___syscall304" => Function::new_env(store, env.clone(), crate::syscalls::___syscall304),
|
||||||
"___syscall305" => Function::new_env(store, env, crate::syscalls::___syscall305),
|
"___syscall305" => Function::new_env(store, env.clone(), crate::syscalls::___syscall305),
|
||||||
"___syscall306" => Function::new_env(store, env, crate::syscalls::___syscall306),
|
"___syscall306" => Function::new_env(store, env.clone(), crate::syscalls::___syscall306),
|
||||||
"___syscall307" => Function::new_env(store, env, crate::syscalls::___syscall307),
|
"___syscall307" => Function::new_env(store, env.clone(), crate::syscalls::___syscall307),
|
||||||
"___syscall308" => Function::new_env(store, env, crate::syscalls::___syscall308),
|
"___syscall308" => Function::new_env(store, env.clone(), crate::syscalls::___syscall308),
|
||||||
"___syscall320" => Function::new_env(store, env, crate::syscalls::___syscall320),
|
"___syscall320" => Function::new_env(store, env.clone(), crate::syscalls::___syscall320),
|
||||||
"___syscall324" => Function::new_env(store, env, crate::syscalls::___syscall324),
|
"___syscall324" => Function::new_env(store, env.clone(), crate::syscalls::___syscall324),
|
||||||
"___syscall330" => Function::new_env(store, env, crate::syscalls::___syscall330),
|
"___syscall330" => Function::new_env(store, env.clone(), crate::syscalls::___syscall330),
|
||||||
"___syscall331" => Function::new_env(store, env, crate::syscalls::___syscall331),
|
"___syscall331" => Function::new_env(store, env.clone(), crate::syscalls::___syscall331),
|
||||||
"___syscall333" => Function::new_env(store, env, crate::syscalls::___syscall333),
|
"___syscall333" => Function::new_env(store, env.clone(), crate::syscalls::___syscall333),
|
||||||
"___syscall334" => Function::new_env(store, env, crate::syscalls::___syscall334),
|
"___syscall334" => Function::new_env(store, env.clone(), crate::syscalls::___syscall334),
|
||||||
"___syscall337" => Function::new_env(store, env, crate::syscalls::___syscall337),
|
"___syscall337" => Function::new_env(store, env.clone(), crate::syscalls::___syscall337),
|
||||||
"___syscall340" => Function::new_env(store, env, crate::syscalls::___syscall340),
|
"___syscall340" => Function::new_env(store, env.clone(), crate::syscalls::___syscall340),
|
||||||
"___syscall345" => Function::new_env(store, env, crate::syscalls::___syscall345),
|
"___syscall345" => Function::new_env(store, env.clone(), crate::syscalls::___syscall345),
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
"abort" => Function::new_env(store, env, crate::process::em_abort),
|
"abort" => Function::new_env(store, env.clone(), crate::process::em_abort),
|
||||||
"_abort" => Function::new_env(store, env, crate::process::_abort),
|
"_abort" => Function::new_env(store, env.clone(), crate::process::_abort),
|
||||||
"_prctl" => Function::new_env(store, env, crate::process::_prctl),
|
"_prctl" => Function::new_env(store, env.clone(), crate::process::_prctl),
|
||||||
"abortStackOverflow" => Function::new_env(store, env, crate::process::abort_stack_overflow),
|
"abortStackOverflow" => Function::new_env(store, env.clone(), crate::process::abort_stack_overflow),
|
||||||
"_llvm_trap" => Function::new_env(store, env, crate::process::_llvm_trap),
|
"_llvm_trap" => Function::new_env(store, env.clone(), crate::process::_llvm_trap),
|
||||||
"_fork" => Function::new_env(store, env, crate::process::_fork),
|
"_fork" => Function::new_env(store, env.clone(), crate::process::_fork),
|
||||||
"_exit" => Function::new_env(store, env, crate::process::_exit),
|
"_exit" => Function::new_env(store, env.clone(), crate::process::_exit),
|
||||||
"_system" => Function::new_env(store, env, crate::process::_system),
|
"_system" => Function::new_env(store, env.clone(), crate::process::_system),
|
||||||
"_popen" => Function::new_env(store, env, crate::process::_popen),
|
"_popen" => Function::new_env(store, env.clone(), crate::process::_popen),
|
||||||
"_endgrent" => Function::new_env(store, env, crate::process::_endgrent),
|
"_endgrent" => Function::new_env(store, env.clone(), crate::process::_endgrent),
|
||||||
"_execve" => Function::new_env(store, env, crate::process::_execve),
|
"_execve" => Function::new_env(store, env.clone(), crate::process::_execve),
|
||||||
"_kill" => Function::new_env(store, env, crate::process::_kill),
|
"_kill" => Function::new_env(store, env.clone(), crate::process::_kill),
|
||||||
"_llvm_stackrestore" => Function::new_env(store, env, crate::process::_llvm_stackrestore),
|
"_llvm_stackrestore" => Function::new_env(store, env.clone(), crate::process::_llvm_stackrestore),
|
||||||
"_llvm_stacksave" => Function::new_env(store, env, crate::process::_llvm_stacksave),
|
"_llvm_stacksave" => Function::new_env(store, env.clone(), crate::process::_llvm_stacksave),
|
||||||
"_llvm_eh_typeid_for" => Function::new_env(store, env, crate::process::_llvm_eh_typeid_for),
|
"_llvm_eh_typeid_for" => Function::new_env(store, env.clone(), crate::process::_llvm_eh_typeid_for),
|
||||||
"_raise" => Function::new_env(store, env, crate::process::_raise),
|
"_raise" => Function::new_env(store, env.clone(), crate::process::_raise),
|
||||||
"_sem_init" => Function::new_env(store, env, crate::process::_sem_init),
|
"_sem_init" => Function::new_env(store, env.clone(), crate::process::_sem_init),
|
||||||
"_sem_destroy" => Function::new_env(store, env, crate::process::_sem_destroy),
|
"_sem_destroy" => Function::new_env(store, env.clone(), crate::process::_sem_destroy),
|
||||||
"_sem_post" => Function::new_env(store, env, crate::process::_sem_post),
|
"_sem_post" => Function::new_env(store, env.clone(), crate::process::_sem_post),
|
||||||
"_sem_wait" => Function::new_env(store, env, crate::process::_sem_wait),
|
"_sem_wait" => Function::new_env(store, env.clone(), crate::process::_sem_wait),
|
||||||
"_getgrent" => Function::new_env(store, env, crate::process::_getgrent),
|
"_getgrent" => Function::new_env(store, env.clone(), crate::process::_getgrent),
|
||||||
"_sched_yield" => Function::new_env(store, env, crate::process::_sched_yield),
|
"_sched_yield" => Function::new_env(store, env.clone(), crate::process::_sched_yield),
|
||||||
"_setgrent" => Function::new_env(store, env, crate::process::_setgrent),
|
"_setgrent" => Function::new_env(store, env.clone(), crate::process::_setgrent),
|
||||||
"_setgroups" => Function::new_env(store, env, crate::process::_setgroups),
|
"_setgroups" => Function::new_env(store, env.clone(), crate::process::_setgroups),
|
||||||
"_setitimer" => Function::new_env(store, env, crate::process::_setitimer),
|
"_setitimer" => Function::new_env(store, env.clone(), crate::process::_setitimer),
|
||||||
"_usleep" => Function::new_env(store, env, crate::process::_usleep),
|
"_usleep" => Function::new_env(store, env.clone(), crate::process::_usleep),
|
||||||
"_nanosleep" => Function::new_env(store, env, crate::process::_nanosleep),
|
"_nanosleep" => Function::new_env(store, env.clone(), crate::process::_nanosleep),
|
||||||
"_utime" => Function::new_env(store, env, crate::process::_utime),
|
"_utime" => Function::new_env(store, env.clone(), crate::process::_utime),
|
||||||
"_utimes" => Function::new_env(store, env, crate::process::_utimes),
|
"_utimes" => Function::new_env(store, env.clone(), crate::process::_utimes),
|
||||||
"_wait" => Function::new_env(store, env, crate::process::_wait),
|
"_wait" => Function::new_env(store, env.clone(), crate::process::_wait),
|
||||||
"_wait3" => Function::new_env(store, env, crate::process::_wait3),
|
"_wait3" => Function::new_env(store, env.clone(), crate::process::_wait3),
|
||||||
"_wait4" => Function::new_env(store, env, crate::process::_wait4),
|
"_wait4" => Function::new_env(store, env.clone(), crate::process::_wait4),
|
||||||
"_waitid" => Function::new_env(store, env, crate::process::_waitid),
|
"_waitid" => Function::new_env(store, env.clone(), crate::process::_waitid),
|
||||||
"_waitpid" => Function::new_env(store, env, crate::process::_waitpid),
|
"_waitpid" => Function::new_env(store, env.clone(), crate::process::_waitpid),
|
||||||
|
|
||||||
// Emscripten
|
// Emscripten
|
||||||
"_emscripten_asm_const_i" => Function::new_env(store, env, crate::emscripten_target::asm_const_i),
|
"_emscripten_asm_const_i" => Function::new_env(store, env.clone(), crate::emscripten_target::asm_const_i),
|
||||||
"_emscripten_exit_with_live_runtime" => Function::new_env(store, env, crate::emscripten_target::exit_with_live_runtime),
|
"_emscripten_exit_with_live_runtime" => Function::new_env(store, env.clone(), crate::emscripten_target::exit_with_live_runtime),
|
||||||
|
|
||||||
// Signal
|
// Signal
|
||||||
"_sigemptyset" => Function::new_env(store, env, crate::signal::_sigemptyset),
|
"_sigemptyset" => Function::new_env(store, env.clone(), crate::signal::_sigemptyset),
|
||||||
"_sigaddset" => Function::new_env(store, env, crate::signal::_sigaddset),
|
"_sigaddset" => Function::new_env(store, env.clone(), crate::signal::_sigaddset),
|
||||||
"_sigprocmask" => Function::new_env(store, env, crate::signal::_sigprocmask),
|
"_sigprocmask" => Function::new_env(store, env.clone(), crate::signal::_sigprocmask),
|
||||||
"_sigaction" => Function::new_env(store, env, crate::signal::_sigaction),
|
"_sigaction" => Function::new_env(store, env.clone(), crate::signal::_sigaction),
|
||||||
"_signal" => Function::new_env(store, env, crate::signal::_signal),
|
"_signal" => Function::new_env(store, env.clone(), crate::signal::_signal),
|
||||||
"_sigsuspend" => Function::new_env(store, env, crate::signal::_sigsuspend),
|
"_sigsuspend" => Function::new_env(store, env.clone(), crate::signal::_sigsuspend),
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
"abortOnCannotGrowMemory" => abort_on_cannot_grow_memory_export,
|
"abortOnCannotGrowMemory" => abort_on_cannot_grow_memory_export,
|
||||||
"_emscripten_memcpy_big" => Function::new_env(store, env, crate::memory::_emscripten_memcpy_big),
|
"_emscripten_memcpy_big" => Function::new_env(store, env.clone(), crate::memory::_emscripten_memcpy_big),
|
||||||
"_emscripten_get_heap_size" => Function::new_env(store, env, crate::memory::_emscripten_get_heap_size),
|
"_emscripten_get_heap_size" => Function::new_env(store, env.clone(), crate::memory::_emscripten_get_heap_size),
|
||||||
"_emscripten_resize_heap" => Function::new_env(store, env, crate::memory::_emscripten_resize_heap),
|
"_emscripten_resize_heap" => Function::new_env(store, env.clone(), crate::memory::_emscripten_resize_heap),
|
||||||
"enlargeMemory" => Function::new_env(store, env, crate::memory::enlarge_memory),
|
"enlargeMemory" => Function::new_env(store, env.clone(), crate::memory::enlarge_memory),
|
||||||
"segfault" => Function::new_env(store, env, crate::memory::segfault),
|
"segfault" => Function::new_env(store, env.clone(), crate::memory::segfault),
|
||||||
"alignfault" => Function::new_env(store, env, crate::memory::alignfault),
|
"alignfault" => Function::new_env(store, env.clone(), crate::memory::alignfault),
|
||||||
"ftfault" => Function::new_env(store, env, crate::memory::ftfault),
|
"ftfault" => Function::new_env(store, env.clone(), crate::memory::ftfault),
|
||||||
"getTotalMemory" => Function::new_env(store, env, crate::memory::get_total_memory),
|
"getTotalMemory" => Function::new_env(store, env.clone(), crate::memory::get_total_memory),
|
||||||
"_sbrk" => Function::new_env(store, env, crate::memory::sbrk),
|
"_sbrk" => Function::new_env(store, env.clone(), crate::memory::sbrk),
|
||||||
"___map_file" => Function::new_env(store, env, crate::memory::___map_file),
|
"___map_file" => Function::new_env(store, env.clone(), crate::memory::___map_file),
|
||||||
|
|
||||||
// Exception
|
// Exception
|
||||||
"___cxa_allocate_exception" => Function::new_env(store, env, crate::exception::___cxa_allocate_exception),
|
"___cxa_allocate_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_allocate_exception),
|
||||||
"___cxa_current_primary_exception" => Function::new_env(store, env, crate::exception::___cxa_current_primary_exception),
|
"___cxa_current_primary_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_current_primary_exception),
|
||||||
"___cxa_decrement_exception_refcount" => Function::new_env(store, env, crate::exception::___cxa_decrement_exception_refcount),
|
"___cxa_decrement_exception_refcount" => Function::new_env(store, env.clone(), crate::exception::___cxa_decrement_exception_refcount),
|
||||||
"___cxa_increment_exception_refcount" => Function::new_env(store, env, crate::exception::___cxa_increment_exception_refcount),
|
"___cxa_increment_exception_refcount" => Function::new_env(store, env.clone(), crate::exception::___cxa_increment_exception_refcount),
|
||||||
"___cxa_rethrow_primary_exception" => Function::new_env(store, env, crate::exception::___cxa_rethrow_primary_exception),
|
"___cxa_rethrow_primary_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_rethrow_primary_exception),
|
||||||
"___cxa_throw" => Function::new_env(store, env, crate::exception::___cxa_throw),
|
"___cxa_throw" => Function::new_env(store, env.clone(), crate::exception::___cxa_throw),
|
||||||
"___cxa_begin_catch" => Function::new_env(store, env, crate::exception::___cxa_begin_catch),
|
"___cxa_begin_catch" => Function::new_env(store, env.clone(), crate::exception::___cxa_begin_catch),
|
||||||
"___cxa_end_catch" => Function::new_env(store, env, crate::exception::___cxa_end_catch),
|
"___cxa_end_catch" => Function::new_env(store, env.clone(), crate::exception::___cxa_end_catch),
|
||||||
"___cxa_uncaught_exception" => Function::new_env(store, env, crate::exception::___cxa_uncaught_exception),
|
"___cxa_uncaught_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_uncaught_exception),
|
||||||
"___cxa_pure_virtual" => Function::new_env(store, env, crate::exception::___cxa_pure_virtual),
|
"___cxa_pure_virtual" => Function::new_env(store, env.clone(), crate::exception::___cxa_pure_virtual),
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
"_gettimeofday" => Function::new_env(store, env, crate::time::_gettimeofday),
|
"_gettimeofday" => Function::new_env(store, env.clone(), crate::time::_gettimeofday),
|
||||||
"_clock_getres" => Function::new_env(store, env, crate::time::_clock_getres),
|
"_clock_getres" => Function::new_env(store, env.clone(), crate::time::_clock_getres),
|
||||||
"_clock_gettime" => Function::new_env(store, env, crate::time::_clock_gettime),
|
"_clock_gettime" => Function::new_env(store, env.clone(), crate::time::_clock_gettime),
|
||||||
"_clock_settime" => Function::new_env(store, env, crate::time::_clock_settime),
|
"_clock_settime" => Function::new_env(store, env.clone(), crate::time::_clock_settime),
|
||||||
"___clock_gettime" => Function::new_env(store, env, crate::time::_clock_gettime),
|
"___clock_gettime" => Function::new_env(store, env.clone(), crate::time::_clock_gettime),
|
||||||
"_clock" => Function::new_env(store, env, crate::time::_clock),
|
"_clock" => Function::new_env(store, env.clone(), crate::time::_clock),
|
||||||
"_difftime" => Function::new_env(store, env, crate::time::_difftime),
|
"_difftime" => Function::new_env(store, env.clone(), crate::time::_difftime),
|
||||||
"_asctime" => Function::new_env(store, env, crate::time::_asctime),
|
"_asctime" => Function::new_env(store, env.clone(), crate::time::_asctime),
|
||||||
"_asctime_r" => Function::new_env(store, env, crate::time::_asctime_r),
|
"_asctime_r" => Function::new_env(store, env.clone(), crate::time::_asctime_r),
|
||||||
"_localtime" => Function::new_env(store, env, crate::time::_localtime),
|
"_localtime" => Function::new_env(store, env.clone(), crate::time::_localtime),
|
||||||
"_time" => Function::new_env(store, env, crate::time::_time),
|
"_time" => Function::new_env(store, env.clone(), crate::time::_time),
|
||||||
"_timegm" => Function::new_env(store, env, crate::time::_timegm),
|
"_timegm" => Function::new_env(store, env.clone(), crate::time::_timegm),
|
||||||
"_strftime" => Function::new_env(store, env, crate::time::_strftime),
|
"_strftime" => Function::new_env(store, env.clone(), crate::time::_strftime),
|
||||||
"_strftime_l" => Function::new_env(store, env, crate::time::_strftime_l),
|
"_strftime_l" => Function::new_env(store, env.clone(), crate::time::_strftime_l),
|
||||||
"_localtime_r" => Function::new_env(store, env, crate::time::_localtime_r),
|
"_localtime_r" => Function::new_env(store, env.clone(), crate::time::_localtime_r),
|
||||||
"_gmtime_r" => Function::new_env(store, env, crate::time::_gmtime_r),
|
"_gmtime_r" => Function::new_env(store, env.clone(), crate::time::_gmtime_r),
|
||||||
"_ctime" => Function::new_env(store, env, crate::time::_ctime),
|
"_ctime" => Function::new_env(store, env.clone(), crate::time::_ctime),
|
||||||
"_ctime_r" => Function::new_env(store, env, crate::time::_ctime_r),
|
"_ctime_r" => Function::new_env(store, env.clone(), crate::time::_ctime_r),
|
||||||
"_mktime" => Function::new_env(store, env, crate::time::_mktime),
|
"_mktime" => Function::new_env(store, env.clone(), crate::time::_mktime),
|
||||||
"_gmtime" => Function::new_env(store, env, crate::time::_gmtime),
|
"_gmtime" => Function::new_env(store, env.clone(), crate::time::_gmtime),
|
||||||
|
|
||||||
// Math
|
// Math
|
||||||
"sqrt" => Function::new(store, crate::math::sqrt),
|
"sqrt" => Function::new(store, crate::math::sqrt),
|
||||||
@@ -937,16 +946,16 @@ pub fn generate_emscripten_env(
|
|||||||
"_llvm_exp2_f64" => Function::new(store, crate::math::_llvm_exp2_f64),
|
"_llvm_exp2_f64" => Function::new(store, crate::math::_llvm_exp2_f64),
|
||||||
"_llvm_trunc_f64" => Function::new(store, crate::math::_llvm_trunc_f64),
|
"_llvm_trunc_f64" => Function::new(store, crate::math::_llvm_trunc_f64),
|
||||||
"_llvm_fma_f64" => Function::new(store, crate::math::_llvm_fma_f64),
|
"_llvm_fma_f64" => Function::new(store, crate::math::_llvm_fma_f64),
|
||||||
"_emscripten_random" => Function::new_env(store, env, crate::math::_emscripten_random),
|
"_emscripten_random" => Function::new_env(store, env.clone(), crate::math::_emscripten_random),
|
||||||
|
|
||||||
// Jump
|
// Jump
|
||||||
"__setjmp" => Function::new_env(store, env, crate::jmp::__setjmp),
|
"__setjmp" => Function::new_env(store, env.clone(), crate::jmp::__setjmp),
|
||||||
"__longjmp" => Function::new_env(store, env, crate::jmp::__longjmp),
|
"__longjmp" => Function::new_env(store, env.clone(), crate::jmp::__longjmp),
|
||||||
"_longjmp" => Function::new_env(store, env, crate::jmp::_longjmp),
|
"_longjmp" => Function::new_env(store, env.clone(), crate::jmp::_longjmp),
|
||||||
"_emscripten_longjmp" => Function::new_env(store, env, crate::jmp::_longjmp),
|
"_emscripten_longjmp" => Function::new_env(store, env.clone(), crate::jmp::_longjmp),
|
||||||
|
|
||||||
// Bitwise
|
// Bitwise
|
||||||
"_llvm_bswap_i64" => Function::new_env(store, env, crate::bitwise::_llvm_bswap_i64),
|
"_llvm_bswap_i64" => Function::new_env(store, env.clone(), crate::bitwise::_llvm_bswap_i64),
|
||||||
|
|
||||||
// libc
|
// libc
|
||||||
"_execv" => Function::new(store, crate::libc::execv),
|
"_execv" => Function::new(store, crate::libc::execv),
|
||||||
@@ -956,8 +965,8 @@ pub fn generate_emscripten_env(
|
|||||||
"_getitimer" => Function::new(store, crate::libc::getitimer),
|
"_getitimer" => Function::new(store, crate::libc::getitimer),
|
||||||
"_getpwent" => Function::new(store, crate::libc::getpwent),
|
"_getpwent" => Function::new(store, crate::libc::getpwent),
|
||||||
"_killpg" => Function::new(store, crate::libc::killpg),
|
"_killpg" => Function::new(store, crate::libc::killpg),
|
||||||
"_pathconf" => Function::new_env(store, env, crate::libc::pathconf),
|
"_pathconf" => Function::new_env(store, env.clone(), crate::libc::pathconf),
|
||||||
"_siginterrupt" => Function::new_env(store, env, crate::signal::_siginterrupt),
|
"_siginterrupt" => Function::new_env(store, env.clone(), crate::signal::_siginterrupt),
|
||||||
"_setpwent" => Function::new(store, crate::libc::setpwent),
|
"_setpwent" => Function::new(store, crate::libc::setpwent),
|
||||||
"_sigismember" => Function::new(store, crate::libc::sigismember),
|
"_sigismember" => Function::new(store, crate::libc::sigismember),
|
||||||
"_sigpending" => Function::new(store, crate::libc::sigpending),
|
"_sigpending" => Function::new(store, crate::libc::sigpending),
|
||||||
@@ -965,131 +974,131 @@ pub fn generate_emscripten_env(
|
|||||||
"___libc_current_sigrtmin" => Function::new(store, crate::libc::current_sigrtmin),
|
"___libc_current_sigrtmin" => Function::new(store, crate::libc::current_sigrtmin),
|
||||||
|
|
||||||
// Linking
|
// Linking
|
||||||
"_dlclose" => Function::new_env(store, env, crate::linking::_dlclose),
|
"_dlclose" => Function::new_env(store, env.clone(), crate::linking::_dlclose),
|
||||||
"_dlerror" => Function::new_env(store, env, crate::linking::_dlerror),
|
"_dlerror" => Function::new_env(store, env.clone(), crate::linking::_dlerror),
|
||||||
"_dlopen" => Function::new_env(store, env, crate::linking::_dlopen),
|
"_dlopen" => Function::new_env(store, env.clone(), crate::linking::_dlopen),
|
||||||
"_dlsym" => Function::new_env(store, env, crate::linking::_dlsym),
|
"_dlsym" => Function::new_env(store, env.clone(), crate::linking::_dlsym),
|
||||||
|
|
||||||
// wasm32-unknown-emscripten
|
// wasm32-unknown-emscripten
|
||||||
"_alarm" => Function::new_env(store, env, crate::emscripten_target::_alarm),
|
"_alarm" => Function::new_env(store, env.clone(), crate::emscripten_target::_alarm),
|
||||||
"_atexit" => Function::new_env(store, env, crate::emscripten_target::_atexit),
|
"_atexit" => Function::new_env(store, env.clone(), crate::emscripten_target::_atexit),
|
||||||
"setTempRet0" => Function::new_env(store, env, crate::emscripten_target::setTempRet0),
|
"setTempRet0" => Function::new_env(store, env.clone(), crate::emscripten_target::setTempRet0),
|
||||||
"getTempRet0" => Function::new_env(store, env, crate::emscripten_target::getTempRet0),
|
"getTempRet0" => Function::new_env(store, env.clone(), crate::emscripten_target::getTempRet0),
|
||||||
"invoke_i" => Function::new_env(store, env, crate::emscripten_target::invoke_i),
|
"invoke_i" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_i),
|
||||||
"invoke_ii" => Function::new_env(store, env, crate::emscripten_target::invoke_ii),
|
"invoke_ii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_ii),
|
||||||
"invoke_iii" => Function::new_env(store, env, crate::emscripten_target::invoke_iii),
|
"invoke_iii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iii),
|
||||||
"invoke_iiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiii),
|
"invoke_iiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiii),
|
||||||
"invoke_iifi" => Function::new_env(store, env, crate::emscripten_target::invoke_iifi),
|
"invoke_iifi" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iifi),
|
||||||
"invoke_v" => Function::new_env(store, env, crate::emscripten_target::invoke_v),
|
"invoke_v" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_v),
|
||||||
"invoke_vi" => Function::new_env(store, env, crate::emscripten_target::invoke_vi),
|
"invoke_vi" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vi),
|
||||||
"invoke_vj" => Function::new_env(store, env, crate::emscripten_target::invoke_vj),
|
"invoke_vj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vj),
|
||||||
"invoke_vjji" => Function::new_env(store, env, crate::emscripten_target::invoke_vjji),
|
"invoke_vjji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vjji),
|
||||||
"invoke_vii" => Function::new_env(store, env, crate::emscripten_target::invoke_vii),
|
"invoke_vii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vii),
|
||||||
"invoke_viii" => Function::new_env(store, env, crate::emscripten_target::invoke_viii),
|
"invoke_viii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viii),
|
||||||
"invoke_viiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiii),
|
"invoke_viiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiii),
|
||||||
"__Unwind_Backtrace" => Function::new_env(store, env, crate::emscripten_target::__Unwind_Backtrace),
|
"__Unwind_Backtrace" => Function::new_env(store, env.clone(), crate::emscripten_target::__Unwind_Backtrace),
|
||||||
"__Unwind_FindEnclosingFunction" => Function::new_env(store, env, crate::emscripten_target::__Unwind_FindEnclosingFunction),
|
"__Unwind_FindEnclosingFunction" => Function::new_env(store, env.clone(), crate::emscripten_target::__Unwind_FindEnclosingFunction),
|
||||||
"__Unwind_GetIPInfo" => Function::new_env(store, env, crate::emscripten_target::__Unwind_GetIPInfo),
|
"__Unwind_GetIPInfo" => Function::new_env(store, env.clone(), crate::emscripten_target::__Unwind_GetIPInfo),
|
||||||
"___cxa_find_matching_catch_2" => Function::new_env(store, env, crate::emscripten_target::___cxa_find_matching_catch_2),
|
"___cxa_find_matching_catch_2" => Function::new_env(store, env.clone(), crate::emscripten_target::___cxa_find_matching_catch_2),
|
||||||
"___cxa_find_matching_catch_3" => Function::new_env(store, env, crate::emscripten_target::___cxa_find_matching_catch_3),
|
"___cxa_find_matching_catch_3" => Function::new_env(store, env.clone(), crate::emscripten_target::___cxa_find_matching_catch_3),
|
||||||
"___cxa_free_exception" => Function::new_env(store, env, crate::emscripten_target::___cxa_free_exception),
|
"___cxa_free_exception" => Function::new_env(store, env.clone(), crate::emscripten_target::___cxa_free_exception),
|
||||||
"___resumeException" => Function::new_env(store, env, crate::emscripten_target::___resumeException),
|
"___resumeException" => Function::new_env(store, env.clone(), crate::emscripten_target::___resumeException),
|
||||||
"_dladdr" => Function::new_env(store, env, crate::emscripten_target::_dladdr),
|
"_dladdr" => Function::new_env(store, env.clone(), crate::emscripten_target::_dladdr),
|
||||||
"_pthread_attr_destroy" => Function::new_env(store, env, crate::pthread::_pthread_attr_destroy),
|
"_pthread_attr_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_destroy),
|
||||||
"_pthread_attr_getstack" => Function::new_env(store, env, crate::pthread::_pthread_attr_getstack),
|
"_pthread_attr_getstack" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_getstack),
|
||||||
"_pthread_attr_init" => Function::new_env(store, env, crate::pthread::_pthread_attr_init),
|
"_pthread_attr_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_init),
|
||||||
"_pthread_attr_setstacksize" => Function::new_env(store, env, crate::pthread::_pthread_attr_setstacksize),
|
"_pthread_attr_setstacksize" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_setstacksize),
|
||||||
"_pthread_cleanup_pop" => Function::new_env(store, env, crate::pthread::_pthread_cleanup_pop),
|
"_pthread_cleanup_pop" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cleanup_pop),
|
||||||
"_pthread_cleanup_push" => Function::new_env(store, env, crate::pthread::_pthread_cleanup_push),
|
"_pthread_cleanup_push" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cleanup_push),
|
||||||
"_pthread_cond_destroy" => Function::new_env(store, env, crate::pthread::_pthread_cond_destroy),
|
"_pthread_cond_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_destroy),
|
||||||
"_pthread_cond_init" => Function::new_env(store, env, crate::pthread::_pthread_cond_init),
|
"_pthread_cond_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_init),
|
||||||
"_pthread_cond_signal" => Function::new_env(store, env, crate::pthread::_pthread_cond_signal),
|
"_pthread_cond_signal" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_signal),
|
||||||
"_pthread_cond_timedwait" => Function::new_env(store, env, crate::pthread::_pthread_cond_timedwait),
|
"_pthread_cond_timedwait" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_timedwait),
|
||||||
"_pthread_cond_wait" => Function::new_env(store, env, crate::pthread::_pthread_cond_wait),
|
"_pthread_cond_wait" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_wait),
|
||||||
"_pthread_condattr_destroy" => Function::new_env(store, env, crate::pthread::_pthread_condattr_destroy),
|
"_pthread_condattr_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_condattr_destroy),
|
||||||
"_pthread_condattr_init" => Function::new_env(store, env, crate::pthread::_pthread_condattr_init),
|
"_pthread_condattr_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_condattr_init),
|
||||||
"_pthread_condattr_setclock" => Function::new_env(store, env, crate::pthread::_pthread_condattr_setclock),
|
"_pthread_condattr_setclock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_condattr_setclock),
|
||||||
"_pthread_create" => Function::new_env(store, env, crate::pthread::_pthread_create),
|
"_pthread_create" => Function::new_env(store, env.clone(), crate::pthread::_pthread_create),
|
||||||
"_pthread_detach" => Function::new_env(store, env, crate::pthread::_pthread_detach),
|
"_pthread_detach" => Function::new_env(store, env.clone(), crate::pthread::_pthread_detach),
|
||||||
"_pthread_equal" => Function::new_env(store, env, crate::pthread::_pthread_equal),
|
"_pthread_equal" => Function::new_env(store, env.clone(), crate::pthread::_pthread_equal),
|
||||||
"_pthread_exit" => Function::new_env(store, env, crate::pthread::_pthread_exit),
|
"_pthread_exit" => Function::new_env(store, env.clone(), crate::pthread::_pthread_exit),
|
||||||
"_pthread_self" => Function::new_env(store, env, crate::pthread::_pthread_self),
|
"_pthread_self" => Function::new_env(store, env.clone(), crate::pthread::_pthread_self),
|
||||||
"_pthread_getattr_np" => Function::new_env(store, env, crate::pthread::_pthread_getattr_np),
|
"_pthread_getattr_np" => Function::new_env(store, env.clone(), crate::pthread::_pthread_getattr_np),
|
||||||
"_pthread_getspecific" => Function::new_env(store, env, crate::pthread::_pthread_getspecific),
|
"_pthread_getspecific" => Function::new_env(store, env.clone(), crate::pthread::_pthread_getspecific),
|
||||||
"_pthread_join" => Function::new_env(store, env, crate::pthread::_pthread_join),
|
"_pthread_join" => Function::new_env(store, env.clone(), crate::pthread::_pthread_join),
|
||||||
"_pthread_key_create" => Function::new_env(store, env, crate::pthread::_pthread_key_create),
|
"_pthread_key_create" => Function::new_env(store, env.clone(), crate::pthread::_pthread_key_create),
|
||||||
"_pthread_mutex_destroy" => Function::new_env(store, env, crate::pthread::_pthread_mutex_destroy),
|
"_pthread_mutex_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutex_destroy),
|
||||||
"_pthread_mutex_init" => Function::new_env(store, env, crate::pthread::_pthread_mutex_init),
|
"_pthread_mutex_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutex_init),
|
||||||
"_pthread_mutexattr_destroy" => Function::new_env(store, env, crate::pthread::_pthread_mutexattr_destroy),
|
"_pthread_mutexattr_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutexattr_destroy),
|
||||||
"_pthread_mutexattr_init" => Function::new_env(store, env, crate::pthread::_pthread_mutexattr_init),
|
"_pthread_mutexattr_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutexattr_init),
|
||||||
"_pthread_mutexattr_settype" => Function::new_env(store, env, crate::pthread::_pthread_mutexattr_settype),
|
"_pthread_mutexattr_settype" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutexattr_settype),
|
||||||
"_pthread_once" => Function::new_env(store, env, crate::pthread::_pthread_once),
|
"_pthread_once" => Function::new_env(store, env.clone(), crate::pthread::_pthread_once),
|
||||||
"_pthread_rwlock_destroy" => Function::new_env(store, env, crate::pthread::_pthread_rwlock_destroy),
|
"_pthread_rwlock_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_destroy),
|
||||||
"_pthread_rwlock_init" => Function::new_env(store, env, crate::pthread::_pthread_rwlock_init),
|
"_pthread_rwlock_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_init),
|
||||||
"_pthread_rwlock_rdlock" => Function::new_env(store, env, crate::pthread::_pthread_rwlock_rdlock),
|
"_pthread_rwlock_rdlock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_rdlock),
|
||||||
"_pthread_rwlock_unlock" => Function::new_env(store, env, crate::pthread::_pthread_rwlock_unlock),
|
"_pthread_rwlock_unlock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_unlock),
|
||||||
"_pthread_rwlock_wrlock" => Function::new_env(store, env, crate::pthread::_pthread_rwlock_wrlock),
|
"_pthread_rwlock_wrlock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_wrlock),
|
||||||
"_pthread_setcancelstate" => Function::new_env(store, env, crate::pthread::_pthread_setcancelstate),
|
"_pthread_setcancelstate" => Function::new_env(store, env.clone(), crate::pthread::_pthread_setcancelstate),
|
||||||
"_pthread_setspecific" => Function::new_env(store, env, crate::pthread::_pthread_setspecific),
|
"_pthread_setspecific" => Function::new_env(store, env.clone(), crate::pthread::_pthread_setspecific),
|
||||||
"_pthread_sigmask" => Function::new_env(store, env, crate::pthread::_pthread_sigmask),
|
"_pthread_sigmask" => Function::new_env(store, env.clone(), crate::pthread::_pthread_sigmask),
|
||||||
"___gxx_personality_v0" => Function::new_env(store, env, crate::emscripten_target::___gxx_personality_v0),
|
"___gxx_personality_v0" => Function::new_env(store, env.clone(), crate::emscripten_target::___gxx_personality_v0),
|
||||||
"_gai_strerror" => Function::new_env(store, env, crate::env::_gai_strerror),
|
"_gai_strerror" => Function::new_env(store, env.clone(), crate::env::_gai_strerror),
|
||||||
"_getdtablesize" => Function::new_env(store, env, crate::emscripten_target::_getdtablesize),
|
"_getdtablesize" => Function::new_env(store, env.clone(), crate::emscripten_target::_getdtablesize),
|
||||||
"_gethostbyaddr" => Function::new_env(store, env, crate::emscripten_target::_gethostbyaddr),
|
"_gethostbyaddr" => Function::new_env(store, env.clone(), crate::emscripten_target::_gethostbyaddr),
|
||||||
"_gethostbyname" => Function::new_env(store, env, crate::emscripten_target::_gethostbyname),
|
"_gethostbyname" => Function::new_env(store, env.clone(), crate::emscripten_target::_gethostbyname),
|
||||||
"_gethostbyname_r" => Function::new_env(store, env, crate::emscripten_target::_gethostbyname_r),
|
"_gethostbyname_r" => Function::new_env(store, env.clone(), crate::emscripten_target::_gethostbyname_r),
|
||||||
"_getloadavg" => Function::new_env(store, env, crate::emscripten_target::_getloadavg),
|
"_getloadavg" => Function::new_env(store, env.clone(), crate::emscripten_target::_getloadavg),
|
||||||
"_getnameinfo" => Function::new_env(store, env, crate::emscripten_target::_getnameinfo),
|
"_getnameinfo" => Function::new_env(store, env.clone(), crate::emscripten_target::_getnameinfo),
|
||||||
"invoke_dii" => Function::new_env(store, env, crate::emscripten_target::invoke_dii),
|
"invoke_dii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_dii),
|
||||||
"invoke_diiii" => Function::new_env(store, env, crate::emscripten_target::invoke_diiii),
|
"invoke_diiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_diiii),
|
||||||
"invoke_iiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiiii),
|
"invoke_iiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiii),
|
||||||
"invoke_iiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiiiii),
|
"invoke_iiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiii),
|
||||||
"invoke_iiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiiiiii),
|
"invoke_iiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiii),
|
||||||
"invoke_iiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiiiiiii),
|
"invoke_iiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiii),
|
||||||
"invoke_iiiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiiiiiiii),
|
"invoke_iiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiii),
|
||||||
"invoke_iiiiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiiiiiiiii),
|
"invoke_iiiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiiii),
|
||||||
"invoke_iiiiiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_iiiiiiiiiii),
|
"invoke_iiiiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiiiii),
|
||||||
"invoke_vd" => Function::new_env(store, env, crate::emscripten_target::invoke_vd),
|
"invoke_vd" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vd),
|
||||||
"invoke_viiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiiii),
|
"invoke_viiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiii),
|
||||||
"invoke_viiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiiiii),
|
"invoke_viiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiii),
|
||||||
"invoke_viiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiiiiii),
|
"invoke_viiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiii),
|
||||||
"invoke_viiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiiiiiii),
|
"invoke_viiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiii),
|
||||||
"invoke_viiiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiiiiiiii),
|
"invoke_viiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiii),
|
||||||
"invoke_viiiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiiiiiiii),
|
"invoke_viiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiii),
|
||||||
"invoke_viiiiiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiiiiiiiii),
|
"invoke_viiiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiiii),
|
||||||
"invoke_iij" => Function::new_env(store, env, crate::emscripten_target::invoke_iij),
|
"invoke_iij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iij),
|
||||||
"invoke_iji" => Function::new_env(store, env, crate::emscripten_target::invoke_iji),
|
"invoke_iji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iji),
|
||||||
"invoke_iiji" => Function::new_env(store, env, crate::emscripten_target::invoke_iiji),
|
"invoke_iiji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiji),
|
||||||
"invoke_iiijj" => Function::new_env(store, env, crate::emscripten_target::invoke_iiijj),
|
"invoke_iiijj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiijj),
|
||||||
"invoke_j" => Function::new_env(store, env, crate::emscripten_target::invoke_j),
|
"invoke_j" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_j),
|
||||||
"invoke_ji" => Function::new_env(store, env, crate::emscripten_target::invoke_ji),
|
"invoke_ji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_ji),
|
||||||
"invoke_jii" => Function::new_env(store, env, crate::emscripten_target::invoke_jii),
|
"invoke_jii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_jii),
|
||||||
"invoke_jij" => Function::new_env(store, env, crate::emscripten_target::invoke_jij),
|
"invoke_jij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_jij),
|
||||||
"invoke_jjj" => Function::new_env(store, env, crate::emscripten_target::invoke_jjj),
|
"invoke_jjj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_jjj),
|
||||||
"invoke_viiij" => Function::new_env(store, env, crate::emscripten_target::invoke_viiij),
|
"invoke_viiij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiij),
|
||||||
"invoke_viiijiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiijiiii),
|
"invoke_viiijiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiijiiii),
|
||||||
"invoke_viiijiiiiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viiijiiiiii),
|
"invoke_viiijiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiijiiiiii),
|
||||||
"invoke_viij" => Function::new_env(store, env, crate::emscripten_target::invoke_viij),
|
"invoke_viij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viij),
|
||||||
"invoke_viiji" => Function::new_env(store, env, crate::emscripten_target::invoke_viiji),
|
"invoke_viiji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiji),
|
||||||
"invoke_viijiii" => Function::new_env(store, env, crate::emscripten_target::invoke_viijiii),
|
"invoke_viijiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viijiii),
|
||||||
"invoke_viijj" => Function::new_env(store, env, crate::emscripten_target::invoke_viijj),
|
"invoke_viijj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viijj),
|
||||||
"invoke_vij" => Function::new_env(store, env, crate::emscripten_target::invoke_vij),
|
"invoke_vij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vij),
|
||||||
"invoke_viji" => Function::new_env(store, env, crate::emscripten_target::invoke_viji),
|
"invoke_viji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viji),
|
||||||
"invoke_vijiii" => Function::new_env(store, env, crate::emscripten_target::invoke_vijiii),
|
"invoke_vijiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vijiii),
|
||||||
"invoke_vijj" => Function::new_env(store, env, crate::emscripten_target::invoke_vijj),
|
"invoke_vijj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vijj),
|
||||||
"invoke_vidd" => Function::new_env(store, env, crate::emscripten_target::invoke_vidd),
|
"invoke_vidd" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vidd),
|
||||||
"invoke_viid" => Function::new_env(store, env, crate::emscripten_target::invoke_viid),
|
"invoke_viid" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viid),
|
||||||
"invoke_viidii" => Function::new_env(store, env, crate::emscripten_target::invoke_viidii),
|
"invoke_viidii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viidii),
|
||||||
"invoke_viidddddddd" => Function::new_env(store, env, crate::emscripten_target::invoke_viidddddddd),
|
"invoke_viidddddddd" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viidddddddd),
|
||||||
|
|
||||||
// ucontext
|
// ucontext
|
||||||
"_getcontext" => Function::new_env(store, env, crate::ucontext::_getcontext),
|
"_getcontext" => Function::new_env(store, env.clone(), crate::ucontext::_getcontext),
|
||||||
"_makecontext" => Function::new_env(store, env, crate::ucontext::_makecontext),
|
"_makecontext" => Function::new_env(store, env.clone(), crate::ucontext::_makecontext),
|
||||||
"_setcontext" => Function::new_env(store, env, crate::ucontext::_setcontext),
|
"_setcontext" => Function::new_env(store, env.clone(), crate::ucontext::_setcontext),
|
||||||
"_swapcontext" => Function::new_env(store, env, crate::ucontext::_swapcontext),
|
"_swapcontext" => Function::new_env(store, env.clone(), crate::ucontext::_swapcontext),
|
||||||
|
|
||||||
// unistd
|
// unistd
|
||||||
"_confstr" => Function::new_env(store, env, crate::unistd::confstr),
|
"_confstr" => Function::new_env(store, env.clone(), crate::unistd::confstr),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Compatibility with newer versions of Emscripten
|
// Compatibility with newer versions of Emscripten
|
||||||
@@ -1110,7 +1119,7 @@ pub fn generate_emscripten_env(
|
|||||||
for null_func_name in globals.null_func_names.iter() {
|
for null_func_name in globals.null_func_names.iter() {
|
||||||
env_ns.insert(
|
env_ns.insert(
|
||||||
null_func_name.as_str(),
|
null_func_name.as_str(),
|
||||||
Function::new_env(store, env, nullfunc),
|
Function::new_env(store, env.clone(), nullfunc),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ pub use crate::utils::{get_wasi_version, is_wasi_module, WasiVersion};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmer::{imports, Function, ImportObject, Memory, Module, Store};
|
use wasmer::{imports, Function, ImportObject, Memory, Module, Store};
|
||||||
|
|
||||||
|
use std::sync::{Arc, Mutex, MutexGuard};
|
||||||
|
|
||||||
/// This is returned in `RuntimeError`.
|
/// This is returned in `RuntimeError`.
|
||||||
/// Use `downcast` or `downcast_ref` to retrieve the `ExitCode`.
|
/// Use `downcast` or `downcast_ref` to retrieve the `ExitCode`.
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
@@ -40,15 +42,16 @@ pub enum WasiError {
|
|||||||
|
|
||||||
/// The environment provided to the WASI imports.
|
/// The environment provided to the WASI imports.
|
||||||
/// It
|
/// It
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct WasiEnv<'a> {
|
pub struct WasiEnv<'a> {
|
||||||
state: WasiState,
|
state: Arc<Mutex<WasiState>>,
|
||||||
memory: Option<&'a Memory>,
|
memory: Option<&'a Memory>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WasiEnv<'a> {
|
impl<'a> WasiEnv<'a> {
|
||||||
pub fn new(state: WasiState) -> Self {
|
pub fn new(state: WasiState) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state,
|
state: Arc::new(Mutex::new(state)),
|
||||||
memory: None,
|
memory: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +60,7 @@ impl<'a> WasiEnv<'a> {
|
|||||||
let wasi_version = get_wasi_version(module, false).ok_or(WasiError::UnknownWasiVersion)?;
|
let wasi_version = get_wasi_version(module, false).ok_or(WasiError::UnknownWasiVersion)?;
|
||||||
Ok(generate_import_object_from_env(
|
Ok(generate_import_object_from_env(
|
||||||
module.store(),
|
module.store(),
|
||||||
self,
|
self.clone(),
|
||||||
wasi_version,
|
wasi_version,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -68,13 +71,13 @@ impl<'a> WasiEnv<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the WASI state
|
/// Get the WASI state
|
||||||
pub fn state(&self) -> &WasiState {
|
pub fn state(&self) -> MutexGuard<WasiState> {
|
||||||
&self.state
|
self.state.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the WASI state (mutable)
|
/// Get the WASI state (mutable)
|
||||||
pub fn state_mut(&mut self) -> &mut WasiState {
|
pub fn state_mut(&mut self) -> MutexGuard<WasiState> {
|
||||||
&mut self.state
|
self.state.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a reference to the memory
|
/// Get a reference to the memory
|
||||||
@@ -85,9 +88,9 @@ impl<'a> WasiEnv<'a> {
|
|||||||
pub(crate) fn get_memory_and_wasi_state(
|
pub(crate) fn get_memory_and_wasi_state(
|
||||||
&mut self,
|
&mut self,
|
||||||
_mem_index: u32,
|
_mem_index: u32,
|
||||||
) -> (&Memory, &mut WasiState) {
|
) -> (&Memory, MutexGuard<WasiState>) {
|
||||||
let memory = self.memory.as_ref().unwrap();
|
let memory = self.memory.as_ref().unwrap();
|
||||||
let state = &mut self.state;
|
let state = self.state.lock().unwrap();
|
||||||
(memory, state)
|
(memory, state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +99,7 @@ impl<'a> WasiEnv<'a> {
|
|||||||
/// can be constructed from a [`WasiStateBuilder`](state::WasiStateBuilder).
|
/// can be constructed from a [`WasiStateBuilder`](state::WasiStateBuilder).
|
||||||
pub fn generate_import_object_from_env(
|
pub fn generate_import_object_from_env(
|
||||||
store: &Store,
|
store: &Store,
|
||||||
wasi_env: &mut WasiEnv,
|
wasi_env: WasiEnv,
|
||||||
version: WasiVersion,
|
version: WasiVersion,
|
||||||
) -> ImportObject {
|
) -> ImportObject {
|
||||||
match version {
|
match version {
|
||||||
@@ -108,107 +111,107 @@ pub fn generate_import_object_from_env(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Combines a state generating function with the import list for legacy WASI
|
/// Combines a state generating function with the import list for legacy WASI
|
||||||
fn generate_import_object_snapshot0(store: &Store, env: &mut WasiEnv) -> ImportObject {
|
fn generate_import_object_snapshot0(store: &Store, env: WasiEnv) -> ImportObject {
|
||||||
imports! {
|
imports! {
|
||||||
"wasi_unstable" => {
|
"wasi_unstable" => {
|
||||||
"args_get" => Function::new_env(store, env, args_get),
|
"args_get" => Function::new_env(store, env.clone(), args_get),
|
||||||
"args_sizes_get" => Function::new_env(store, env, args_sizes_get),
|
"args_sizes_get" => Function::new_env(store, env.clone(), args_sizes_get),
|
||||||
"clock_res_get" => Function::new_env(store, env, clock_res_get),
|
"clock_res_get" => Function::new_env(store, env.clone(), clock_res_get),
|
||||||
"clock_time_get" => Function::new_env(store, env, clock_time_get),
|
"clock_time_get" => Function::new_env(store, env.clone(), clock_time_get),
|
||||||
"environ_get" => Function::new_env(store, env, environ_get),
|
"environ_get" => Function::new_env(store, env.clone(), environ_get),
|
||||||
"environ_sizes_get" => Function::new_env(store, env, environ_sizes_get),
|
"environ_sizes_get" => Function::new_env(store, env.clone(), environ_sizes_get),
|
||||||
"fd_advise" => Function::new_env(store, env, fd_advise),
|
"fd_advise" => Function::new_env(store, env.clone(), fd_advise),
|
||||||
"fd_allocate" => Function::new_env(store, env, fd_allocate),
|
"fd_allocate" => Function::new_env(store, env.clone(), fd_allocate),
|
||||||
"fd_close" => Function::new_env(store, env, fd_close),
|
"fd_close" => Function::new_env(store, env.clone(), fd_close),
|
||||||
"fd_datasync" => Function::new_env(store, env, fd_datasync),
|
"fd_datasync" => Function::new_env(store, env.clone(), fd_datasync),
|
||||||
"fd_fdstat_get" => Function::new_env(store, env, fd_fdstat_get),
|
"fd_fdstat_get" => Function::new_env(store, env.clone(), fd_fdstat_get),
|
||||||
"fd_fdstat_set_flags" => Function::new_env(store, env, fd_fdstat_set_flags),
|
"fd_fdstat_set_flags" => Function::new_env(store, env.clone(), fd_fdstat_set_flags),
|
||||||
"fd_fdstat_set_rights" => Function::new_env(store, env, fd_fdstat_set_rights),
|
"fd_fdstat_set_rights" => Function::new_env(store, env.clone(), fd_fdstat_set_rights),
|
||||||
"fd_filestat_get" => Function::new_env(store, env, legacy::snapshot0::fd_filestat_get),
|
"fd_filestat_get" => Function::new_env(store, env.clone(), legacy::snapshot0::fd_filestat_get),
|
||||||
"fd_filestat_set_size" => Function::new_env(store, env, fd_filestat_set_size),
|
"fd_filestat_set_size" => Function::new_env(store, env.clone(), fd_filestat_set_size),
|
||||||
"fd_filestat_set_times" => Function::new_env(store, env, fd_filestat_set_times),
|
"fd_filestat_set_times" => Function::new_env(store, env.clone(), fd_filestat_set_times),
|
||||||
"fd_pread" => Function::new_env(store, env, fd_pread),
|
"fd_pread" => Function::new_env(store, env.clone(), fd_pread),
|
||||||
"fd_prestat_get" => Function::new_env(store, env, fd_prestat_get),
|
"fd_prestat_get" => Function::new_env(store, env.clone(), fd_prestat_get),
|
||||||
"fd_prestat_dir_name" => Function::new_env(store, env, fd_prestat_dir_name),
|
"fd_prestat_dir_name" => Function::new_env(store, env.clone(), fd_prestat_dir_name),
|
||||||
"fd_pwrite" => Function::new_env(store, env, fd_pwrite),
|
"fd_pwrite" => Function::new_env(store, env.clone(), fd_pwrite),
|
||||||
"fd_read" => Function::new_env(store, env, fd_read),
|
"fd_read" => Function::new_env(store, env.clone(), fd_read),
|
||||||
"fd_readdir" => Function::new_env(store, env, fd_readdir),
|
"fd_readdir" => Function::new_env(store, env.clone(), fd_readdir),
|
||||||
"fd_renumber" => Function::new_env(store, env, fd_renumber),
|
"fd_renumber" => Function::new_env(store, env.clone(), fd_renumber),
|
||||||
"fd_seek" => Function::new_env(store, env, legacy::snapshot0::fd_seek),
|
"fd_seek" => Function::new_env(store, env.clone(), legacy::snapshot0::fd_seek),
|
||||||
"fd_sync" => Function::new_env(store, env, fd_sync),
|
"fd_sync" => Function::new_env(store, env.clone(), fd_sync),
|
||||||
"fd_tell" => Function::new_env(store, env, fd_tell),
|
"fd_tell" => Function::new_env(store, env.clone(), fd_tell),
|
||||||
"fd_write" => Function::new_env(store, env, fd_write),
|
"fd_write" => Function::new_env(store, env.clone(), fd_write),
|
||||||
"path_create_directory" => Function::new_env(store, env, path_create_directory),
|
"path_create_directory" => Function::new_env(store, env.clone(), path_create_directory),
|
||||||
"path_filestat_get" => Function::new_env(store, env, legacy::snapshot0::path_filestat_get),
|
"path_filestat_get" => Function::new_env(store, env.clone(), legacy::snapshot0::path_filestat_get),
|
||||||
"path_filestat_set_times" => Function::new_env(store, env, path_filestat_set_times),
|
"path_filestat_set_times" => Function::new_env(store, env.clone(), path_filestat_set_times),
|
||||||
"path_link" => Function::new_env(store, env, path_link),
|
"path_link" => Function::new_env(store, env.clone(), path_link),
|
||||||
"path_open" => Function::new_env(store, env, path_open),
|
"path_open" => Function::new_env(store, env.clone(), path_open),
|
||||||
"path_readlink" => Function::new_env(store, env, path_readlink),
|
"path_readlink" => Function::new_env(store, env.clone(), path_readlink),
|
||||||
"path_remove_directory" => Function::new_env(store, env, path_remove_directory),
|
"path_remove_directory" => Function::new_env(store, env.clone(), path_remove_directory),
|
||||||
"path_rename" => Function::new_env(store, env, path_rename),
|
"path_rename" => Function::new_env(store, env.clone(), path_rename),
|
||||||
"path_symlink" => Function::new_env(store, env, path_symlink),
|
"path_symlink" => Function::new_env(store, env.clone(), path_symlink),
|
||||||
"path_unlink_file" => Function::new_env(store, env, path_unlink_file),
|
"path_unlink_file" => Function::new_env(store, env.clone(), path_unlink_file),
|
||||||
"poll_oneoff" => Function::new_env(store, env, legacy::snapshot0::poll_oneoff),
|
"poll_oneoff" => Function::new_env(store, env.clone(), legacy::snapshot0::poll_oneoff),
|
||||||
"proc_exit" => Function::new_env(store, env, proc_exit),
|
"proc_exit" => Function::new_env(store, env.clone(), proc_exit),
|
||||||
"proc_raise" => Function::new_env(store, env, proc_raise),
|
"proc_raise" => Function::new_env(store, env.clone(), proc_raise),
|
||||||
"random_get" => Function::new_env(store, env, random_get),
|
"random_get" => Function::new_env(store, env.clone(), random_get),
|
||||||
"sched_yield" => Function::new_env(store, env, sched_yield),
|
"sched_yield" => Function::new_env(store, env.clone(), sched_yield),
|
||||||
"sock_recv" => Function::new_env(store, env, sock_recv),
|
"sock_recv" => Function::new_env(store, env.clone(), sock_recv),
|
||||||
"sock_send" => Function::new_env(store, env, sock_send),
|
"sock_send" => Function::new_env(store, env.clone(), sock_send),
|
||||||
"sock_shutdown" => Function::new_env(store, env, sock_shutdown),
|
"sock_shutdown" => Function::new_env(store, env.clone(), sock_shutdown),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Combines a state generating function with the import list for snapshot 1
|
/// Combines a state generating function with the import list for snapshot 1
|
||||||
fn generate_import_object_snapshot1(store: &Store, env: &mut WasiEnv) -> ImportObject {
|
fn generate_import_object_snapshot1(store: &Store, env: WasiEnv) -> ImportObject {
|
||||||
imports! {
|
imports! {
|
||||||
"wasi_snapshot_preview1" => {
|
"wasi_snapshot_preview1" => {
|
||||||
"args_get" => Function::new_env(store, env, args_get),
|
"args_get" => Function::new_env(store, env.clone(), args_get),
|
||||||
"args_sizes_get" => Function::new_env(store, env, args_sizes_get),
|
"args_sizes_get" => Function::new_env(store, env.clone(), args_sizes_get),
|
||||||
"clock_res_get" => Function::new_env(store, env, clock_res_get),
|
"clock_res_get" => Function::new_env(store, env.clone(), clock_res_get),
|
||||||
"clock_time_get" => Function::new_env(store, env, clock_time_get),
|
"clock_time_get" => Function::new_env(store, env.clone(), clock_time_get),
|
||||||
"environ_get" => Function::new_env(store, env, environ_get),
|
"environ_get" => Function::new_env(store, env.clone(), environ_get),
|
||||||
"environ_sizes_get" => Function::new_env(store, env, environ_sizes_get),
|
"environ_sizes_get" => Function::new_env(store, env.clone(), environ_sizes_get),
|
||||||
"fd_advise" => Function::new_env(store, env, fd_advise),
|
"fd_advise" => Function::new_env(store, env.clone(), fd_advise),
|
||||||
"fd_allocate" => Function::new_env(store, env, fd_allocate),
|
"fd_allocate" => Function::new_env(store, env.clone(), fd_allocate),
|
||||||
"fd_close" => Function::new_env(store, env, fd_close),
|
"fd_close" => Function::new_env(store, env.clone(), fd_close),
|
||||||
"fd_datasync" => Function::new_env(store, env, fd_datasync),
|
"fd_datasync" => Function::new_env(store, env.clone(), fd_datasync),
|
||||||
"fd_fdstat_get" => Function::new_env(store, env, fd_fdstat_get),
|
"fd_fdstat_get" => Function::new_env(store, env.clone(), fd_fdstat_get),
|
||||||
"fd_fdstat_set_flags" => Function::new_env(store, env, fd_fdstat_set_flags),
|
"fd_fdstat_set_flags" => Function::new_env(store, env.clone(), fd_fdstat_set_flags),
|
||||||
"fd_fdstat_set_rights" => Function::new_env(store, env, fd_fdstat_set_rights),
|
"fd_fdstat_set_rights" => Function::new_env(store, env.clone(), fd_fdstat_set_rights),
|
||||||
"fd_filestat_get" => Function::new_env(store, env, fd_filestat_get),
|
"fd_filestat_get" => Function::new_env(store, env.clone(), fd_filestat_get),
|
||||||
"fd_filestat_set_size" => Function::new_env(store, env, fd_filestat_set_size),
|
"fd_filestat_set_size" => Function::new_env(store, env.clone(), fd_filestat_set_size),
|
||||||
"fd_filestat_set_times" => Function::new_env(store, env, fd_filestat_set_times),
|
"fd_filestat_set_times" => Function::new_env(store, env.clone(), fd_filestat_set_times),
|
||||||
"fd_pread" => Function::new_env(store, env, fd_pread),
|
"fd_pread" => Function::new_env(store, env.clone(), fd_pread),
|
||||||
"fd_prestat_get" => Function::new_env(store, env, fd_prestat_get),
|
"fd_prestat_get" => Function::new_env(store, env.clone(), fd_prestat_get),
|
||||||
"fd_prestat_dir_name" => Function::new_env(store, env, fd_prestat_dir_name),
|
"fd_prestat_dir_name" => Function::new_env(store, env.clone(), fd_prestat_dir_name),
|
||||||
"fd_pwrite" => Function::new_env(store, env, fd_pwrite),
|
"fd_pwrite" => Function::new_env(store, env.clone(), fd_pwrite),
|
||||||
"fd_read" => Function::new_env(store, env, fd_read),
|
"fd_read" => Function::new_env(store, env.clone(), fd_read),
|
||||||
"fd_readdir" => Function::new_env(store, env, fd_readdir),
|
"fd_readdir" => Function::new_env(store, env.clone(), fd_readdir),
|
||||||
"fd_renumber" => Function::new_env(store, env, fd_renumber),
|
"fd_renumber" => Function::new_env(store, env.clone(), fd_renumber),
|
||||||
"fd_seek" => Function::new_env(store, env, fd_seek),
|
"fd_seek" => Function::new_env(store, env.clone(), fd_seek),
|
||||||
"fd_sync" => Function::new_env(store, env, fd_sync),
|
"fd_sync" => Function::new_env(store, env.clone(), fd_sync),
|
||||||
"fd_tell" => Function::new_env(store, env, fd_tell),
|
"fd_tell" => Function::new_env(store, env.clone(), fd_tell),
|
||||||
"fd_write" => Function::new_env(store, env, fd_write),
|
"fd_write" => Function::new_env(store, env.clone(), fd_write),
|
||||||
"path_create_directory" => Function::new_env(store, env, path_create_directory),
|
"path_create_directory" => Function::new_env(store, env.clone(), path_create_directory),
|
||||||
"path_filestat_get" => Function::new_env(store, env, path_filestat_get),
|
"path_filestat_get" => Function::new_env(store, env.clone(), path_filestat_get),
|
||||||
"path_filestat_set_times" => Function::new_env(store, env, path_filestat_set_times),
|
"path_filestat_set_times" => Function::new_env(store, env.clone(), path_filestat_set_times),
|
||||||
"path_link" => Function::new_env(store, env, path_link),
|
"path_link" => Function::new_env(store, env.clone(), path_link),
|
||||||
"path_open" => Function::new_env(store, env, path_open),
|
"path_open" => Function::new_env(store, env.clone(), path_open),
|
||||||
"path_readlink" => Function::new_env(store, env, path_readlink),
|
"path_readlink" => Function::new_env(store, env.clone(), path_readlink),
|
||||||
"path_remove_directory" => Function::new_env(store, env, path_remove_directory),
|
"path_remove_directory" => Function::new_env(store, env.clone(), path_remove_directory),
|
||||||
"path_rename" => Function::new_env(store, env, path_rename),
|
"path_rename" => Function::new_env(store, env.clone(), path_rename),
|
||||||
"path_symlink" => Function::new_env(store, env, path_symlink),
|
"path_symlink" => Function::new_env(store, env.clone(), path_symlink),
|
||||||
"path_unlink_file" => Function::new_env(store, env, path_unlink_file),
|
"path_unlink_file" => Function::new_env(store, env.clone(), path_unlink_file),
|
||||||
"poll_oneoff" => Function::new_env(store, env, poll_oneoff),
|
"poll_oneoff" => Function::new_env(store, env.clone(), poll_oneoff),
|
||||||
"proc_exit" => Function::new_env(store, env, proc_exit),
|
"proc_exit" => Function::new_env(store, env.clone(), proc_exit),
|
||||||
"proc_raise" => Function::new_env(store, env, proc_raise),
|
"proc_raise" => Function::new_env(store, env.clone(), proc_raise),
|
||||||
"random_get" => Function::new_env(store, env, random_get),
|
"random_get" => Function::new_env(store, env.clone(), random_get),
|
||||||
"sched_yield" => Function::new_env(store, env, sched_yield),
|
"sched_yield" => Function::new_env(store, env.clone(), sched_yield),
|
||||||
"sock_recv" => Function::new_env(store, env, sock_recv),
|
"sock_recv" => Function::new_env(store, env.clone(), sock_recv),
|
||||||
"sock_send" => Function::new_env(store, env, sock_send),
|
"sock_send" => Function::new_env(store, env.clone(), sock_send),
|
||||||
"sock_shutdown" => Function::new_env(store, env, sock_shutdown),
|
"sock_shutdown" => Function::new_env(store, env.clone(), sock_shutdown),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ pub fn args_get(
|
|||||||
argv_buf: WasmPtr<u8, Array>,
|
argv_buf: WasmPtr<u8, Array>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::args_get");
|
debug!("wasi::args_get");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let result = write_buffer_array(memory, &*state.args, argv, argv_buf);
|
let result = write_buffer_array(memory, &*state.args, argv, argv_buf);
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ pub fn args_sizes_get(
|
|||||||
argv_buf_size: WasmPtr<u32>,
|
argv_buf_size: WasmPtr<u32>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::args_sizes_get");
|
debug!("wasi::args_sizes_get");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let argc = wasi_try!(argc.deref(memory));
|
let argc = wasi_try!(argc.deref(memory));
|
||||||
let argv_buf_size = wasi_try!(argv_buf_size.deref(memory));
|
let argv_buf_size = wasi_try!(argv_buf_size.deref(memory));
|
||||||
@@ -256,7 +256,7 @@ pub fn environ_get(
|
|||||||
environ_buf: WasmPtr<u8, Array>,
|
environ_buf: WasmPtr<u8, Array>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::environ_get");
|
debug!("wasi::environ_get");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
write_buffer_array(memory, &*state.envs, environ, environ_buf)
|
write_buffer_array(memory, &*state.envs, environ, environ_buf)
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ pub fn environ_sizes_get(
|
|||||||
environ_buf_size: WasmPtr<u32>,
|
environ_buf_size: WasmPtr<u32>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::environ_sizes_get");
|
debug!("wasi::environ_sizes_get");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let environ_count = wasi_try!(environ_count.deref(memory));
|
let environ_count = wasi_try!(environ_count.deref(memory));
|
||||||
let environ_buf_size = wasi_try!(environ_buf_size.deref(memory));
|
let environ_buf_size = wasi_try!(environ_buf_size.deref(memory));
|
||||||
@@ -333,7 +333,7 @@ pub fn fd_allocate(
|
|||||||
len: __wasi_filesize_t,
|
len: __wasi_filesize_t,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_allocate");
|
debug!("wasi::fd_allocate");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
let inode = fd_entry.inode;
|
let inode = fd_entry.inode;
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ pub fn fd_allocate(
|
|||||||
/// If `fd` is invalid or not open
|
/// If `fd` is invalid or not open
|
||||||
pub fn fd_close(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
|
pub fn fd_close(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_close: fd={}", fd);
|
debug!("wasi::fd_close: fd={}", fd);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ pub fn fd_close(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
|
|||||||
/// The file descriptor to sync
|
/// The file descriptor to sync
|
||||||
pub fn fd_datasync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
|
pub fn fd_datasync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_datasync");
|
debug!("wasi::fd_datasync");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_DATASYNC) {
|
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_DATASYNC) {
|
||||||
return __WASI_EACCES;
|
return __WASI_EACCES;
|
||||||
@@ -421,7 +421,7 @@ pub fn fd_fdstat_get(
|
|||||||
fd,
|
fd,
|
||||||
buf_ptr.offset()
|
buf_ptr.offset()
|
||||||
);
|
);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
|
|
||||||
let stat = wasi_try!(state.fs.fdstat(fd));
|
let stat = wasi_try!(state.fs.fdstat(fd));
|
||||||
@@ -445,7 +445,7 @@ pub fn fd_fdstat_set_flags(
|
|||||||
flags: __wasi_fdflags_t,
|
flags: __wasi_fdflags_t,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_fdstat_set_flags");
|
debug!("wasi::fd_fdstat_set_flags");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
|
|
||||||
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_FDSTAT_SET_FLAGS) {
|
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_FDSTAT_SET_FLAGS) {
|
||||||
@@ -472,7 +472,7 @@ pub fn fd_fdstat_set_rights(
|
|||||||
fs_rights_inheriting: __wasi_rights_t,
|
fs_rights_inheriting: __wasi_rights_t,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_fdstat_set_rights");
|
debug!("wasi::fd_fdstat_set_rights");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
|
|
||||||
// ensure new rights are a subset of current rights
|
// ensure new rights are a subset of current rights
|
||||||
@@ -502,7 +502,7 @@ pub fn fd_filestat_get(
|
|||||||
buf: WasmPtr<__wasi_filestat_t>,
|
buf: WasmPtr<__wasi_filestat_t>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_filestat_get");
|
debug!("wasi::fd_filestat_get");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_FILESTAT_GET) {
|
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_FILESTAT_GET) {
|
||||||
return __WASI_EACCES;
|
return __WASI_EACCES;
|
||||||
@@ -529,7 +529,7 @@ pub fn fd_filestat_set_size(
|
|||||||
st_size: __wasi_filesize_t,
|
st_size: __wasi_filesize_t,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_filestat_set_size");
|
debug!("wasi::fd_filestat_set_size");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
let inode = fd_entry.inode;
|
let inode = fd_entry.inode;
|
||||||
|
|
||||||
@@ -573,7 +573,7 @@ pub fn fd_filestat_set_times(
|
|||||||
fst_flags: __wasi_fstflags_t,
|
fst_flags: __wasi_fstflags_t,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_filestat_set_times");
|
debug!("wasi::fd_filestat_set_times");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
|
|
||||||
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_FILESTAT_SET_TIMES) {
|
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_FILESTAT_SET_TIMES) {
|
||||||
@@ -587,7 +587,8 @@ pub fn fd_filestat_set_times(
|
|||||||
return __WASI_EINVAL;
|
return __WASI_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
let inode = &mut state.fs.inodes[fd_entry.inode];
|
let inode_idx = fd_entry.inode;
|
||||||
|
let inode = &mut state.fs.inodes[inode_idx];
|
||||||
|
|
||||||
if fst_flags & __WASI_FILESTAT_SET_ATIM != 0 || fst_flags & __WASI_FILESTAT_SET_ATIM_NOW != 0 {
|
if fst_flags & __WASI_FILESTAT_SET_ATIM != 0 || fst_flags & __WASI_FILESTAT_SET_ATIM_NOW != 0 {
|
||||||
let time_to_set = if fst_flags & __WASI_FILESTAT_SET_ATIM != 0 {
|
let time_to_set = if fst_flags & __WASI_FILESTAT_SET_ATIM != 0 {
|
||||||
@@ -646,7 +647,7 @@ pub fn fd_pread(
|
|||||||
nread: WasmPtr<u32>,
|
nread: WasmPtr<u32>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_pread: fd={}, offset={}", fd, offset);
|
debug!("wasi::fd_pread: fd={}, offset={}", fd, offset);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let iov_cells = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
let iov_cells = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
||||||
let nread_cell = wasi_try!(nread.deref(memory));
|
let nread_cell = wasi_try!(nread.deref(memory));
|
||||||
@@ -716,7 +717,7 @@ pub fn fd_prestat_get(
|
|||||||
buf: WasmPtr<__wasi_prestat_t>,
|
buf: WasmPtr<__wasi_prestat_t>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_prestat_get: fd={}", fd);
|
debug!("wasi::fd_prestat_get: fd={}", fd);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let prestat_ptr = wasi_try!(buf.deref(memory));
|
let prestat_ptr = wasi_try!(buf.deref(memory));
|
||||||
|
|
||||||
@@ -735,7 +736,7 @@ pub fn fd_prestat_dir_name(
|
|||||||
"wasi::fd_prestat_dir_name: fd={}, path_len={}",
|
"wasi::fd_prestat_dir_name: fd={}, path_len={}",
|
||||||
fd, path_len
|
fd, path_len
|
||||||
);
|
);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let path_chars = wasi_try!(path.deref(memory, 0, path_len));
|
let path_chars = wasi_try!(path.deref(memory, 0, path_len));
|
||||||
|
|
||||||
let real_fd = wasi_try!(state.fs.fd_map.get(&fd).ok_or(__WASI_EBADF));
|
let real_fd = wasi_try!(state.fs.fd_map.get(&fd).ok_or(__WASI_EBADF));
|
||||||
@@ -795,7 +796,7 @@ pub fn fd_pwrite(
|
|||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_pwrite");
|
debug!("wasi::fd_pwrite");
|
||||||
// TODO: refactor, this is just copied from `fd_write`...
|
// TODO: refactor, this is just copied from `fd_write`...
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let iovs_arr_cell = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
let iovs_arr_cell = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
||||||
let nwritten_cell = wasi_try!(nwritten.deref(memory));
|
let nwritten_cell = wasi_try!(nwritten.deref(memory));
|
||||||
|
|
||||||
@@ -828,7 +829,8 @@ pub fn fd_pwrite(
|
|||||||
return __WASI_EACCES;
|
return __WASI_EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
let inode = &mut state.fs.inodes[fd_entry.inode];
|
let inode_idx = fd_entry.inode;
|
||||||
|
let inode = &mut state.fs.inodes[inode_idx];
|
||||||
|
|
||||||
match &mut inode.kind {
|
match &mut inode.kind {
|
||||||
Kind::File { handle, .. } => {
|
Kind::File { handle, .. } => {
|
||||||
@@ -878,7 +880,7 @@ pub fn fd_read(
|
|||||||
nread: WasmPtr<u32>,
|
nread: WasmPtr<u32>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_read: fd={}", fd);
|
debug!("wasi::fd_read: fd={}", fd);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let iovs_arr_cell = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
let iovs_arr_cell = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
||||||
let nread_cell = wasi_try!(nread.deref(memory));
|
let nread_cell = wasi_try!(nread.deref(memory));
|
||||||
@@ -903,7 +905,8 @@ pub fn fd_read(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let offset = fd_entry.offset as usize;
|
let offset = fd_entry.offset as usize;
|
||||||
let inode = &mut state.fs.inodes[fd_entry.inode];
|
let inode_idx = fd_entry.inode;
|
||||||
|
let inode = &mut state.fs.inodes[inode_idx];
|
||||||
|
|
||||||
let bytes_read = match &mut inode.kind {
|
let bytes_read = match &mut inode.kind {
|
||||||
Kind::File { handle, .. } => {
|
Kind::File { handle, .. } => {
|
||||||
@@ -924,6 +927,8 @@ pub fn fd_read(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// reborrow
|
||||||
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
fd_entry.offset += bytes_read as u64;
|
fd_entry.offset += bytes_read as u64;
|
||||||
|
|
||||||
bytes_read
|
bytes_read
|
||||||
@@ -959,7 +964,7 @@ pub fn fd_readdir(
|
|||||||
bufused: WasmPtr<u32>,
|
bufused: WasmPtr<u32>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_readdir");
|
debug!("wasi::fd_readdir");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
// TODO: figure out how this is supposed to work;
|
// TODO: figure out how this is supposed to work;
|
||||||
// is it supposed to pack the buffer full every time until it can't? or do one at a time?
|
// is it supposed to pack the buffer full every time until it can't? or do one at a time?
|
||||||
|
|
||||||
@@ -1069,7 +1074,7 @@ pub fn fd_readdir(
|
|||||||
/// Location to copy file descriptor to
|
/// Location to copy file descriptor to
|
||||||
pub fn fd_renumber(env: &mut WasiEnv, from: __wasi_fd_t, to: __wasi_fd_t) -> __wasi_errno_t {
|
pub fn fd_renumber(env: &mut WasiEnv, from: __wasi_fd_t, to: __wasi_fd_t) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_renumber: from={}, to={}", from, to);
|
debug!("wasi::fd_renumber: from={}, to={}", from, to);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.fd_map.get(&from).ok_or(__WASI_EBADF));
|
let fd_entry = wasi_try!(state.fs.fd_map.get(&from).ok_or(__WASI_EBADF));
|
||||||
let new_fd_entry = Fd {
|
let new_fd_entry = Fd {
|
||||||
// TODO: verify this is correct
|
// TODO: verify this is correct
|
||||||
@@ -1102,7 +1107,7 @@ pub fn fd_seek(
|
|||||||
newoffset: WasmPtr<__wasi_filesize_t>,
|
newoffset: WasmPtr<__wasi_filesize_t>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_seek: fd={}, offset={}", fd, offset);
|
debug!("wasi::fd_seek: fd={}, offset={}", fd, offset);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let new_offset_cell = wasi_try!(newoffset.deref(memory));
|
let new_offset_cell = wasi_try!(newoffset.deref(memory));
|
||||||
|
|
||||||
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
@@ -1116,11 +1121,15 @@ pub fn fd_seek(
|
|||||||
__WASI_WHENCE_CUR => fd_entry.offset = (fd_entry.offset as i64 + offset) as u64,
|
__WASI_WHENCE_CUR => fd_entry.offset = (fd_entry.offset as i64 + offset) as u64,
|
||||||
__WASI_WHENCE_END => {
|
__WASI_WHENCE_END => {
|
||||||
use std::io::SeekFrom;
|
use std::io::SeekFrom;
|
||||||
match state.fs.inodes[fd_entry.inode].kind {
|
let inode_idx = fd_entry.inode;
|
||||||
|
match state.fs.inodes[inode_idx].kind {
|
||||||
Kind::File { ref mut handle, .. } => {
|
Kind::File { ref mut handle, .. } => {
|
||||||
if let Some(handle) = handle {
|
if let Some(handle) = handle {
|
||||||
let end = wasi_try!(handle.seek(SeekFrom::End(0)).ok().ok_or(__WASI_EIO));
|
let end = wasi_try!(handle.seek(SeekFrom::End(0)).ok().ok_or(__WASI_EIO));
|
||||||
// TODO: handle case if fd_entry.offset uses 64 bits of a u64
|
// TODO: handle case if fd_entry.offset uses 64 bits of a u64
|
||||||
|
|
||||||
|
// reborrow
|
||||||
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
fd_entry.offset = (end as i64 + offset) as u64;
|
fd_entry.offset = (end as i64 + offset) as u64;
|
||||||
} else {
|
} else {
|
||||||
return __WASI_EINVAL;
|
return __WASI_EINVAL;
|
||||||
@@ -1143,7 +1152,8 @@ pub fn fd_seek(
|
|||||||
__WASI_WHENCE_SET => fd_entry.offset = offset as u64,
|
__WASI_WHENCE_SET => fd_entry.offset = offset as u64,
|
||||||
_ => return __WASI_EINVAL,
|
_ => return __WASI_EINVAL,
|
||||||
}
|
}
|
||||||
|
// reborrow
|
||||||
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
new_offset_cell.set(fd_entry.offset);
|
new_offset_cell.set(fd_entry.offset);
|
||||||
|
|
||||||
__WASI_ESUCCESS
|
__WASI_ESUCCESS
|
||||||
@@ -1161,7 +1171,7 @@ pub fn fd_seek(
|
|||||||
pub fn fd_sync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
|
pub fn fd_sync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_sync");
|
debug!("wasi::fd_sync");
|
||||||
debug!("=> fd={}", fd);
|
debug!("=> fd={}", fd);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_SYNC) {
|
if !has_rights(fd_entry.rights, __WASI_RIGHT_FD_SYNC) {
|
||||||
return __WASI_EACCES;
|
return __WASI_EACCES;
|
||||||
@@ -1198,7 +1208,7 @@ pub fn fd_tell(
|
|||||||
offset: WasmPtr<__wasi_filesize_t>,
|
offset: WasmPtr<__wasi_filesize_t>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::fd_tell");
|
debug!("wasi::fd_tell");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let offset_cell = wasi_try!(offset.deref(memory));
|
let offset_cell = wasi_try!(offset.deref(memory));
|
||||||
|
|
||||||
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
@@ -1241,7 +1251,7 @@ pub fn fd_write(
|
|||||||
} else {
|
} else {
|
||||||
trace!("wasi::fd_write: fd={}", fd);
|
trace!("wasi::fd_write: fd={}", fd);
|
||||||
}
|
}
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let iovs_arr_cell = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
let iovs_arr_cell = wasi_try!(iovs.deref(memory, 0, iovs_len));
|
||||||
let nwritten_cell = wasi_try!(nwritten.deref(memory));
|
let nwritten_cell = wasi_try!(nwritten.deref(memory));
|
||||||
|
|
||||||
@@ -1273,7 +1283,8 @@ pub fn fd_write(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let offset = fd_entry.offset as usize;
|
let offset = fd_entry.offset as usize;
|
||||||
let inode = &mut state.fs.inodes[fd_entry.inode];
|
let inode_idx = fd_entry.inode;
|
||||||
|
let inode = &mut state.fs.inodes[inode_idx];
|
||||||
|
|
||||||
let bytes_written = match &mut inode.kind {
|
let bytes_written = match &mut inode.kind {
|
||||||
Kind::File { handle, .. } => {
|
Kind::File { handle, .. } => {
|
||||||
@@ -1294,6 +1305,8 @@ pub fn fd_write(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// reborrow
|
||||||
|
let fd_entry = wasi_try!(state.fs.fd_map.get_mut(&fd).ok_or(__WASI_EBADF));
|
||||||
fd_entry.offset += bytes_written as u64;
|
fd_entry.offset += bytes_written as u64;
|
||||||
wasi_try!(state.fs.filestat_resync_size(fd));
|
wasi_try!(state.fs.filestat_resync_size(fd));
|
||||||
|
|
||||||
@@ -1326,7 +1339,7 @@ pub fn path_create_directory(
|
|||||||
path_len: u32,
|
path_len: u32,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::path_create_directory");
|
debug!("wasi::path_create_directory");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let working_dir = wasi_try!(state.fs.get_fd(fd));
|
let working_dir = wasi_try!(state.fs.get_fd(fd));
|
||||||
if let Kind::Root { .. } = &state.fs.inodes[working_dir.inode].kind {
|
if let Kind::Root { .. } = &state.fs.inodes[working_dir.inode].kind {
|
||||||
@@ -1431,7 +1444,7 @@ pub fn path_filestat_get(
|
|||||||
buf: WasmPtr<__wasi_filestat_t>,
|
buf: WasmPtr<__wasi_filestat_t>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::path_filestat_get");
|
debug!("wasi::path_filestat_get");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let root_dir = wasi_try!(state.fs.get_fd(fd));
|
let root_dir = wasi_try!(state.fs.get_fd(fd));
|
||||||
|
|
||||||
@@ -1490,7 +1503,7 @@ pub fn path_filestat_set_times(
|
|||||||
fst_flags: __wasi_fstflags_t,
|
fst_flags: __wasi_fstflags_t,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::path_filestat_set_times");
|
debug!("wasi::path_filestat_set_times");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
let fd_entry = wasi_try!(state.fs.get_fd(fd));
|
||||||
let fd_inode = fd_entry.inode;
|
let fd_inode = fd_entry.inode;
|
||||||
if !has_rights(fd_entry.rights, __WASI_RIGHT_PATH_FILESTAT_SET_TIMES) {
|
if !has_rights(fd_entry.rights, __WASI_RIGHT_PATH_FILESTAT_SET_TIMES) {
|
||||||
@@ -1581,7 +1594,7 @@ pub fn path_link(
|
|||||||
if old_flags & __WASI_LOOKUP_SYMLINK_FOLLOW != 0 {
|
if old_flags & __WASI_LOOKUP_SYMLINK_FOLLOW != 0 {
|
||||||
debug!(" - will follow symlinks when opening path");
|
debug!(" - will follow symlinks when opening path");
|
||||||
}
|
}
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let old_path_str = get_input_str!(memory, old_path, old_path_len);
|
let old_path_str = get_input_str!(memory, old_path, old_path_len);
|
||||||
let new_path_str = get_input_str!(memory, new_path, new_path_len);
|
let new_path_str = get_input_str!(memory, new_path, new_path_len);
|
||||||
let source_fd = wasi_try!(state.fs.get_fd(old_fd));
|
let source_fd = wasi_try!(state.fs.get_fd(old_fd));
|
||||||
@@ -1666,7 +1679,7 @@ pub fn path_open(
|
|||||||
if dirflags & __WASI_LOOKUP_SYMLINK_FOLLOW != 0 {
|
if dirflags & __WASI_LOOKUP_SYMLINK_FOLLOW != 0 {
|
||||||
debug!(" - will follow symlinks when opening path");
|
debug!(" - will follow symlinks when opening path");
|
||||||
}
|
}
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
/* TODO: find actual upper bound on name size (also this is a path, not a name :think-fish:) */
|
/* TODO: find actual upper bound on name size (also this is a path, not a name :think-fish:) */
|
||||||
if path_len > 1024 * 1024 {
|
if path_len > 1024 * 1024 {
|
||||||
return __WASI_ENAMETOOLONG;
|
return __WASI_ENAMETOOLONG;
|
||||||
@@ -1897,7 +1910,7 @@ pub fn path_readlink(
|
|||||||
buf_used: WasmPtr<u32>,
|
buf_used: WasmPtr<u32>,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::path_readlink");
|
debug!("wasi::path_readlink");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let base_dir = wasi_try!(state.fs.fd_map.get(&dir_fd).ok_or(__WASI_EBADF));
|
let base_dir = wasi_try!(state.fs.fd_map.get(&dir_fd).ok_or(__WASI_EBADF));
|
||||||
if !has_rights(base_dir.rights, __WASI_RIGHT_PATH_READLINK) {
|
if !has_rights(base_dir.rights, __WASI_RIGHT_PATH_READLINK) {
|
||||||
@@ -1940,7 +1953,7 @@ pub fn path_remove_directory(
|
|||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
// TODO check if fd is a dir, ensure it's within sandbox, etc.
|
// TODO check if fd is a dir, ensure it's within sandbox, etc.
|
||||||
debug!("wasi::path_remove_directory");
|
debug!("wasi::path_remove_directory");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let base_dir = wasi_try!(state.fs.fd_map.get(&fd), __WASI_EBADF);
|
let base_dir = wasi_try!(state.fs.fd_map.get(&fd), __WASI_EBADF);
|
||||||
let path_str = get_input_str!(memory, path, path_len);
|
let path_str = get_input_str!(memory, path, path_len);
|
||||||
@@ -2018,7 +2031,7 @@ pub fn path_rename(
|
|||||||
new_path_len: u32,
|
new_path_len: u32,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::path_rename");
|
debug!("wasi::path_rename");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let source_str = get_input_str!(memory, old_path, old_path_len);
|
let source_str = get_input_str!(memory, old_path, old_path_len);
|
||||||
let source_path = std::path::Path::new(source_str);
|
let source_path = std::path::Path::new(source_str);
|
||||||
let target_str = get_input_str!(memory, new_path, new_path_len);
|
let target_str = get_input_str!(memory, new_path, new_path_len);
|
||||||
@@ -2126,7 +2139,7 @@ pub fn path_symlink(
|
|||||||
new_path_len: u32,
|
new_path_len: u32,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::path_symlink");
|
debug!("wasi::path_symlink");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
let old_path_str = get_input_str!(memory, old_path, old_path_len);
|
let old_path_str = get_input_str!(memory, old_path, old_path_len);
|
||||||
let new_path_str = get_input_str!(memory, new_path, new_path_len);
|
let new_path_str = get_input_str!(memory, new_path, new_path_len);
|
||||||
let base_fd = wasi_try!(state.fs.get_fd(fd));
|
let base_fd = wasi_try!(state.fs.get_fd(fd));
|
||||||
@@ -2203,7 +2216,7 @@ pub fn path_unlink_file(
|
|||||||
path_len: u32,
|
path_len: u32,
|
||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::path_unlink_file");
|
debug!("wasi::path_unlink_file");
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let base_dir = wasi_try!(state.fs.fd_map.get(&fd).ok_or(__WASI_EBADF));
|
let base_dir = wasi_try!(state.fs.fd_map.get(&fd).ok_or(__WASI_EBADF));
|
||||||
if !has_rights(base_dir.rights, __WASI_RIGHT_PATH_UNLINK_FILE) {
|
if !has_rights(base_dir.rights, __WASI_RIGHT_PATH_UNLINK_FILE) {
|
||||||
@@ -2299,7 +2312,7 @@ pub fn poll_oneoff(
|
|||||||
) -> __wasi_errno_t {
|
) -> __wasi_errno_t {
|
||||||
debug!("wasi::poll_oneoff");
|
debug!("wasi::poll_oneoff");
|
||||||
debug!(" => nsubscriptions = {}", nsubscriptions);
|
debug!(" => nsubscriptions = {}", nsubscriptions);
|
||||||
let (memory, state) = env.get_memory_and_wasi_state(0);
|
let (memory, mut state) = env.get_memory_and_wasi_state(0);
|
||||||
|
|
||||||
let subscription_array = wasi_try!(in_.deref(memory, 0, nsubscriptions));
|
let subscription_array = wasi_try!(in_.deref(memory, 0, nsubscriptions));
|
||||||
let event_array = wasi_try!(out_.deref(memory, 0, nsubscriptions));
|
let event_array = wasi_try!(out_.deref(memory, 0, nsubscriptions));
|
||||||
|
|||||||
@@ -161,25 +161,25 @@ fn native_function_with_env() -> Result<()> {
|
|||||||
let store = get_store();
|
let store = get_store();
|
||||||
let module = get_module(&store)?;
|
let module = get_module(&store)?;
|
||||||
|
|
||||||
let mut env: AtomicUsize = AtomicUsize::new(0);
|
let env: AtomicUsize = AtomicUsize::new(0);
|
||||||
Instance::new(
|
Instance::new(
|
||||||
&module,
|
&module,
|
||||||
&imports! {
|
&imports! {
|
||||||
"host" => {
|
"host" => {
|
||||||
"0" => Function::new_env(&store, &mut env, |env: &mut AtomicUsize| {
|
"0" => Function::new_env(&store, &env, |env: &mut &AtomicUsize| {
|
||||||
assert_eq!(env.fetch_add(1, SeqCst), 0);
|
assert_eq!(env.fetch_add(1, SeqCst), 0);
|
||||||
}),
|
}),
|
||||||
"1" => Function::new_env(&store, &mut env, |env: &mut AtomicUsize, x: i32| -> i32 {
|
"1" => Function::new_env(&store, &env, |env: &mut &AtomicUsize, x: i32| -> i32 {
|
||||||
assert_eq!(x, 0);
|
assert_eq!(x, 0);
|
||||||
assert_eq!(env.fetch_add(1, SeqCst), 1);
|
assert_eq!(env.fetch_add(1, SeqCst), 1);
|
||||||
1
|
1
|
||||||
}),
|
}),
|
||||||
"2" => Function::new_env(&store, &mut env, |env: &mut AtomicUsize, x: i32, y: i64| {
|
"2" => Function::new_env(&store, &env, |env: &mut &AtomicUsize, x: i32, y: i64| {
|
||||||
assert_eq!(x, 2);
|
assert_eq!(x, 2);
|
||||||
assert_eq!(y, 3);
|
assert_eq!(y, 3);
|
||||||
assert_eq!(env.fetch_add(1, SeqCst), 2);
|
assert_eq!(env.fetch_add(1, SeqCst), 2);
|
||||||
}),
|
}),
|
||||||
"3" => Function::new_env(&store, &mut env, |env: &mut AtomicUsize, a: i32, b: i64, c: i32, d: f32, e: f64| {
|
"3" => Function::new_env(&store, &env, |env: &mut &AtomicUsize, a: i32, b: i64, c: i32, d: f32, e: f64| {
|
||||||
assert_eq!(a, 100);
|
assert_eq!(a, 100);
|
||||||
assert_eq!(b, 200);
|
assert_eq!(b, 200);
|
||||||
assert_eq!(c, 300);
|
assert_eq!(c, 300);
|
||||||
|
|||||||
Reference in New Issue
Block a user