1663: Make Function Env immutable r=MarkMcCaskey a=MarkMcCaskey


Alternative / related to #1625

Resolves #1612 

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
This commit is contained in:
bors[bot]
2020-11-20 22:47:33 +00:00
committed by GitHub
51 changed files with 840 additions and 758 deletions

View File

@@ -13,6 +13,7 @@
### Changed ### Changed
- [#1663](https://github.com/wasmerio/wasmer/pull/1663) Function environments passed to host functions now must be passed by `&` instead of `&mut`. This is a breaking change. This change fixes a race condition when a host function is called from multiple threads. If you need mutability in your environment, consider using `std::sync::Mutex` or other synchronization primitives.
- [#1830](https://github.com/wasmerio/wasmer/pull/1830) Minimum supported Rust version bumped to 1.47.0 - [#1830](https://github.com/wasmerio/wasmer/pull/1830) Minimum supported Rust version bumped to 1.47.0
- [#1810](https://github.com/wasmerio/wasmer/pull/1810) Make the `state` field of `WasiEnv` public - [#1810](https://github.com/wasmerio/wasmer/pull/1810) Make the `state` field of `WasiEnv` public

View File

@@ -74,10 +74,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
// Create the functions // Create the functions
fn get_counter(env: &mut Env) -> i32 { fn get_counter(env: &Env) -> i32 {
*env.counter.borrow() *env.counter.borrow()
} }
fn add_to_counter(env: &mut Env, add: i32) -> i32 { fn add_to_counter(env: &Env, add: i32) -> i32 {
let mut counter_ref = env.counter.borrow_mut(); let mut counter_ref = env.counter.borrow_mut();
*counter_ref += add; *counter_ref += add;

View File

@@ -67,6 +67,8 @@ llvm = [
"wasmer-compiler-llvm", "wasmer-compiler-llvm",
"compiler", "compiler",
] ]
# enables internal features used by the deprecated API.
deprecated = []
default-compiler = [] default-compiler = []
default-engine = [] default-engine = []

View File

@@ -6,7 +6,9 @@ use crate::FunctionType;
use crate::NativeFunc; use crate::NativeFunc;
use crate::RuntimeError; use crate::RuntimeError;
pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, WithoutEnv}; pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, WithoutEnv};
use std::cell::RefCell; #[cfg(feature = "deprecated")]
pub use inner::{UnsafeMutableEnv, WithUnsafeMutableEnv};
use std::cmp::max; use std::cmp::max;
use std::fmt; use std::fmt;
use wasmer_vm::{ use wasmer_vm::{
@@ -125,11 +127,11 @@ impl Function {
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn new_with_env<F, Env>(store: &Store, ty: &FunctionType, env: Env, func: F) -> Self pub fn new_with_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(&Env, &[Val]) -> Result<Vec<Val>, RuntimeError> + 'static,
Env: Sized + 'static, Env: Sized + 'static,
{ {
let dynamic_ctx = VMDynamicFunctionContext::from_context(VMDynamicFunctionWithEnv { let dynamic_ctx = VMDynamicFunctionContext::from_context(VMDynamicFunctionWithEnv {
env: RefCell::new(env), env: Box::new(env),
func: Box::new(func), func: Box::new(func),
function_type: ty.clone(), function_type: ty.clone(),
}); });
@@ -214,7 +216,7 @@ impl Function {
/// }; /// };
/// let env = Env { multiplier: 2 }; /// let env = Env { multiplier: 2 };
/// ///
/// fn sum_and_multiply(env: &mut Env, a: i32, b: i32) -> i32 { /// fn sum_and_multiply(env: &Env, a: i32, b: i32) -> i32 {
/// (a + b) * env.multiplier /// (a + b) * env.multiplier
/// } /// }
/// ///
@@ -254,6 +256,47 @@ impl Function {
} }
} }
/// Function used by the deprecated API to call a function with a `&mut` Env.
///
/// This is not a stable API and may be broken at any time.
///
/// # Safety
/// - This function is only safe to use from the deprecated API.
#[doc(hidden)]
#[cfg(feature = "deprecated")]
pub unsafe fn new_native_with_unsafe_mutable_env<F, Args, Rets, Env>(
store: &Store,
env: Env,
func: F,
) -> Self
where
F: HostFunction<Args, Rets, WithUnsafeMutableEnv, Env>,
Args: WasmTypeList,
Rets: WasmTypeList,
Env: UnsafeMutableEnv + 'static,
{
let function = inner::Function::<Args, Rets>::new(func);
let address = function.address();
let box_env = Box::new(env);
let vmctx = VMFunctionEnvironment {
host_env: Box::into_raw(box_env) as *mut _,
};
let signature = function.ty();
Self {
store: store.clone(),
definition: FunctionDefinition::Host(HostFunctionDefinition { has_env: true }),
exported: ExportFunction {
address,
kind: VMFunctionKind::Static,
vmctx,
signature,
call_trampoline: None,
},
}
}
/// Returns the [`FunctionType`] of the `Function`. /// Returns the [`FunctionType`] of the `Function`.
/// ///
/// # Example /// # Example
@@ -628,8 +671,8 @@ where
{ {
function_type: FunctionType, function_type: FunctionType,
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
func: Box<dyn Fn(&mut Env, &[Val]) -> Result<Vec<Val>, RuntimeError> + 'static>, func: Box<dyn Fn(&Env, &[Val]) -> Result<Vec<Val>, RuntimeError> + 'static>,
env: RefCell<Env>, env: Box<Env>,
} }
impl<Env> VMDynamicFunction for VMDynamicFunctionWithEnv<Env> impl<Env> VMDynamicFunction for VMDynamicFunctionWithEnv<Env>
@@ -637,9 +680,7 @@ where
Env: Sized + 'static, Env: Sized + 'static,
{ {
fn call(&self, args: &[Val]) -> Result<Vec<Val>, RuntimeError> { fn call(&self, args: &[Val]) -> Result<Vec<Val>, RuntimeError> {
// TODO: the `&mut *self.env.as_ptr()` is likely invoking some "mild" (*self.func)(&*self.env, &args)
// undefined behavior due to how it's used in the static fn call
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
@@ -979,6 +1020,14 @@ mod inner {
fn function_body_ptr(self) -> *const VMFunctionBody; fn function_body_ptr(self) -> *const VMFunctionBody;
} }
/// Marker trait to limit what the hidden APIs needed for the deprecated API
/// can be used on.
///
/// Marks an environment as being passed by `&mut`.
#[cfg(feature = "deprecated")]
#[doc(hidden)]
pub unsafe trait UnsafeMutableEnv: Sized {}
/// Empty trait to specify the kind of `HostFunction`: With or /// Empty trait to specify the kind of `HostFunction`: With or
/// without an environment. /// without an environment.
/// ///
@@ -994,6 +1043,18 @@ mod inner {
impl HostFunctionKind for WithEnv {} impl HostFunctionKind for WithEnv {}
/// An empty struct to help Rust typing to determine
/// when a `HostFunction` has an environment.
///
/// This environment is passed by `&mut` and exists solely for the deprecated
/// API.
#[cfg(feature = "deprecated")]
#[doc(hidden)]
pub struct WithUnsafeMutableEnv;
#[cfg(feature = "deprecated")]
impl HostFunctionKind for WithUnsafeMutableEnv {}
/// An empty struct to help Rust typing to determine /// An empty struct to help Rust typing to determine
/// when a `HostFunction` does not have an environment. /// when a `HostFunction` does not have an environment.
pub struct WithoutEnv; pub struct WithoutEnv;
@@ -1187,6 +1248,52 @@ mod inner {
Rets: WasmTypeList, Rets: WasmTypeList,
RetsAsResult: IntoResult<Rets>, RetsAsResult: IntoResult<Rets>,
Env: Sized, Env: Sized,
Func: Fn(&Env, $( $x , )*) -> RetsAsResult + Send + 'static,
{
#[allow(non_snake_case)]
fn function_body_ptr(self) -> *const VMFunctionBody {
/// This is a function that wraps the real host
/// function. Its address will be used inside the
/// runtime.
extern fn func_wrapper<$( $x, )* Rets, RetsAsResult, Env, Func>( env: &Env, $( $x: $x::Native, )* ) -> Rets::CStruct
where
$( $x: FromToNativeWasmType, )*
Rets: WasmTypeList,
RetsAsResult: IntoResult<Rets>,
Env: Sized,
Func: Fn(&Env, $( $x ),* ) -> RetsAsResult + 'static
{
let func: &Func = unsafe { &*(&() as *const () as *const Func) };
let result = panic::catch_unwind(AssertUnwindSafe(|| {
func(env, $( FromToNativeWasmType::from_native($x) ),* ).into_result()
}));
match result {
Ok(Ok(result)) => return result.into_c_struct(),
Ok(Err(trap)) => unsafe { raise_user_trap(Box::new(trap)) },
Err(panic) => unsafe { resume_panic(panic) },
}
}
func_wrapper::< $( $x, )* Rets, RetsAsResult, Env, Self > as *const VMFunctionBody
}
}
// Implement `HostFunction` for a function that has the same arity than the tuple.
// This specific function has an environment.
#[doc(hidden)]
#[cfg(feature = "deprecated")]
#[allow(unused_parens)]
impl< $( $x, )* Rets, RetsAsResult, Env, Func >
HostFunction<( $( $x ),* ), Rets, WithUnsafeMutableEnv, Env>
for
Func
where
$( $x: FromToNativeWasmType, )*
Rets: WasmTypeList,
RetsAsResult: IntoResult<Rets>,
Env: UnsafeMutableEnv,
Func: Fn(&mut Env, $( $x , )*) -> RetsAsResult + Send + 'static, Func: Fn(&mut Env, $( $x , )*) -> RetsAsResult + Send + 'static,
{ {
#[allow(non_snake_case)] #[allow(non_snake_case)]
@@ -1218,7 +1325,6 @@ mod inner {
func_wrapper::< $( $x, )* Rets, RetsAsResult, Env, Self > as *const VMFunctionBody func_wrapper::< $( $x, )* Rets, RetsAsResult, Env, Self > as *const VMFunctionBody
} }
} }
}; };
} }

View File

@@ -6,6 +6,9 @@ mod table;
pub use self::function::{ pub use self::function::{
FromToNativeWasmType, Function, HostFunction, WasmTypeList, WithEnv, WithoutEnv, FromToNativeWasmType, Function, HostFunction, WasmTypeList, WithEnv, WithoutEnv,
}; };
#[cfg(feature = "deprecated")]
pub use self::function::{UnsafeMutableEnv, WithUnsafeMutableEnv};
pub use self::global::Global; pub use self::global::Global;
pub use self::memory::Memory; pub use self::memory::Memory;
pub use self::table::Table; pub use self::table::Table;

View File

@@ -46,6 +46,8 @@ pub mod internals {
//! `wasmer-vm`. Please don't use any of this types directly, as //! `wasmer-vm`. Please don't use any of this types directly, as
//! they might change frequently or be removed in the future. //! they might change frequently or be removed in the future.
#[cfg(feature = "deprecated")]
pub use crate::externals::{UnsafeMutableEnv, WithUnsafeMutableEnv};
pub use crate::externals::{WithEnv, WithoutEnv}; pub use crate::externals::{WithEnv, WithoutEnv};
} }

View File

@@ -211,10 +211,10 @@ fn function_new_env() -> Result<()> {
#[derive(Clone)] #[derive(Clone)]
struct MyEnv {}; struct MyEnv {};
let my_env = MyEnv {}; let my_env = MyEnv {};
let function = Function::new_native_with_env(&store, my_env.clone(), |_env: &mut MyEnv| {}); let function = Function::new_native_with_env(&store, my_env.clone(), |_env: &MyEnv| {});
assert_eq!(function.ty().clone(), FunctionType::new(vec![], vec![])); assert_eq!(function.ty().clone(), FunctionType::new(vec![], vec![]));
let function = let function =
Function::new_native_with_env(&store, my_env.clone(), |_env: &mut MyEnv, _a: i32| {}); Function::new_native_with_env(&store, my_env.clone(), |_env: &MyEnv, _a: i32| {});
assert_eq!( assert_eq!(
function.ty().clone(), function.ty().clone(),
FunctionType::new(vec![Type::I32], vec![]) FunctionType::new(vec![Type::I32], vec![])
@@ -222,14 +222,14 @@ fn function_new_env() -> Result<()> {
let function = Function::new_native_with_env( let function = Function::new_native_with_env(
&store, &store,
my_env.clone(), my_env.clone(),
|_env: &mut MyEnv, _a: i32, _b: i64, _c: f32, _d: f64| {}, |_env: &MyEnv, _a: i32, _b: i64, _c: f32, _d: f64| {},
); );
assert_eq!( assert_eq!(
function.ty().clone(), function.ty().clone(),
FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]) FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![])
); );
let function = let function =
Function::new_native_with_env(&store, my_env.clone(), |_env: &mut MyEnv| -> i32 { 1 }); Function::new_native_with_env(&store, my_env.clone(), |_env: &MyEnv| -> i32 { 1 });
assert_eq!( assert_eq!(
function.ty().clone(), function.ty().clone(),
FunctionType::new(vec![], vec![Type::I32]) FunctionType::new(vec![], vec![Type::I32])
@@ -237,7 +237,7 @@ fn function_new_env() -> Result<()> {
let function = Function::new_native_with_env( let function = Function::new_native_with_env(
&store, &store,
my_env.clone(), my_env.clone(),
|_env: &mut MyEnv| -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }, |_env: &MyEnv| -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) },
); );
assert_eq!( assert_eq!(
function.ty().clone(), function.ty().clone(),
@@ -279,7 +279,7 @@ fn function_new_dynamic_env() -> Result<()> {
&store, &store,
&function_type, &function_type,
my_env.clone(), my_env.clone(),
|_env: &mut MyEnv, _values: &[Value]| unimplemented!(), |_env: &MyEnv, _values: &[Value]| unimplemented!(),
); );
assert_eq!(function.ty().clone(), function_type); assert_eq!(function.ty().clone(), function_type);
let function_type = FunctionType::new(vec![Type::I32], vec![]); let function_type = FunctionType::new(vec![Type::I32], vec![]);
@@ -287,7 +287,7 @@ fn function_new_dynamic_env() -> Result<()> {
&store, &store,
&function_type, &function_type,
my_env.clone(), my_env.clone(),
|_env: &mut MyEnv, _values: &[Value]| unimplemented!(), |_env: &MyEnv, _values: &[Value]| unimplemented!(),
); );
assert_eq!(function.ty().clone(), function_type); assert_eq!(function.ty().clone(), function_type);
let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]); let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]);
@@ -295,7 +295,7 @@ fn function_new_dynamic_env() -> Result<()> {
&store, &store,
&function_type, &function_type,
my_env.clone(), my_env.clone(),
|_env: &mut MyEnv, _values: &[Value]| unimplemented!(), |_env: &MyEnv, _values: &[Value]| unimplemented!(),
); );
assert_eq!(function.ty().clone(), function_type); assert_eq!(function.ty().clone(), function_type);
let function_type = FunctionType::new(vec![], vec![Type::I32]); let function_type = FunctionType::new(vec![], vec![Type::I32]);
@@ -303,7 +303,7 @@ fn function_new_dynamic_env() -> Result<()> {
&store, &store,
&function_type, &function_type,
my_env.clone(), my_env.clone(),
|_env: &mut MyEnv, _values: &[Value]| unimplemented!(), |_env: &MyEnv, _values: &[Value]| unimplemented!(),
); );
assert_eq!(function.ty().clone(), function_type); assert_eq!(function.ty().clone(), function_type);
let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]); let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]);
@@ -311,7 +311,7 @@ fn function_new_dynamic_env() -> Result<()> {
&store, &store,
&function_type, &function_type,
my_env.clone(), my_env.clone(),
|_env: &mut MyEnv, _values: &[Value]| unimplemented!(), |_env: &MyEnv, _values: &[Value]| unimplemented!(),
); );
assert_eq!(function.ty().clone(), function_type); assert_eq!(function.ty().clone(), function_type);
Ok(()) Ok(())

View File

@@ -45,10 +45,10 @@ pub(crate) struct CAPIImportObject {
/// but the new/current API does not. So we store them here to pass them to the Instance /// but the new/current API does not. So we store them here to pass them to the Instance
/// to allow functions to access this data for backwards compatibilty. /// to allow functions to access this data for backwards compatibilty.
pub(crate) imported_memories: Vec<*mut Memory>, pub(crate) imported_memories: Vec<*mut Memory>,
/// List of pointers to `LegacyEnv`s used to patch imported functions to be able to /// List of pointers to `UnsafeMutableEnv`s used to patch imported functions to be able to
/// pass a the "vmctx" as the first argument. /// pass a the "vmctx" as the first argument.
/// Needed here because of extending import objects. /// Needed here because of extending import objects.
pub(crate) instance_pointers_to_update: Vec<NonNull<LegacyEnv>>, pub(crate) instance_pointers_to_update: Vec<NonNull<UnsafeMutableEnv>>,
} }
#[repr(C)] #[repr(C)]
@@ -399,7 +399,7 @@ pub unsafe extern "C" fn wasmer_import_object_imports_destroy(
let function_wrapper: Box<FunctionWrapper> = let function_wrapper: Box<FunctionWrapper> =
Box::from_raw(import.value.func as *mut _); Box::from_raw(import.value.func as *mut _);
let _: Box<Function> = Box::from_raw(function_wrapper.func.as_ptr()); let _: Box<Function> = Box::from_raw(function_wrapper.func.as_ptr());
let _: Box<LegacyEnv> = Box::from_raw(function_wrapper.legacy_env.as_ptr()); let _: Box<UnsafeMutableEnv> = Box::from_raw(function_wrapper.legacy_env.as_ptr());
} }
wasmer_import_export_kind::WASM_GLOBAL => { wasmer_import_export_kind::WASM_GLOBAL => {
let _: Box<Global> = Box::from_raw(import.value.global as *mut _); let _: Box<Global> = Box::from_raw(import.value.global as *mut _);
@@ -635,11 +635,11 @@ pub unsafe extern "C" fn wasmer_import_func_params_arity(
/// struct used to pass in context to functions (which must be back-patched) /// struct used to pass in context to functions (which must be back-patched)
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub(crate) struct LegacyEnv { pub(crate) struct UnsafeMutableEnv {
pub(crate) instance_ptr: Option<NonNull<CAPIInstance>>, pub(crate) instance_ptr: Option<NonNull<CAPIInstance>>,
} }
impl LegacyEnv { impl UnsafeMutableEnv {
pub(crate) fn ctx_ptr(&self) -> *mut CAPIInstance { pub(crate) fn ctx_ptr(&self) -> *mut CAPIInstance {
self.instance_ptr self.instance_ptr
.map(|p| p.as_ptr()) .map(|p| p.as_ptr())
@@ -647,13 +647,13 @@ impl LegacyEnv {
} }
} }
/// struct used to hold on to `LegacyEnv` pointer as well as the function. /// struct used to hold on to `UnsafeMutableEnv` pointer as well as the function.
/// we need to do this to initialize the context ptr inside of `LegacyEnv` when /// we need to do this to initialize the context ptr inside of `UnsafeMutableEnv` when
/// instantiating the module. /// instantiating the module.
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct FunctionWrapper { pub(crate) struct FunctionWrapper {
pub(crate) func: NonNull<Function>, pub(crate) func: NonNull<Function>,
pub(crate) legacy_env: NonNull<LegacyEnv>, pub(crate) legacy_env: NonNull<UnsafeMutableEnv>,
} }
/// Creates new host function, aka imported function. `func` is a /// Creates new host function, aka imported function. `func` is a
@@ -690,7 +690,7 @@ pub unsafe extern "C" fn wasmer_import_func_new(
let store = get_global_store(); let store = get_global_store();
let env_ptr = Box::into_raw(Box::new(LegacyEnv::default())); let env_ptr = Box::into_raw(Box::new(UnsafeMutableEnv::default()));
let func = Function::new_with_env(store, &func_type, &mut *env_ptr, move |env, args| { let func = Function::new_with_env(store, &func_type, &mut *env_ptr, move |env, args| {
use libffi::high::call::{call, Arg}; use libffi::high::call::{call, Arg};

View File

@@ -100,42 +100,41 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
let func_sig = &function_type.inner().function_type; let func_sig = &function_type.inner().function_type;
let num_rets = func_sig.results().len(); let num_rets = func_sig.results().len();
let inner_callback = let inner_callback = move |env: &*mut c_void, args: &[Val]| -> Result<Vec<Val>, RuntimeError> {
move |env: &mut *mut c_void, args: &[Val]| -> Result<Vec<Val>, RuntimeError> { let processed_args: wasm_val_vec_t = args
let processed_args: wasm_val_vec_t = args .into_iter()
.into_iter() .map(TryInto::try_into)
.map(TryInto::try_into) .collect::<Result<Vec<wasm_val_t>, _>>()
.collect::<Result<Vec<wasm_val_t>, _>>() .expect("Argument conversion failed")
.expect("Argument conversion failed")
.into();
let mut results: wasm_val_vec_t = vec![
wasm_val_t {
kind: wasm_valkind_enum::WASM_I64 as _,
of: wasm_val_inner { int64_t: 0 },
};
num_rets
]
.into(); .into();
let trap = callback(*env, &processed_args, &mut results); let mut results: wasm_val_vec_t = vec![
wasm_val_t {
kind: wasm_valkind_enum::WASM_I64 as _,
of: wasm_val_inner { int64_t: 0 },
};
num_rets
]
.into();
if !trap.is_null() { let trap = callback(*env, &processed_args, &mut results);
let trap: Box<wasm_trap_t> = Box::from_raw(trap);
return Err(trap.inner); if !trap.is_null() {
} let trap: Box<wasm_trap_t> = Box::from_raw(trap);
let processed_results = results return Err(trap.inner);
.into_slice() }
.expect("Failed to convert `results` into a slice")
.into_iter()
.map(TryInto::try_into)
.collect::<Result<Vec<Val>, _>>()
.expect("Result conversion failed");
Ok(processed_results) let processed_results = results
}; .into_slice()
.expect("Failed to convert `results` into a slice")
.into_iter()
.map(TryInto::try_into)
.collect::<Result<Vec<Val>, _>>()
.expect("Result conversion failed");
Ok(processed_results)
};
let function = Function::new_with_env(&store.inner, &func_sig, env, inner_callback); let function = Function::new_with_env(&store.inner, &func_sig, env, inner_callback);

View File

@@ -120,6 +120,12 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "const_fn"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
[[package]] [[package]]
name = "constant_time_eq" name = "constant_time_eq"
version = "0.1.5" version = "0.1.5"
@@ -128,18 +134,18 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]] [[package]]
name = "cranelift-bforest" name = "cranelift-bforest"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
] ]
[[package]] [[package]]
name = "cranelift-codegen" name = "cranelift-codegen"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"cranelift-bforest", "cranelift-bforest",
@@ -149,7 +155,6 @@ dependencies = [
"gimli 0.21.0", "gimli 0.21.0",
"log", "log",
"regalloc", "regalloc",
"serde",
"smallvec", "smallvec",
"target-lexicon", "target-lexicon",
"thiserror", "thiserror",
@@ -157,9 +162,9 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-meta" name = "cranelift-codegen-meta"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0"
dependencies = [ dependencies = [
"cranelift-codegen-shared", "cranelift-codegen-shared",
"cranelift-entity", "cranelift-entity",
@@ -167,24 +172,24 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-shared" name = "cranelift-codegen-shared"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826"
[[package]] [[package]]
name = "cranelift-entity" name = "cranelift-entity"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3"
dependencies = [ dependencies = [
"serde", "serde",
] ]
[[package]] [[package]]
name = "cranelift-frontend" name = "cranelift-frontend"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"log", "log",
@@ -202,50 +207,49 @@ dependencies = [
] ]
[[package]] [[package]]
name = "crossbeam-deque" name = "crossbeam-channel"
version = "0.7.3" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
dependencies = [ dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
"maybe-uninit",
] ]
[[package]] [[package]]
name = "crossbeam-epoch" name = "crossbeam-epoch"
version = "0.8.2" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f"
dependencies = [ dependencies = [
"autocfg", "cfg-if 1.0.0",
"cfg-if 0.1.10", "const_fn",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"maybe-uninit",
"memoffset", "memoffset",
"scopeguard", "scopeguard",
] ]
[[package]]
name = "crossbeam-queue"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if 0.1.10",
"crossbeam-utils",
"maybe-uninit",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.7.2" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 0.1.10", "cfg-if 1.0.0",
"const_fn",
"lazy_static", "lazy_static",
] ]
@@ -570,12 +574,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.3.3" version = "2.3.3"
@@ -637,20 +635,20 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.19.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]]
name = "object"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"indexmap", "indexmap",
] ]
[[package]]
name = "object"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.4.0" version = "1.4.0"
@@ -793,9 +791,9 @@ dependencies = [
[[package]] [[package]]
name = "rayon" name = "rayon"
version = "1.3.1" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"crossbeam-deque", "crossbeam-deque",
@@ -805,12 +803,12 @@ dependencies = [
[[package]] [[package]]
name = "rayon-core" name = "rayon-core"
version = "1.7.1" version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a"
dependencies = [ dependencies = [
"crossbeam-channel",
"crossbeam-deque", "crossbeam-deque",
"crossbeam-queue",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"num_cpus", "num_cpus",
@@ -824,9 +822,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]] [[package]]
name = "regalloc" name = "regalloc"
version = "0.0.26" version = "0.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1"
dependencies = [ dependencies = [
"log", "log",
"rustc-hash", "rustc-hash",
@@ -1011,9 +1009,9 @@ dependencies = [
[[package]] [[package]]
name = "target-lexicon" name = "target-lexicon"
version = "0.10.0" version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
@@ -1115,7 +1113,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "wasmer" name = "wasmer"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 0.1.10",
"indexmap", "indexmap",
@@ -1137,7 +1135,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-cache" name = "wasmer-cache"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"blake3", "blake3",
"hex", "hex",
@@ -1148,7 +1146,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler" name = "wasmer-compiler"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"enumset", "enumset",
"raw-cpuid", "raw-cpuid",
@@ -1164,7 +1162,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler-cranelift" name = "wasmer-compiler-cranelift"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"cranelift-frontend", "cranelift-frontend",
@@ -1172,6 +1170,7 @@ dependencies = [
"more-asserts", "more-asserts",
"rayon", "rayon",
"serde", "serde",
"smallvec",
"tracing", "tracing",
"wasmer-compiler", "wasmer-compiler",
"wasmer-types", "wasmer-types",
@@ -1180,7 +1179,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler-llvm" name = "wasmer-compiler-llvm"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"cc", "cc",
@@ -1202,7 +1201,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler-singlepass" name = "wasmer-compiler-singlepass"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"dynasm", "dynasm",
@@ -1219,7 +1218,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-engine" name = "wasmer-engine"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bincode", "bincode",
@@ -1237,7 +1236,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-engine-jit" name = "wasmer-engine-jit"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"bincode", "bincode",
"cfg-if 0.1.10", "cfg-if 0.1.10",
@@ -1253,7 +1252,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-engine-native" name = "wasmer-engine-native"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"bincode", "bincode",
"cfg-if 0.1.10", "cfg-if 0.1.10",
@@ -1272,9 +1271,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-object" name = "wasmer-object"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"object 0.19.0", "object 0.21.1",
"thiserror", "thiserror",
"wasmer-compiler", "wasmer-compiler",
"wasmer-types", "wasmer-types",
@@ -1300,7 +1299,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-types" name = "wasmer-types"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
"serde", "serde",
@@ -1308,7 +1307,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-vm" name = "wasmer-vm"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"cc", "cc",
@@ -1326,9 +1325,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.57.0" version = "0.65.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf"
[[package]] [[package]]
name = "wast" name = "wast"

View File

@@ -15,7 +15,7 @@ maintenance = { status = "deprecated" }
[dependencies] [dependencies]
wasmer-types = { path = "../../wasmer-types", version = "1.0.0-alpha5" } wasmer-types = { path = "../../wasmer-types", version = "1.0.0-alpha5" }
wasmer = { path = "../../api", version = "1.0.0-alpha5" } wasmer = { path = "../../api", version = "1.0.0-alpha5", features = ["deprecated"] }
wasmer-cache = { path = "../../cache", version = "1.0.0-alpha5" } wasmer-cache = { path = "../../cache", version = "1.0.0-alpha5" }
wasmer-compiler = { path = "../../compiler", version = "1.0.0-alpha5", features = ["translator"] } wasmer-compiler = { path = "../../compiler", version = "1.0.0-alpha5", features = ["translator"] }
wasmer-compiler-llvm = { path = "../../compiler-llvm", version = "1.0.0-alpha5", optional = true } wasmer-compiler-llvm = { path = "../../compiler-llvm", version = "1.0.0-alpha5", optional = true }

View File

@@ -6,6 +6,7 @@ use crate::{
}; };
use std::marker::PhantomData; use std::marker::PhantomData;
pub use new::wasmer::internals::UnsafeMutableEnv;
pub use new::wasmer::{HostFunction, WasmTypeList}; pub use new::wasmer::{HostFunction, WasmTypeList};
/// Represents a function that can be used by WebAssembly. /// Represents a function that can be used by WebAssembly.
@@ -27,17 +28,19 @@ where
/// Creates a new `Func`. /// Creates a new `Func`.
pub fn new<F>(func: F) -> Self pub fn new<F>(func: F) -> Self
where where
F: HostFunction<Args, Rets, new::wasmer::internals::WithEnv, vm::Ctx>, F: HostFunction<Args, Rets, new::wasmer::internals::WithUnsafeMutableEnv, vm::Ctx> + Send,
{ {
// Create an empty `vm::Ctx`, that is going to be overwritten by `Instance::new`. // Create an empty `vm::Ctx`, that is going to be overwritten by `Instance::new`.
let ctx = unsafe { vm::Ctx::new_uninit() }; let ctx = unsafe { vm::Ctx::new_uninit() };
Self { Self {
new_function: new::wasmer::Function::new_native_with_env::<F, Args, Rets, vm::Ctx>( new_function: unsafe {
&get_global_store(), new::wasmer::Function::new_native_with_unsafe_mutable_env::<F, Args, Rets, vm::Ctx>(
ctx, &get_global_store(),
func, ctx,
), func,
)
},
_phantom: PhantomData, _phantom: PhantomData,
} }
} }
@@ -234,35 +237,36 @@ use std::{
/// `module::Module::instantiate`. /// `module::Module::instantiate`.
pub(crate) struct DynamicCtx { pub(crate) struct DynamicCtx {
pub(crate) vmctx: Rc<RefCell<vm::Ctx>>, pub(crate) vmctx: Rc<RefCell<vm::Ctx>>,
inner_func:
Box<dyn Fn(&mut vm::Ctx, &[Value]) -> Result<Vec<Value>, RuntimeError> + Send + 'static>,
} }
impl DynamicFunc { impl DynamicFunc {
/// Create a new `DynamicFunc`. /// Create a new `DynamicFunc`.
pub fn new<F>(signature: &FuncSig, func: F) -> Self pub fn new<F>(signature: &FuncSig, func: F) -> Self
where where
F: Fn(&mut vm::Ctx, &[Value]) -> Result<Vec<Value>, RuntimeError> + 'static, F: Fn(&mut vm::Ctx, &[Value]) -> Result<Vec<Value>, RuntimeError> + Send + 'static,
{ {
// Create an empty `vm::Ctx`, that is going to be overwritten by `Instance::new`. // Create an empty `vm::Ctx`, that is going to be overwritten by `Instance::new`.
let ctx = DynamicCtx { let ctx = DynamicCtx {
vmctx: Rc::new(RefCell::new(unsafe { vm::Ctx::new_uninit() })), vmctx: Rc::new(RefCell::new(unsafe { vm::Ctx::new_uninit() })),
inner_func: Box::new(func),
}; };
Self { // Wrapper to safely extract a `&mut vm::Ctx` to pass
new_function: new::wasmer::Function::new_with_env( // to `func`.
&get_global_store(), fn inner(dyn_ctx: &DynamicCtx, params: &[Value]) -> Result<Vec<Value>, RuntimeError> {
signature, let cell: Rc<RefCell<vm::Ctx>> = dyn_ctx.vmctx.clone();
ctx, let mut vmctx: RefMut<vm::Ctx> = cell.borrow_mut();
// Wrapper to safely extract a `&mut vm::Ctx` to pass
// to `func`.
move |dyn_ctx: &mut DynamicCtx,
params: &[Value]|
-> Result<Vec<Value>, RuntimeError> {
let cell: Rc<RefCell<vm::Ctx>> = dyn_ctx.vmctx.clone();
let mut vmctx: RefMut<vm::Ctx> = cell.borrow_mut();
func(vmctx.deref_mut(), params) (dyn_ctx.inner_func)(vmctx.deref_mut(), params)
}, }
),
Self {
new_function: new::wasmer::Function::new_with_env::<
fn(&DynamicCtx, &[Value]) -> Result<Vec<Value>, RuntimeError>,
DynamicCtx,
>(&get_global_store(), signature, ctx, inner),
} }
} }

View File

@@ -1,6 +1,8 @@
use crate::module::ModuleInfo; use crate::{module::ModuleInfo, new};
use std::{ffi::c_void, ptr}; use std::{ffi::c_void, ptr};
use new::wasmer::internals::UnsafeMutableEnv;
/// The context of the currently running WebAssembly instance. /// The context of the currently running WebAssembly instance.
/// ///
/// This is implicitly passed to every WebAssembly function. /// This is implicitly passed to every WebAssembly function.
@@ -38,6 +40,9 @@ pub struct Ctx {
pub data_finalizer: Option<fn(data: *mut c_void)>, pub data_finalizer: Option<fn(data: *mut c_void)>,
} }
/// We mark `Ctx` as a legacy env that can be passed by `&mut`.
unsafe impl UnsafeMutableEnv for Ctx {}
impl Ctx { impl Ctx {
pub(crate) unsafe fn new_uninit() -> Self { pub(crate) unsafe fn new_uninit() -> Self {
Self { Self {

View File

@@ -120,6 +120,12 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "const_fn"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
[[package]] [[package]]
name = "constant_time_eq" name = "constant_time_eq"
version = "0.1.5" version = "0.1.5"
@@ -128,18 +134,18 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]] [[package]]
name = "cranelift-bforest" name = "cranelift-bforest"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9413a2c6bdb01ab8acc867421bd7343ddea491d015453f4e56f4f60c816d120" checksum = "0f065f6889758f817f61a230220d1811ba99a9762af2fb69ae23048314f75ff2"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
] ]
[[package]] [[package]]
name = "cranelift-codegen" name = "cranelift-codegen"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f28d389588c2375bb95292e0bc6cbf010e7f30fb4e9734738b576521b737826a" checksum = "510aa2ab4307644100682b94e449940a0ea15c5887f1d4b9678b8dd5ef31e736"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"cranelift-bforest", "cranelift-bforest",
@@ -149,7 +155,6 @@ dependencies = [
"gimli 0.21.0", "gimli 0.21.0",
"log", "log",
"regalloc", "regalloc",
"serde",
"smallvec", "smallvec",
"target-lexicon", "target-lexicon",
"thiserror", "thiserror",
@@ -157,9 +162,9 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-meta" name = "cranelift-codegen-meta"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74dd3cf6f107c1df4c2b8aab91ec4181aee7ff17289673fcbec63325e7e40a83" checksum = "b4cb0c7e87c60d63b35f9670c15479ee4a5e557dd127efab88b2f9b2ca83c9a0"
dependencies = [ dependencies = [
"cranelift-codegen-shared", "cranelift-codegen-shared",
"cranelift-entity", "cranelift-entity",
@@ -167,24 +172,24 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-shared" name = "cranelift-codegen-shared"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaf050fab2dbf324544489443ff3cc8c67c9420c8902ec6628bd906bd7393e9" checksum = "60636227098693e06de8d6d88beea2a7d32ecf8a8030dacdb57c68e06f381826"
[[package]] [[package]]
name = "cranelift-entity" name = "cranelift-entity"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f07eb8aa0a5da94b56339e4e3052c496a3df4354357cd5da8c7b02c6e8f1dc1d" checksum = "6156db73e0c9f65f80c512988d63ec736be0dee3dd66bf951e3e28aed9dc02d3"
dependencies = [ dependencies = [
"serde", "serde",
] ]
[[package]] [[package]]
name = "cranelift-frontend" name = "cranelift-frontend"
version = "0.65.0" version = "0.67.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f6fe1d3e968576f4b60d23f40ee90281f8de2cdf23d2110f3b0296ff420555e" checksum = "e09cd158c9a820a4cc14a34076811da225cce1d31dc6d03c5ef85b91aef560b9"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"log", "log",
@@ -202,50 +207,49 @@ dependencies = [
] ]
[[package]] [[package]]
name = "crossbeam-deque" name = "crossbeam-channel"
version = "0.7.3" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
dependencies = [ dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
"maybe-uninit",
] ]
[[package]] [[package]]
name = "crossbeam-epoch" name = "crossbeam-epoch"
version = "0.8.2" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f"
dependencies = [ dependencies = [
"autocfg", "cfg-if 1.0.0",
"cfg-if 0.1.10", "const_fn",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"maybe-uninit",
"memoffset", "memoffset",
"scopeguard", "scopeguard",
] ]
[[package]]
name = "crossbeam-queue"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if 0.1.10",
"crossbeam-utils",
"maybe-uninit",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.7.2" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 0.1.10", "cfg-if 1.0.0",
"const_fn",
"lazy_static", "lazy_static",
] ]
@@ -570,12 +574,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.3.3" version = "2.3.3"
@@ -637,20 +635,20 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.19.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]]
name = "object"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"indexmap", "indexmap",
] ]
[[package]]
name = "object"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.4.0" version = "1.4.0"
@@ -793,9 +791,9 @@ dependencies = [
[[package]] [[package]]
name = "rayon" name = "rayon"
version = "1.3.1" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"crossbeam-deque", "crossbeam-deque",
@@ -805,12 +803,12 @@ dependencies = [
[[package]] [[package]]
name = "rayon-core" name = "rayon-core"
version = "1.7.1" version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a"
dependencies = [ dependencies = [
"crossbeam-channel",
"crossbeam-deque", "crossbeam-deque",
"crossbeam-queue",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"num_cpus", "num_cpus",
@@ -824,9 +822,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]] [[package]]
name = "regalloc" name = "regalloc"
version = "0.0.26" version = "0.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1"
dependencies = [ dependencies = [
"log", "log",
"rustc-hash", "rustc-hash",
@@ -1011,9 +1009,9 @@ dependencies = [
[[package]] [[package]]
name = "target-lexicon" name = "target-lexicon"
version = "0.10.0" version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
@@ -1115,7 +1113,7 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "wasmer" name = "wasmer"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if 0.1.10",
"indexmap", "indexmap",
@@ -1137,7 +1135,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-cache" name = "wasmer-cache"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"blake3", "blake3",
"hex", "hex",
@@ -1148,7 +1146,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler" name = "wasmer-compiler"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"enumset", "enumset",
"raw-cpuid", "raw-cpuid",
@@ -1164,7 +1162,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler-cranelift" name = "wasmer-compiler-cranelift"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"cranelift-frontend", "cranelift-frontend",
@@ -1172,6 +1170,7 @@ dependencies = [
"more-asserts", "more-asserts",
"rayon", "rayon",
"serde", "serde",
"smallvec",
"tracing", "tracing",
"wasmer-compiler", "wasmer-compiler",
"wasmer-types", "wasmer-types",
@@ -1180,7 +1179,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler-llvm" name = "wasmer-compiler-llvm"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"cc", "cc",
@@ -1202,7 +1201,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-compiler-singlepass" name = "wasmer-compiler-singlepass"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"dynasm", "dynasm",
@@ -1219,7 +1218,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-engine" name = "wasmer-engine"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bincode", "bincode",
@@ -1237,7 +1236,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-engine-jit" name = "wasmer-engine-jit"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"bincode", "bincode",
"cfg-if 0.1.10", "cfg-if 0.1.10",
@@ -1253,7 +1252,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-engine-native" name = "wasmer-engine-native"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"bincode", "bincode",
"cfg-if 0.1.10", "cfg-if 0.1.10",
@@ -1272,9 +1271,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-object" name = "wasmer-object"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"object 0.19.0", "object 0.21.1",
"thiserror", "thiserror",
"wasmer-compiler", "wasmer-compiler",
"wasmer-types", "wasmer-types",
@@ -1307,7 +1306,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-types" name = "wasmer-types"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
"serde", "serde",
@@ -1315,7 +1314,7 @@ dependencies = [
[[package]] [[package]]
name = "wasmer-vm" name = "wasmer-vm"
version = "1.0.0-alpha4" version = "1.0.0-alpha5"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"cc", "cc",
@@ -1333,9 +1332,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.57.0" version = "0.65.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf"
[[package]] [[package]]
name = "wast" name = "wast"

View File

@@ -2,7 +2,7 @@ use crate::emscripten_target;
use crate::EmEnv; use crate::EmEnv;
///emscripten: _llvm_bswap_i64 ///emscripten: _llvm_bswap_i64
pub fn _llvm_bswap_i64(ctx: &mut EmEnv, _low: i32, high: i32) -> i32 { pub fn _llvm_bswap_i64(ctx: &EmEnv, _low: i32, high: i32) -> i32 {
debug!("emscripten::_llvm_bswap_i64"); debug!("emscripten::_llvm_bswap_i64");
emscripten_target::setTempRet0(ctx, _low.swap_bytes()); emscripten_target::setTempRet0(ctx, _low.swap_bytes());
high.swap_bytes() high.swap_bytes()

View File

@@ -5,31 +5,31 @@ use crate::EmEnv;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use libc::getdtablesize; use libc::getdtablesize;
pub fn asm_const_i(_ctx: &mut EmEnv, _val: i32) -> i32 { pub fn asm_const_i(_ctx: &EmEnv, _val: i32) -> i32 {
debug!("emscripten::asm_const_i: {}", _val); debug!("emscripten::asm_const_i: {}", _val);
0 0
} }
pub fn exit_with_live_runtime(_ctx: &mut EmEnv) { pub fn exit_with_live_runtime(_ctx: &EmEnv) {
debug!("emscripten::exit_with_live_runtime"); debug!("emscripten::exit_with_live_runtime");
} }
pub fn setTempRet0(ctx: &mut EmEnv, val: i32) { pub fn setTempRet0(ctx: &EmEnv, val: i32) {
trace!("emscripten::setTempRet0: {}", val); trace!("emscripten::setTempRet0: {}", val);
get_emscripten_data(ctx).temp_ret_0 = val; get_emscripten_data(ctx).temp_ret_0 = val;
} }
pub fn getTempRet0(ctx: &mut EmEnv) -> i32 { pub fn getTempRet0(ctx: &EmEnv) -> i32 {
trace!("emscripten::getTempRet0"); trace!("emscripten::getTempRet0");
get_emscripten_data(ctx).temp_ret_0 get_emscripten_data(ctx).temp_ret_0
} }
pub fn _alarm(_ctx: &mut EmEnv, _seconds: u32) -> i32 { pub fn _alarm(_ctx: &EmEnv, _seconds: u32) -> i32 {
debug!("emscripten::_alarm({})", _seconds); debug!("emscripten::_alarm({})", _seconds);
0 0
} }
pub fn _atexit(_ctx: &mut EmEnv, _func: i32) -> i32 { pub fn _atexit(_ctx: &EmEnv, _func: i32) -> i32 {
debug!("emscripten::_atexit"); debug!("emscripten::_atexit");
// TODO: implement atexit properly // TODO: implement atexit properly
// __ATEXIT__.unshift({ // __ATEXIT__.unshift({
@@ -38,38 +38,38 @@ pub fn _atexit(_ctx: &mut EmEnv, _func: i32) -> i32 {
// }); // });
0 0
} }
pub fn __Unwind_Backtrace(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn __Unwind_Backtrace(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
debug!("emscripten::__Unwind_Backtrace"); debug!("emscripten::__Unwind_Backtrace");
0 0
} }
pub fn __Unwind_FindEnclosingFunction(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn __Unwind_FindEnclosingFunction(_ctx: &EmEnv, _a: i32) -> i32 {
debug!("emscripten::__Unwind_FindEnclosingFunction"); debug!("emscripten::__Unwind_FindEnclosingFunction");
0 0
} }
pub fn __Unwind_GetIPInfo(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn __Unwind_GetIPInfo(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
debug!("emscripten::__Unwind_GetIPInfo"); debug!("emscripten::__Unwind_GetIPInfo");
0 0
} }
pub fn ___cxa_find_matching_catch_2(_ctx: &mut EmEnv) -> i32 { pub fn ___cxa_find_matching_catch_2(_ctx: &EmEnv) -> i32 {
debug!("emscripten::___cxa_find_matching_catch_2"); debug!("emscripten::___cxa_find_matching_catch_2");
0 0
} }
pub fn ___cxa_find_matching_catch_3(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn ___cxa_find_matching_catch_3(_ctx: &EmEnv, _a: i32) -> i32 {
debug!("emscripten::___cxa_find_matching_catch_3"); debug!("emscripten::___cxa_find_matching_catch_3");
0 0
} }
pub fn ___cxa_free_exception(_ctx: &mut EmEnv, _a: i32) { pub fn ___cxa_free_exception(_ctx: &EmEnv, _a: i32) {
debug!("emscripten::___cxa_free_exception"); debug!("emscripten::___cxa_free_exception");
} }
pub fn ___resumeException(_ctx: &mut EmEnv, _a: i32) { pub fn ___resumeException(_ctx: &EmEnv, _a: i32) {
debug!("emscripten::___resumeException"); debug!("emscripten::___resumeException");
} }
pub fn _dladdr(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _dladdr(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_dladdr"); debug!("emscripten::_dladdr");
0 0
} }
pub fn ___gxx_personality_v0( pub fn ___gxx_personality_v0(
_ctx: &mut EmEnv, _ctx: &EmEnv,
_a: i32, _a: i32,
_b: i32, _b: i32,
_c: i32, _c: i32,
@@ -82,25 +82,25 @@ pub fn ___gxx_personality_v0(
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub fn _getdtablesize(_ctx: &mut EmEnv) -> i32 { pub fn _getdtablesize(_ctx: &EmEnv) -> i32 {
debug!("emscripten::getdtablesize"); debug!("emscripten::getdtablesize");
unsafe { getdtablesize() } unsafe { getdtablesize() }
} }
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
pub fn _getdtablesize(_ctx: &mut EmEnv) -> i32 { pub fn _getdtablesize(_ctx: &EmEnv) -> i32 {
debug!("emscripten::getdtablesize"); debug!("emscripten::getdtablesize");
-1 -1
} }
pub fn _gethostbyaddr(_ctx: &mut EmEnv, _addr: i32, _addrlen: i32, _atype: i32) -> i32 { pub fn _gethostbyaddr(_ctx: &EmEnv, _addr: i32, _addrlen: i32, _atype: i32) -> i32 {
debug!("emscripten::gethostbyaddr"); debug!("emscripten::gethostbyaddr");
0 0
} }
pub fn _gethostbyname(_ctx: &mut EmEnv, _name: i32) -> i32 { pub fn _gethostbyname(_ctx: &EmEnv, _name: i32) -> i32 {
debug!("emscripten::gethostbyname_r"); debug!("emscripten::gethostbyname_r");
0 0
} }
pub fn _gethostbyname_r( pub fn _gethostbyname_r(
_ctx: &mut EmEnv, _ctx: &EmEnv,
_name: i32, _name: i32,
_ret: i32, _ret: i32,
_buf: i32, _buf: i32,
@@ -112,12 +112,12 @@ pub fn _gethostbyname_r(
0 0
} }
// NOTE: php.js has proper impl; libc has proper impl for linux // NOTE: php.js has proper impl; libc has proper impl for linux
pub fn _getloadavg(_ctx: &mut EmEnv, _loadavg: i32, _nelem: i32) -> i32 { pub fn _getloadavg(_ctx: &EmEnv, _loadavg: i32, _nelem: i32) -> i32 {
debug!("emscripten::getloadavg"); debug!("emscripten::getloadavg");
0 0
} }
pub fn _getnameinfo( pub fn _getnameinfo(
_ctx: &mut EmEnv, _ctx: &EmEnv,
_addr: i32, _addr: i32,
_addrlen: i32, _addrlen: i32,
_host: i32, _host: i32,
@@ -170,73 +170,65 @@ macro_rules! invoke_no_return {
} }
// Invoke functions // Invoke functions
pub fn invoke_i(ctx: &mut EmEnv, index: i32) -> i32 { pub fn invoke_i(ctx: &EmEnv, index: i32) -> i32 {
debug!("emscripten::invoke_i"); debug!("emscripten::invoke_i");
invoke!(ctx, dyn_call_i, index) invoke!(ctx, dyn_call_i, index)
} }
pub fn invoke_ii(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 { pub fn invoke_ii(ctx: &EmEnv, index: i32, a1: i32) -> i32 {
debug!("emscripten::invoke_ii"); debug!("emscripten::invoke_ii");
invoke!(ctx, dyn_call_ii, index, a1) invoke!(ctx, dyn_call_ii, index, a1)
} }
pub fn invoke_iii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 { pub fn invoke_iii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) -> i32 {
debug!("emscripten::invoke_iii"); debug!("emscripten::invoke_iii");
invoke!(ctx, dyn_call_iii, index, a1, a2) invoke!(ctx, dyn_call_iii, index, a1, a2)
} }
pub fn invoke_iiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { pub fn invoke_iiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
debug!("emscripten::invoke_iiii"); debug!("emscripten::invoke_iiii");
invoke!(ctx, dyn_call_iiii, index, a1, a2, a3) invoke!(ctx, dyn_call_iiii, index, a1, a2, a3)
} }
pub fn invoke_iifi(ctx: &mut EmEnv, index: i32, a1: i32, a2: f64, a3: i32) -> i32 { pub fn invoke_iifi(ctx: &EmEnv, index: i32, a1: i32, a2: f64, a3: i32) -> i32 {
debug!("emscripten::invoke_iifi"); debug!("emscripten::invoke_iifi");
invoke!(ctx, dyn_call_iifi, index, a1, a2, a3) invoke!(ctx, dyn_call_iifi, index, a1, a2, a3)
} }
pub fn invoke_v(ctx: &mut EmEnv, index: i32) { pub fn invoke_v(ctx: &EmEnv, index: i32) {
debug!("emscripten::invoke_v"); debug!("emscripten::invoke_v");
invoke_no_return!(ctx, dyn_call_v, index); invoke_no_return!(ctx, dyn_call_v, index);
} }
pub fn invoke_vi(ctx: &mut EmEnv, index: i32, a1: i32) { pub fn invoke_vi(ctx: &EmEnv, index: i32, a1: i32) {
debug!("emscripten::invoke_vi"); debug!("emscripten::invoke_vi");
invoke_no_return!(ctx, dyn_call_vi, index, a1); invoke_no_return!(ctx, dyn_call_vi, index, a1);
} }
pub fn invoke_vii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) { pub fn invoke_vii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) {
debug!("emscripten::invoke_vii"); debug!("emscripten::invoke_vii");
invoke_no_return!(ctx, dyn_call_vii, index, a1, a2); invoke_no_return!(ctx, dyn_call_vii, index, a1, a2);
} }
pub fn invoke_viii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) { pub fn invoke_viii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) {
debug!("emscripten::invoke_viii"); debug!("emscripten::invoke_viii");
invoke_no_return!(ctx, dyn_call_viii, index, a1, a2, a3); invoke_no_return!(ctx, dyn_call_viii, index, a1, a2, a3);
} }
pub fn invoke_viiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { pub fn invoke_viiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
debug!("emscripten::invoke_viiii"); debug!("emscripten::invoke_viiii");
invoke_no_return!(ctx, dyn_call_viiii, index, a1, a2, a3, a4); invoke_no_return!(ctx, dyn_call_viiii, index, a1, a2, a3, a4);
} }
pub fn invoke_dii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> f64 { pub fn invoke_dii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) -> f64 {
debug!("emscripten::invoke_dii"); debug!("emscripten::invoke_dii");
invoke!(ctx, dyn_call_dii, index, a1, a2) invoke!(ctx, dyn_call_dii, index, a1, a2)
} }
pub fn invoke_diiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> f64 { pub fn invoke_diiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> f64 {
debug!("emscripten::invoke_diiii"); debug!("emscripten::invoke_diiii");
invoke!(ctx, dyn_call_diiii, index, a1, a2, a3, a4) invoke!(ctx, dyn_call_diiii, index, a1, a2, a3, a4)
} }
pub fn invoke_iiiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { pub fn invoke_iiiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
debug!("emscripten::invoke_iiiii"); debug!("emscripten::invoke_iiiii");
invoke!(ctx, dyn_call_iiiii, index, a1, a2, a3, a4) invoke!(ctx, dyn_call_iiiii, index, a1, a2, a3, a4)
} }
pub fn invoke_iiiiii( pub fn invoke_iiiiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> i32 {
ctx: &mut EmEnv,
index: i32,
a1: i32,
a2: i32,
a3: i32,
a4: i32,
a5: i32,
) -> i32 {
debug!("emscripten::invoke_iiiiii"); debug!("emscripten::invoke_iiiiii");
invoke!(ctx, dyn_call_iiiiii, index, a1, a2, a3, a4, a5) invoke!(ctx, dyn_call_iiiiii, index, a1, a2, a3, a4, a5)
} }
pub fn invoke_iiiiiii( pub fn invoke_iiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -249,7 +241,7 @@ pub fn invoke_iiiiiii(
invoke!(ctx, dyn_call_iiiiiii, index, a1, a2, a3, a4, a5, a6) invoke!(ctx, dyn_call_iiiiiii, index, a1, a2, a3, a4, a5, a6)
} }
pub fn invoke_iiiiiiii( pub fn invoke_iiiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -263,7 +255,7 @@ pub fn invoke_iiiiiiii(
invoke!(ctx, dyn_call_iiiiiiii, index, a1, a2, a3, a4, a5, a6, a7) invoke!(ctx, dyn_call_iiiiiiii, index, a1, a2, a3, a4, a5, a6, a7)
} }
pub fn invoke_iiiiiiiii( pub fn invoke_iiiiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -290,7 +282,7 @@ pub fn invoke_iiiiiiiii(
) )
} }
pub fn invoke_iiiiiiiiii( pub fn invoke_iiiiiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -319,7 +311,7 @@ pub fn invoke_iiiiiiiiii(
) )
} }
pub fn invoke_iiiiiiiiiii( pub fn invoke_iiiiiiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -349,16 +341,16 @@ pub fn invoke_iiiiiiiiiii(
a10 a10
) )
} }
pub fn invoke_vd(ctx: &mut EmEnv, index: i32, a1: f64) { pub fn invoke_vd(ctx: &EmEnv, index: i32, a1: f64) {
debug!("emscripten::invoke_vd"); debug!("emscripten::invoke_vd");
invoke_no_return!(ctx, dyn_call_vd, index, a1) invoke_no_return!(ctx, dyn_call_vd, index, a1)
} }
pub fn invoke_viiiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { pub fn invoke_viiiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
debug!("emscripten::invoke_viiiii"); debug!("emscripten::invoke_viiiii");
invoke_no_return!(ctx, dyn_call_viiiii, index, a1, a2, a3, a4, a5) invoke_no_return!(ctx, dyn_call_viiiii, index, a1, a2, a3, a4, a5)
} }
pub fn invoke_viiiiii( pub fn invoke_viiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -371,7 +363,7 @@ pub fn invoke_viiiiii(
invoke_no_return!(ctx, dyn_call_viiiiii, index, a1, a2, a3, a4, a5, a6) invoke_no_return!(ctx, dyn_call_viiiiii, index, a1, a2, a3, a4, a5, a6)
} }
pub fn invoke_viiiiiii( pub fn invoke_viiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -385,7 +377,7 @@ pub fn invoke_viiiiiii(
invoke_no_return!(ctx, dyn_call_viiiiiii, index, a1, a2, a3, a4, a5, a6, a7) invoke_no_return!(ctx, dyn_call_viiiiiii, index, a1, a2, a3, a4, a5, a6, a7)
} }
pub fn invoke_viiiiiiii( pub fn invoke_viiiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -412,7 +404,7 @@ pub fn invoke_viiiiiiii(
) )
} }
pub fn invoke_viiiiiiiii( pub fn invoke_viiiiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -441,7 +433,7 @@ pub fn invoke_viiiiiiiii(
) )
} }
pub fn invoke_viiiiiiiiii( pub fn invoke_viiiiiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -472,23 +464,23 @@ pub fn invoke_viiiiiiiiii(
) )
} }
pub fn invoke_iij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { pub fn invoke_iij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
debug!("emscripten::invoke_iij"); debug!("emscripten::invoke_iij");
invoke!(ctx, dyn_call_iij, index, a1, a2, a3) invoke!(ctx, dyn_call_iij, index, a1, a2, a3)
} }
pub fn invoke_iji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { pub fn invoke_iji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
debug!("emscripten::invoke_iji"); debug!("emscripten::invoke_iji");
invoke!(ctx, dyn_call_iji, index, a1, a2, a3) invoke!(ctx, dyn_call_iji, index, a1, a2, a3)
} }
pub fn invoke_iiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { pub fn invoke_iiji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
debug!("emscripten::invoke_iiji"); debug!("emscripten::invoke_iiji");
invoke!(ctx, dyn_call_iiji, index, a1, a2, a3, a4) invoke!(ctx, dyn_call_iiji, index, a1, a2, a3, a4)
} }
pub fn invoke_iiijj( pub fn invoke_iiijj(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -500,7 +492,7 @@ pub fn invoke_iiijj(
debug!("emscripten::invoke_iiijj"); debug!("emscripten::invoke_iiijj");
invoke!(ctx, dyn_call_iiijj, index, a1, a2, a3, a4, a5, a6) invoke!(ctx, dyn_call_iiijj, index, a1, a2, a3, a4, a5, a6)
} }
pub fn invoke_j(ctx: &mut EmEnv, index: i32) -> i32 { pub fn invoke_j(ctx: &EmEnv, index: i32) -> i32 {
debug!("emscripten::invoke_j"); debug!("emscripten::invoke_j");
if let Some(dyn_call_j) = &get_emscripten_data(ctx).dyn_call_j { if let Some(dyn_call_j) = &get_emscripten_data(ctx).dyn_call_j {
dyn_call_j.call(index).unwrap() dyn_call_j.call(index).unwrap()
@@ -508,7 +500,7 @@ pub fn invoke_j(ctx: &mut EmEnv, index: i32) -> i32 {
panic!("dyn_call_j is set to None"); panic!("dyn_call_j is set to None");
} }
} }
pub fn invoke_ji(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 { pub fn invoke_ji(ctx: &EmEnv, index: i32, a1: i32) -> i32 {
debug!("emscripten::invoke_ji"); debug!("emscripten::invoke_ji");
if let Some(dyn_call_ji) = &get_emscripten_data(ctx).dyn_call_ji { if let Some(dyn_call_ji) = &get_emscripten_data(ctx).dyn_call_ji {
dyn_call_ji.call(index, a1).unwrap() dyn_call_ji.call(index, a1).unwrap()
@@ -516,7 +508,7 @@ pub fn invoke_ji(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 {
panic!("dyn_call_ji is set to None"); panic!("dyn_call_ji is set to None");
} }
} }
pub fn invoke_jii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 { pub fn invoke_jii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) -> i32 {
debug!("emscripten::invoke_jii"); debug!("emscripten::invoke_jii");
if let Some(dyn_call_jii) = &get_emscripten_data(ctx).dyn_call_jii { if let Some(dyn_call_jii) = &get_emscripten_data(ctx).dyn_call_jii {
dyn_call_jii.call(index, a1, a2).unwrap() dyn_call_jii.call(index, a1, a2).unwrap()
@@ -525,7 +517,7 @@ pub fn invoke_jii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 {
} }
} }
pub fn invoke_jij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { pub fn invoke_jij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 {
debug!("emscripten::invoke_jij"); debug!("emscripten::invoke_jij");
if let Some(dyn_call_jij) = &get_emscripten_data(ctx).dyn_call_jij { if let Some(dyn_call_jij) = &get_emscripten_data(ctx).dyn_call_jij {
dyn_call_jij.call(index, a1, a2, a3).unwrap() dyn_call_jij.call(index, a1, a2, a3).unwrap()
@@ -533,7 +525,7 @@ pub fn invoke_jij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32
panic!("dyn_call_jij is set to None"); panic!("dyn_call_jij is set to None");
} }
} }
pub fn invoke_jjj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { pub fn invoke_jjj(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 {
debug!("emscripten::invoke_jjj"); debug!("emscripten::invoke_jjj");
if let Some(dyn_call_jjj) = &get_emscripten_data(ctx).dyn_call_jjj { if let Some(dyn_call_jjj) = &get_emscripten_data(ctx).dyn_call_jjj {
dyn_call_jjj.call(index, a1, a2, a3, a4).unwrap() dyn_call_jjj.call(index, a1, a2, a3, a4).unwrap()
@@ -541,7 +533,7 @@ pub fn invoke_jjj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i3
panic!("dyn_call_jjj is set to None"); panic!("dyn_call_jjj is set to None");
} }
} }
pub fn invoke_viiij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { pub fn invoke_viiij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
debug!("emscripten::invoke_viiij"); debug!("emscripten::invoke_viiij");
if let Some(dyn_call_viiij) = &get_emscripten_data(ctx).dyn_call_viiij { if let Some(dyn_call_viiij) = &get_emscripten_data(ctx).dyn_call_viiij {
dyn_call_viiij.call(index, a1, a2, a3, a4, a5).unwrap(); dyn_call_viiij.call(index, a1, a2, a3, a4, a5).unwrap();
@@ -550,7 +542,7 @@ pub fn invoke_viiij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4:
} }
} }
pub fn invoke_viiijiiii( pub fn invoke_viiijiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -572,7 +564,7 @@ pub fn invoke_viiijiiii(
} }
} }
pub fn invoke_viiijiiiiii( pub fn invoke_viiijiiiiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -595,7 +587,7 @@ pub fn invoke_viiijiiiiii(
panic!("dyn_call_viiijiiiiii is set to None"); panic!("dyn_call_viiijiiiiii is set to None");
} }
} }
pub fn invoke_viij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { pub fn invoke_viij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
debug!("emscripten::invoke_viij"); debug!("emscripten::invoke_viij");
if let Some(dyn_call_viij) = &get_emscripten_data(ctx).dyn_call_viij { if let Some(dyn_call_viij) = &get_emscripten_data(ctx).dyn_call_viij {
dyn_call_viij.call(index, a1, a2, a3, a4).unwrap(); dyn_call_viij.call(index, a1, a2, a3, a4).unwrap();
@@ -603,7 +595,7 @@ pub fn invoke_viij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i
panic!("dyn_call_viij is set to None"); panic!("dyn_call_viij is set to None");
} }
} }
pub fn invoke_viiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { pub fn invoke_viiji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
debug!("emscripten::invoke_viiji"); debug!("emscripten::invoke_viiji");
if let Some(dyn_call_viiji) = &get_emscripten_data(ctx).dyn_call_viiji { if let Some(dyn_call_viiji) = &get_emscripten_data(ctx).dyn_call_viiji {
dyn_call_viiji.call(index, a1, a2, a3, a4, a5).unwrap(); dyn_call_viiji.call(index, a1, a2, a3, a4, a5).unwrap();
@@ -612,7 +604,7 @@ pub fn invoke_viiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4:
} }
} }
pub fn invoke_viijiii( pub fn invoke_viijiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -631,16 +623,7 @@ pub fn invoke_viijiii(
panic!("dyn_call_viijiii is set to None"); panic!("dyn_call_viijiii is set to None");
} }
} }
pub fn invoke_viijj( pub fn invoke_viijj(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) {
ctx: &mut EmEnv,
index: i32,
a1: i32,
a2: i32,
a3: i32,
a4: i32,
a5: i32,
a6: i32,
) {
debug!("emscripten::invoke_viijj"); debug!("emscripten::invoke_viijj");
if let Some(dyn_call_viijj) = &get_emscripten_data(ctx).dyn_call_viijj { if let Some(dyn_call_viijj) = &get_emscripten_data(ctx).dyn_call_viijj {
dyn_call_viijj.call(index, a1, a2, a3, a4, a5, a6).unwrap(); dyn_call_viijj.call(index, a1, a2, a3, a4, a5, a6).unwrap();
@@ -648,7 +631,7 @@ pub fn invoke_viijj(
panic!("dyn_call_viijj is set to None"); panic!("dyn_call_viijj is set to None");
} }
} }
pub fn invoke_vj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) { pub fn invoke_vj(ctx: &EmEnv, index: i32, a1: i32, a2: i32) {
debug!("emscripten::invoke_vj"); debug!("emscripten::invoke_vj");
if let Some(dyn_call_vj) = &get_emscripten_data(ctx).dyn_call_vj { if let Some(dyn_call_vj) = &get_emscripten_data(ctx).dyn_call_vj {
dyn_call_vj.call(index, a1, a2).unwrap(); dyn_call_vj.call(index, a1, a2).unwrap();
@@ -656,11 +639,11 @@ pub fn invoke_vj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) {
panic!("dyn_call_vj is set to None"); panic!("dyn_call_vj is set to None");
} }
} }
pub fn invoke_vjji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { pub fn invoke_vjji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
debug!("emscripten::invoke_vjji"); debug!("emscripten::invoke_vjji");
invoke_no_return!(ctx, dyn_call_vjji, index, a1, a2, a3, a4, a5) invoke_no_return!(ctx, dyn_call_vjji, index, a1, a2, a3, a4, a5)
} }
pub fn invoke_vij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) { pub fn invoke_vij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) {
debug!("emscripten::invoke_vij"); debug!("emscripten::invoke_vij");
if let Some(dyn_call_vij) = &get_emscripten_data(ctx).dyn_call_vij { if let Some(dyn_call_vij) = &get_emscripten_data(ctx).dyn_call_vij {
dyn_call_vij.call(index, a1, a2, a3).unwrap(); dyn_call_vij.call(index, a1, a2, a3).unwrap();
@@ -668,7 +651,7 @@ pub fn invoke_vij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) {
panic!("dyn_call_vij is set to None"); panic!("dyn_call_vij is set to None");
} }
} }
pub fn invoke_viji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { pub fn invoke_viji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) {
debug!("emscripten::invoke_viji"); debug!("emscripten::invoke_viji");
if let Some(dyn_call_viji) = &get_emscripten_data(ctx).dyn_call_viji { if let Some(dyn_call_viji) = &get_emscripten_data(ctx).dyn_call_viji {
dyn_call_viji.call(index, a1, a2, a3, a4).unwrap() dyn_call_viji.call(index, a1, a2, a3, a4).unwrap()
@@ -677,7 +660,7 @@ pub fn invoke_viji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i
} }
} }
pub fn invoke_vijiii( pub fn invoke_vijiii(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,
@@ -693,7 +676,7 @@ pub fn invoke_vijiii(
panic!("dyn_call_vijiii is set to None"); panic!("dyn_call_vijiii is set to None");
} }
} }
pub fn invoke_vijj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { pub fn invoke_vijj(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
debug!("emscripten::invoke_vijj"); debug!("emscripten::invoke_vijj");
if let Some(dyn_call_vijj) = &get_emscripten_data(ctx).dyn_call_vijj { if let Some(dyn_call_vijj) = &get_emscripten_data(ctx).dyn_call_vijj {
dyn_call_vijj.call(index, a1, a2, a3, a4, a5).unwrap() dyn_call_vijj.call(index, a1, a2, a3, a4, a5).unwrap()
@@ -701,20 +684,20 @@ pub fn invoke_vijj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i
panic!("dyn_call_vijj is set to None"); panic!("dyn_call_vijj is set to None");
} }
} }
pub fn invoke_vidd(ctx: &mut EmEnv, index: i32, a1: i32, a2: f64, a3: f64) { pub fn invoke_vidd(ctx: &EmEnv, index: i32, a1: i32, a2: f64, a3: f64) {
debug!("emscripten::invoke_viid"); debug!("emscripten::invoke_viid");
invoke_no_return!(ctx, dyn_call_vidd, index, a1, a2, a3); invoke_no_return!(ctx, dyn_call_vidd, index, a1, a2, a3);
} }
pub fn invoke_viid(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: f64) { pub fn invoke_viid(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: f64) {
debug!("emscripten::invoke_viid"); debug!("emscripten::invoke_viid");
invoke_no_return!(ctx, dyn_call_viid, index, a1, a2, a3); invoke_no_return!(ctx, dyn_call_viid, index, a1, a2, a3);
} }
pub fn invoke_viidii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: f64, a4: i32, a5: i32) { pub fn invoke_viidii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: f64, a4: i32, a5: i32) {
debug!("emscripten::invoke_viidii"); debug!("emscripten::invoke_viidii");
invoke_no_return!(ctx, dyn_call_viidii, index, a1, a2, a3, a4, a5); invoke_no_return!(ctx, dyn_call_viidii, index, a1, a2, a3, a4, a5);
} }
pub fn invoke_viidddddddd( pub fn invoke_viidddddddd(
ctx: &mut EmEnv, ctx: &EmEnv,
index: i32, index: i32,
a1: i32, a1: i32,
a2: i32, a2: i32,

View File

@@ -23,7 +23,7 @@ use std::os::raw::c_int;
use crate::EmEnv; use crate::EmEnv;
use wasmer::ValueType; use wasmer::ValueType;
pub fn call_malloc(ctx: &mut EmEnv, size: u32) -> u32 { pub fn call_malloc(ctx: &EmEnv, size: u32) -> u32 {
get_emscripten_data(ctx) get_emscripten_data(ctx)
.malloc .malloc
.as_ref() .as_ref()
@@ -33,11 +33,11 @@ pub fn call_malloc(ctx: &mut EmEnv, size: u32) -> u32 {
} }
#[warn(dead_code)] #[warn(dead_code)]
pub fn call_malloc_with_cast<T: Copy, Ty>(ctx: &mut EmEnv, size: u32) -> WasmPtr<T, Ty> { pub fn call_malloc_with_cast<T: Copy, Ty>(ctx: &EmEnv, size: u32) -> WasmPtr<T, Ty> {
WasmPtr::new(call_malloc(ctx, size)) WasmPtr::new(call_malloc(ctx, size))
} }
pub fn call_memalign(ctx: &mut EmEnv, alignment: u32, size: u32) -> u32 { pub fn call_memalign(ctx: &EmEnv, alignment: u32, size: u32) -> u32 {
if let Some(memalign) = &get_emscripten_data(ctx).memalign { if let Some(memalign) = &get_emscripten_data(ctx).memalign {
memalign.call(alignment, size).unwrap() memalign.call(alignment, size).unwrap()
} else { } else {
@@ -45,7 +45,7 @@ pub fn call_memalign(ctx: &mut EmEnv, alignment: u32, size: u32) -> u32 {
} }
} }
pub fn call_memset(ctx: &mut EmEnv, pointer: u32, value: u32, size: u32) -> u32 { pub fn call_memset(ctx: &EmEnv, pointer: u32, value: u32, size: u32) -> u32 {
get_emscripten_data(ctx) get_emscripten_data(ctx)
.memset .memset
.as_ref() .as_ref()
@@ -54,16 +54,16 @@ pub fn call_memset(ctx: &mut EmEnv, pointer: u32, value: u32, size: u32) -> u32
.unwrap() .unwrap()
} }
pub(crate) fn get_emscripten_data<'a>(ctx: &'a mut EmEnv) -> &'a mut EmscriptenData<'static> { pub(crate) fn get_emscripten_data<'a>(ctx: &'a EmEnv) -> &'a mut EmscriptenData<'static> {
unsafe { &mut **ctx.data } unsafe { &mut **ctx.data }
} }
pub fn _getpagesize(_ctx: &mut EmEnv) -> u32 { pub fn _getpagesize(_ctx: &EmEnv) -> u32 {
debug!("emscripten::_getpagesize"); debug!("emscripten::_getpagesize");
16384 16384
} }
pub fn _times(ctx: &mut EmEnv, buffer: u32) -> u32 { pub fn _times(ctx: &EmEnv, buffer: u32) -> u32 {
if buffer != 0 { if buffer != 0 {
call_memset(ctx, buffer, 0, 16); call_memset(ctx, buffer, 0, 16);
} }
@@ -71,7 +71,7 @@ pub fn _times(ctx: &mut EmEnv, buffer: u32) -> u32 {
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___build_environment(ctx: &mut EmEnv, environ: c_int) { pub fn ___build_environment(ctx: &EmEnv, environ: c_int) {
debug!("emscripten::___build_environment {}", environ); debug!("emscripten::___build_environment {}", environ);
const MAX_ENV_VALUES: u32 = 64; const MAX_ENV_VALUES: u32 = 64;
const TOTAL_ENV_SIZE: u32 = 1024; const TOTAL_ENV_SIZE: u32 = 1024;
@@ -123,13 +123,13 @@ pub fn ___build_environment(ctx: &mut EmEnv, environ: c_int) {
} }
} }
pub fn ___assert_fail(_ctx: &mut EmEnv, _a: c_int, _b: c_int, _c: c_int, _d: c_int) { pub fn ___assert_fail(_ctx: &EmEnv, _a: c_int, _b: c_int, _c: c_int, _d: c_int) {
debug!("emscripten::___assert_fail {} {} {} {}", _a, _b, _c, _d); debug!("emscripten::___assert_fail {} {} {} {}", _a, _b, _c, _d);
// TODO: Implement like emscripten expects regarding memory/page size // TODO: Implement like emscripten expects regarding memory/page size
// TODO raise an error // TODO raise an error
} }
pub fn _pathconf(ctx: &mut EmEnv, path_addr: c_int, name: c_int) -> c_int { pub fn _pathconf(ctx: &EmEnv, path_addr: c_int, name: c_int) -> c_int {
debug!( debug!(
"emscripten::_pathconf {} {} - UNIMPLEMENTED", "emscripten::_pathconf {} {} - UNIMPLEMENTED",
path_addr, name path_addr, name
@@ -150,7 +150,7 @@ pub fn _pathconf(ctx: &mut EmEnv, path_addr: c_int, name: c_int) -> c_int {
} }
} }
pub fn _fpathconf(_ctx: &mut EmEnv, _fildes: c_int, name: c_int) -> c_int { pub fn _fpathconf(_ctx: &EmEnv, _fildes: c_int, name: c_int) -> c_int {
debug!("emscripten::_fpathconf {} {}", _fildes, name); debug!("emscripten::_fpathconf {} {}", _fildes, name);
match name { match name {
0 => 32000, 0 => 32000,

View File

@@ -15,7 +15,7 @@ use crate::EmEnv;
// #[no_mangle] // #[no_mangle]
/// emscripten: _getenv // (name: *const char) -> *const c_char; /// emscripten: _getenv // (name: *const char) -> *const c_char;
pub fn _getenv(ctx: &mut EmEnv, name: i32) -> u32 { pub fn _getenv(ctx: &EmEnv, name: i32) -> u32 {
debug!("emscripten::_getenv"); debug!("emscripten::_getenv");
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
@@ -31,7 +31,7 @@ pub fn _getenv(ctx: &mut EmEnv, name: i32) -> u32 {
} }
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int); /// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
pub fn _setenv(ctx: &mut EmEnv, name: c_int, value: c_int, overwrite: c_int) -> c_int { pub fn _setenv(ctx: &EmEnv, name: c_int, value: c_int, overwrite: c_int) -> c_int {
debug!("emscripten::_setenv"); debug!("emscripten::_setenv");
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
@@ -44,7 +44,7 @@ pub fn _setenv(ctx: &mut EmEnv, name: c_int, value: c_int, overwrite: c_int) ->
} }
/// emscripten: _putenv // (name: *const char); /// emscripten: _putenv // (name: *const char);
pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int { pub fn _putenv(ctx: &EmEnv, name: c_int) -> c_int {
debug!("emscripten::_putenv"); debug!("emscripten::_putenv");
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
@@ -55,7 +55,7 @@ pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int {
} }
/// emscripten: _unsetenv // (name: *const char); /// emscripten: _unsetenv // (name: *const char);
pub fn _unsetenv(ctx: &mut EmEnv, name: c_int) -> c_int { pub fn _unsetenv(ctx: &EmEnv, name: c_int) -> c_int {
debug!("emscripten::_unsetenv"); debug!("emscripten::_unsetenv");
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
@@ -66,7 +66,7 @@ pub fn _unsetenv(ctx: &mut EmEnv, name: c_int) -> c_int {
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { pub fn _getpwnam(ctx: &EmEnv, name_ptr: c_int) -> c_int {
debug!("emscripten::_getpwnam {}", name_ptr); debug!("emscripten::_getpwnam {}", name_ptr);
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
let _ = name_ptr; let _ = name_ptr;
@@ -106,7 +106,7 @@ pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { pub fn _getgrnam(ctx: &EmEnv, name_ptr: c_int) -> c_int {
debug!("emscripten::_getgrnam {}", name_ptr); debug!("emscripten::_getgrnam {}", name_ptr);
#[repr(C)] #[repr(C)]
@@ -137,14 +137,14 @@ pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
} }
} }
pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> i32 { pub fn _sysconf(_ctx: &EmEnv, name: c_int) -> i32 {
debug!("emscripten::_sysconf {}", name); debug!("emscripten::_sysconf {}", name);
// TODO: Implement like emscripten expects regarding memory/page size // TODO: Implement like emscripten expects regarding memory/page size
unsafe { sysconf(name) as i32 } // TODO review i64 unsafe { sysconf(name) as i32 } // TODO review i64
} }
// this may be a memory leak, probably not though because emscripten does the same thing // this may be a memory leak, probably not though because emscripten does the same thing
pub fn _gai_strerror(ctx: &mut EmEnv, ecode: i32) -> i32 { pub fn _gai_strerror(ctx: &EmEnv, ecode: i32) -> i32 {
debug!("emscripten::_gai_strerror({})", ecode); debug!("emscripten::_gai_strerror({})", ecode);
let cstr = unsafe { std::ffi::CStr::from_ptr(libc::gai_strerror(ecode)) }; let cstr = unsafe { std::ffi::CStr::from_ptr(libc::gai_strerror(ecode)) };
@@ -164,7 +164,7 @@ pub fn _gai_strerror(ctx: &mut EmEnv, ecode: i32) -> i32 {
} }
pub fn _getaddrinfo( pub fn _getaddrinfo(
ctx: &mut EmEnv, ctx: &EmEnv,
node_ptr: WasmPtr<c_char>, node_ptr: WasmPtr<c_char>,
service_str_ptr: WasmPtr<c_char>, service_str_ptr: WasmPtr<c_char>,
hints_ptr: WasmPtr<EmAddrInfo>, hints_ptr: WasmPtr<EmAddrInfo>,

View File

@@ -17,7 +17,7 @@ extern "C" {
// #[no_mangle] // #[no_mangle]
/// emscripten: _getenv // (name: *const char) -> *const c_char; /// emscripten: _getenv // (name: *const char) -> *const c_char;
pub fn _getenv(ctx: &mut EmEnv, name: u32) -> u32 { pub fn _getenv(ctx: &EmEnv, name: u32) -> u32 {
debug!("emscripten::_getenv"); debug!("emscripten::_getenv");
let name_string = read_string_from_wasm(ctx.memory(0), name); let name_string = read_string_from_wasm(ctx.memory(0), name);
debug!("=> name({:?})", name_string); debug!("=> name({:?})", name_string);
@@ -29,7 +29,7 @@ pub fn _getenv(ctx: &mut EmEnv, name: u32) -> u32 {
} }
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int); /// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
pub fn _setenv(ctx: &mut EmEnv, name: u32, value: u32, _overwrite: u32) -> c_int { pub fn _setenv(ctx: &EmEnv, name: u32, value: u32, _overwrite: u32) -> c_int {
debug!("emscripten::_setenv"); debug!("emscripten::_setenv");
// setenv does not exist on windows, so we hack it with _putenv // setenv does not exist on windows, so we hack it with _putenv
let name = read_string_from_wasm(ctx.memory(0), name); let name = read_string_from_wasm(ctx.memory(0), name);
@@ -43,7 +43,7 @@ pub fn _setenv(ctx: &mut EmEnv, name: u32, value: u32, _overwrite: u32) -> c_int
} }
/// emscripten: _putenv // (name: *const char); /// emscripten: _putenv // (name: *const char);
pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int { pub fn _putenv(ctx: &EmEnv, name: c_int) -> c_int {
debug!("emscripten::_putenv"); debug!("emscripten::_putenv");
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
debug!("=> name({:?})", unsafe { debug!("=> name({:?})", unsafe {
@@ -53,7 +53,7 @@ pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int {
} }
/// emscripten: _unsetenv // (name: *const char); /// emscripten: _unsetenv // (name: *const char);
pub fn _unsetenv(ctx: &mut EmEnv, name: u32) -> c_int { pub fn _unsetenv(ctx: &EmEnv, name: u32) -> c_int {
debug!("emscripten::_unsetenv"); debug!("emscripten::_unsetenv");
let name = read_string_from_wasm(ctx.memory(0), name); let name = read_string_from_wasm(ctx.memory(0), name);
// no unsetenv on windows, so use putenv with an empty value // no unsetenv on windows, so use putenv with an empty value
@@ -65,7 +65,7 @@ pub fn _unsetenv(ctx: &mut EmEnv, name: u32) -> c_int {
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { pub fn _getpwnam(ctx: &EmEnv, name_ptr: c_int) -> c_int {
debug!("emscripten::_getpwnam {}", name_ptr); debug!("emscripten::_getpwnam {}", name_ptr);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = name_ptr; let _ = name_ptr;
@@ -99,7 +99,7 @@ pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { pub fn _getgrnam(ctx: &EmEnv, name_ptr: c_int) -> c_int {
debug!("emscripten::_getgrnam {}", name_ptr); debug!("emscripten::_getgrnam {}", name_ptr);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = name_ptr; let _ = name_ptr;
@@ -125,7 +125,7 @@ pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int {
} }
} }
pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> c_long { pub fn _sysconf(_ctx: &EmEnv, name: c_int) -> c_long {
debug!("emscripten::_sysconf {}", name); debug!("emscripten::_sysconf {}", name);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = name; let _ = name;
@@ -133,13 +133,13 @@ pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> c_long {
0 0
} }
pub fn _gai_strerror(_ctx: &mut EmEnv, _ecode: i32) -> i32 { pub fn _gai_strerror(_ctx: &EmEnv, _ecode: i32) -> i32 {
debug!("emscripten::_gai_strerror({}) - stub", _ecode); debug!("emscripten::_gai_strerror({}) - stub", _ecode);
-1 -1
} }
pub fn _getaddrinfo( pub fn _getaddrinfo(
_ctx: &mut EmEnv, _ctx: &EmEnv,
_node_ptr: WasmPtr<c_char>, _node_ptr: WasmPtr<c_char>,
_service_str_ptr: WasmPtr<c_char>, _service_str_ptr: WasmPtr<c_char>,
_hints_ptr: WasmPtr<EmAddrInfo>, _hints_ptr: WasmPtr<EmAddrInfo>,

View File

@@ -1,7 +1,7 @@
// use std::collections::HashMap; // use std::collections::HashMap;
use crate::EmEnv; use crate::EmEnv;
pub fn ___seterrno(_ctx: &mut EmEnv, _value: i32) { pub fn ___seterrno(_ctx: &EmEnv, _value: i32) {
debug!("emscripten::___seterrno {}", _value); debug!("emscripten::___seterrno {}", _value);
// TODO: Incomplete impl // TODO: Incomplete impl
eprintln!("failed to set errno!"); eprintln!("failed to set errno!");

View File

@@ -3,54 +3,54 @@ use super::process::_abort;
use crate::EmEnv; use crate::EmEnv;
/// emscripten: ___cxa_allocate_exception /// emscripten: ___cxa_allocate_exception
pub fn ___cxa_allocate_exception(ctx: &mut EmEnv, size: u32) -> u32 { pub fn ___cxa_allocate_exception(ctx: &EmEnv, size: u32) -> u32 {
debug!("emscripten::___cxa_allocate_exception"); debug!("emscripten::___cxa_allocate_exception");
env::call_malloc(ctx, size as _) env::call_malloc(ctx, size as _)
} }
pub fn ___cxa_current_primary_exception(_ctx: &mut EmEnv) -> u32 { pub fn ___cxa_current_primary_exception(_ctx: &EmEnv) -> u32 {
debug!("emscripten::___cxa_current_primary_exception"); debug!("emscripten::___cxa_current_primary_exception");
unimplemented!("emscripten::___cxa_current_primary_exception") unimplemented!("emscripten::___cxa_current_primary_exception")
} }
pub fn ___cxa_decrement_exception_refcount(_ctx: &mut EmEnv, _a: u32) { pub fn ___cxa_decrement_exception_refcount(_ctx: &EmEnv, _a: u32) {
debug!("emscripten::___cxa_decrement_exception_refcount({})", _a); debug!("emscripten::___cxa_decrement_exception_refcount({})", _a);
unimplemented!("emscripten::___cxa_decrement_exception_refcount({})", _a) unimplemented!("emscripten::___cxa_decrement_exception_refcount({})", _a)
} }
pub fn ___cxa_increment_exception_refcount(_ctx: &mut EmEnv, _a: u32) { pub fn ___cxa_increment_exception_refcount(_ctx: &EmEnv, _a: u32) {
debug!("emscripten::___cxa_increment_exception_refcount({})", _a); debug!("emscripten::___cxa_increment_exception_refcount({})", _a);
unimplemented!("emscripten::___cxa_increment_exception_refcount({})", _a) unimplemented!("emscripten::___cxa_increment_exception_refcount({})", _a)
} }
pub fn ___cxa_rethrow_primary_exception(_ctx: &mut EmEnv, _a: u32) { pub fn ___cxa_rethrow_primary_exception(_ctx: &EmEnv, _a: u32) {
debug!("emscripten::___cxa_rethrow_primary_exception({})", _a); debug!("emscripten::___cxa_rethrow_primary_exception({})", _a);
unimplemented!("emscripten::___cxa_rethrow_primary_exception({})", _a) unimplemented!("emscripten::___cxa_rethrow_primary_exception({})", _a)
} }
/// emscripten: ___cxa_throw /// emscripten: ___cxa_throw
/// TODO: We don't have support for exceptions yet /// TODO: We don't have support for exceptions yet
pub fn ___cxa_throw(ctx: &mut EmEnv, _ptr: u32, _ty: u32, _destructor: u32) { pub fn ___cxa_throw(ctx: &EmEnv, _ptr: u32, _ty: u32, _destructor: u32) {
debug!("emscripten::___cxa_throw"); debug!("emscripten::___cxa_throw");
eprintln!("Throwing exceptions not yet implemented: aborting!"); eprintln!("Throwing exceptions not yet implemented: aborting!");
_abort(ctx); _abort(ctx);
} }
pub fn ___cxa_begin_catch(_ctx: &mut EmEnv, _exception_object_ptr: u32) -> i32 { pub fn ___cxa_begin_catch(_ctx: &EmEnv, _exception_object_ptr: u32) -> i32 {
debug!("emscripten::___cxa_begin_catch"); debug!("emscripten::___cxa_begin_catch");
-1 -1
} }
pub fn ___cxa_end_catch(_ctx: &mut EmEnv) { pub fn ___cxa_end_catch(_ctx: &EmEnv) {
debug!("emscripten::___cxa_end_catch"); debug!("emscripten::___cxa_end_catch");
} }
pub fn ___cxa_uncaught_exception(_ctx: &mut EmEnv) -> i32 { pub fn ___cxa_uncaught_exception(_ctx: &EmEnv) -> i32 {
debug!("emscripten::___cxa_uncaught_exception"); debug!("emscripten::___cxa_uncaught_exception");
-1 -1
} }
pub fn ___cxa_pure_virtual(_ctx: &mut EmEnv) { pub fn ___cxa_pure_virtual(_ctx: &EmEnv) {
debug!("emscripten::___cxa_pure_virtual"); debug!("emscripten::___cxa_pure_virtual");
// ABORT = true // ABORT = true
panic!("Pure virtual function called!"); panic!("Pure virtual function called!");

View File

@@ -4,7 +4,7 @@ use libc::execvp as libc_execvp;
use std::cell::Cell; use std::cell::Cell;
use std::ffi::CString; use std::ffi::CString;
pub fn execvp(ctx: &mut EmEnv, command_name_offset: u32, argv_offset: u32) -> i32 { pub fn execvp(ctx: &EmEnv, command_name_offset: u32, argv_offset: u32) -> i32 {
// a single reference to re-use // a single reference to re-use
let emscripten_memory = ctx.memory(0); let emscripten_memory = ctx.memory(0);
@@ -41,13 +41,13 @@ pub fn execvp(ctx: &mut EmEnv, command_name_offset: u32, argv_offset: u32) -> i3
} }
/// execl /// execl
pub fn execl(_ctx: &mut EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 { pub fn execl(_ctx: &EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 {
debug!("emscripten::execl"); debug!("emscripten::execl");
-1 -1
} }
/// execle /// execle
pub fn execle(_ctx: &mut EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 { pub fn execle(_ctx: &EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 {
debug!("emscripten::execle"); debug!("emscripten::execle");
-1 -1
} }

View File

@@ -1,7 +1,7 @@
use crate::EmEnv; use crate::EmEnv;
// __exit // __exit
pub fn exit(_ctx: &mut EmEnv, value: i32) { pub fn exit(_ctx: &EmEnv, value: i32) {
debug!("emscripten::exit {}", value); debug!("emscripten::exit {}", value);
::std::process::exit(value); ::std::process::exit(value);
} }

View File

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

View File

@@ -13,19 +13,19 @@ pub use self::windows::*;
use crate::EmEnv; use crate::EmEnv;
/// getprotobyname /// getprotobyname
pub fn getprotobyname(_ctx: &mut EmEnv, _name_ptr: i32) -> i32 { pub fn getprotobyname(_ctx: &EmEnv, _name_ptr: i32) -> i32 {
debug!("emscripten::getprotobyname"); debug!("emscripten::getprotobyname");
unimplemented!("emscripten::getprotobyname") unimplemented!("emscripten::getprotobyname")
} }
/// getprotobynumber /// getprotobynumber
pub fn getprotobynumber(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn getprotobynumber(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::getprotobynumber"); debug!("emscripten::getprotobynumber");
unimplemented!("emscripten::getprotobynumber") unimplemented!("emscripten::getprotobynumber")
} }
/// sigdelset /// sigdelset
pub fn sigdelset(ctx: &mut EmEnv, set: i32, signum: i32) -> i32 { pub fn sigdelset(ctx: &EmEnv, set: i32, signum: i32) -> i32 {
debug!("emscripten::sigdelset"); debug!("emscripten::sigdelset");
let memory = ctx.memory(0); let memory = ctx.memory(0);
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
@@ -37,7 +37,7 @@ pub fn sigdelset(ctx: &mut EmEnv, set: i32, signum: i32) -> i32 {
} }
/// sigfillset /// sigfillset
pub fn sigfillset(ctx: &mut EmEnv, set: i32) -> i32 { pub fn sigfillset(ctx: &EmEnv, set: i32) -> i32 {
debug!("emscripten::sigfillset"); debug!("emscripten::sigfillset");
let memory = ctx.memory(0); let memory = ctx.memory(0);
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
@@ -51,13 +51,13 @@ pub fn sigfillset(ctx: &mut EmEnv, set: i32) -> i32 {
} }
/// tzset /// tzset
pub fn tzset(_ctx: &mut EmEnv) { pub fn tzset(_ctx: &EmEnv) {
debug!("emscripten::tzset - stub"); debug!("emscripten::tzset - stub");
//unimplemented!("emscripten::tzset - stub") //unimplemented!("emscripten::tzset - stub")
} }
/// strptime /// strptime
pub fn strptime(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { pub fn strptime(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::strptime"); debug!("emscripten::strptime");
unimplemented!("emscripten::strptime") unimplemented!("emscripten::strptime")
} }

View File

@@ -6,12 +6,12 @@ use std::mem;
use crate::EmEnv; use crate::EmEnv;
/// putchar /// putchar
pub fn putchar(_ctx: &mut EmEnv, chr: i32) { pub fn putchar(_ctx: &EmEnv, chr: i32) {
unsafe { libc::putchar(chr) }; unsafe { libc::putchar(chr) };
} }
/// printf /// printf
pub fn printf(ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 { pub fn printf(ctx: &EmEnv, memory_offset: i32, extra: i32) -> i32 {
debug!("emscripten::printf {}, {}", memory_offset, extra); debug!("emscripten::printf {}, {}", memory_offset, extra);
unsafe { unsafe {
let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _; let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _;
@@ -20,7 +20,7 @@ pub fn printf(ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 {
} }
/// chroot /// chroot
pub fn chroot(ctx: &mut EmEnv, name_ptr: i32) -> i32 { pub fn chroot(ctx: &EmEnv, name_ptr: i32) -> i32 {
debug!("emscripten::chroot"); debug!("emscripten::chroot");
let name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8; let name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8;
unsafe { _chroot(name as *const _) } unsafe { _chroot(name as *const _) }
@@ -28,7 +28,7 @@ pub fn chroot(ctx: &mut EmEnv, name_ptr: i32) -> i32 {
/// getpwuid /// getpwuid
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn getpwuid(ctx: &mut EmEnv, uid: i32) -> i32 { pub fn getpwuid(ctx: &EmEnv, uid: i32) -> i32 {
debug!("emscripten::getpwuid {}", uid); debug!("emscripten::getpwuid {}", uid);
#[repr(C)] #[repr(C)]

View File

@@ -14,12 +14,12 @@ use crate::EmEnv;
//} //}
/// putchar /// putchar
pub fn putchar(_ctx: &mut EmEnv, chr: i32) { pub fn putchar(_ctx: &EmEnv, chr: i32) {
unsafe { libc::putchar(chr) }; unsafe { libc::putchar(chr) };
} }
/// printf /// printf
pub fn printf(_ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 { pub fn printf(_ctx: &EmEnv, memory_offset: i32, extra: i32) -> i32 {
debug!("emscripten::printf {}, {}", memory_offset, extra); debug!("emscripten::printf {}, {}", memory_offset, extra);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
{ {
@@ -34,13 +34,13 @@ pub fn printf(_ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 {
} }
/// chroot /// chroot
pub fn chroot(_ctx: &mut EmEnv, _name_ptr: i32) -> i32 { pub fn chroot(_ctx: &EmEnv, _name_ptr: i32) -> i32 {
debug!("emscripten::chroot"); debug!("emscripten::chroot");
unimplemented!("emscripten::chroot") unimplemented!("emscripten::chroot")
} }
/// getpwuid /// getpwuid
pub fn getpwuid(_ctx: &mut EmEnv, _uid: i32) -> i32 { pub fn getpwuid(_ctx: &EmEnv, _uid: i32) -> i32 {
debug!("emscripten::getpwuid"); debug!("emscripten::getpwuid");
unimplemented!("emscripten::getpwuid") unimplemented!("emscripten::getpwuid")
} }

View File

@@ -9,7 +9,7 @@ use std::fmt;
use wasmer::RuntimeError; use wasmer::RuntimeError;
/// setjmp /// setjmp
pub fn __setjmp(ctx: &mut EmEnv, _env_addr: u32) -> c_int { pub fn __setjmp(ctx: &EmEnv, _env_addr: u32) -> c_int {
debug!("emscripten::__setjmp (setjmp)"); debug!("emscripten::__setjmp (setjmp)");
abort_with_message(ctx, "missing function: _setjmp"); abort_with_message(ctx, "missing function: _setjmp");
unreachable!() unreachable!()
@@ -32,7 +32,7 @@ pub fn __setjmp(ctx: &mut EmEnv, _env_addr: u32) -> c_int {
/// longjmp /// longjmp
#[allow(unreachable_code)] #[allow(unreachable_code)]
pub fn __longjmp(ctx: &mut EmEnv, _env_addr: u32, _val: c_int) { pub fn __longjmp(ctx: &EmEnv, _env_addr: u32, _val: c_int) {
debug!("emscripten::__longjmp (longmp)"); debug!("emscripten::__longjmp (longmp)");
abort_with_message(ctx, "missing function: _longjmp"); abort_with_message(ctx, "missing function: _longjmp");
// unsafe { // unsafe {
@@ -59,7 +59,7 @@ impl Error for LongJumpRet {}
/// _longjmp /// _longjmp
// This function differs from the js implementation, it should return Result<(), &'static str> // This function differs from the js implementation, it should return Result<(), &'static str>
#[allow(unreachable_code)] #[allow(unreachable_code)]
pub fn _longjmp(ctx: &mut EmEnv, env_addr: i32, val: c_int) { pub fn _longjmp(ctx: &EmEnv, env_addr: i32, val: c_int) {
let val = if val == 0 { 1 } else { val }; let val = if val == 0 { 1 } else { val };
get_emscripten_data(ctx) get_emscripten_data(ctx)
.set_threw .set_threw

View File

@@ -423,7 +423,7 @@ pub fn set_up_emscripten(instance: &mut Instance) -> Result<(), RuntimeError> {
/// If you don't want to set it up yourself, consider using [`run_emscripten_instance`]. /// If you don't want to set it up yourself, consider using [`run_emscripten_instance`].
pub fn emscripten_call_main( pub fn emscripten_call_main(
instance: &mut Instance, instance: &mut Instance,
env: &mut EmEnv, env: &EmEnv,
path: &str, path: &str,
args: &[&str], args: &[&str],
) -> Result<(), RuntimeError> { ) -> Result<(), RuntimeError> {
@@ -500,7 +500,7 @@ pub fn run_emscripten_instance(
Ok(()) Ok(())
} }
fn store_module_arguments(ctx: &mut EmEnv, args: Vec<&str>) -> (u32, u32) { fn store_module_arguments(ctx: &EmEnv, args: Vec<&str>) -> (u32, u32) {
let argc = args.len() + 1; let argc = args.len() + 1;
let mut args_slice = vec![0; argc]; let mut args_slice = vec![0; argc];
@@ -649,7 +649,7 @@ impl EmscriptenGlobals {
pub fn generate_emscripten_env( pub fn generate_emscripten_env(
store: &Store, store: &Store,
globals: &mut EmscriptenGlobals, globals: &mut EmscriptenGlobals,
env: &mut EmEnv, env: &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_native_with_env( Function::new_native_with_env(
@@ -1148,7 +1148,7 @@ pub fn generate_emscripten_env(
import_object import_object
} }
pub fn nullfunc(ctx: &mut EmEnv, _x: u32) { pub fn nullfunc(ctx: &EmEnv, _x: u32) {
use crate::process::abort_with_message; use crate::process::abort_with_message;
debug!("emscripten::nullfunc_i {}", _x); debug!("emscripten::nullfunc_i {}", _x);
abort_with_message( abort_with_message(

View File

@@ -49,14 +49,14 @@ pub fn killpg(_a: i32, _b: i32) -> i32 {
} }
#[cfg(unix)] #[cfg(unix)]
pub fn pathconf(ctx: &mut EmEnv, path_ptr: i32, name: i32) -> i32 { pub fn pathconf(ctx: &EmEnv, path_ptr: i32, name: i32) -> i32 {
debug!("emscripten::pathconf"); debug!("emscripten::pathconf");
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8; let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
unsafe { libc::pathconf(path as *const _, name).try_into().unwrap() } unsafe { libc::pathconf(path as *const _, name).try_into().unwrap() }
} }
#[cfg(not(unix))] #[cfg(not(unix))]
pub fn pathconf(_ctx: &mut EmEnv, _path_ptr: i32, _name: i32) -> i32 { pub fn pathconf(_ctx: &EmEnv, _path_ptr: i32, _name: i32) -> i32 {
debug!("emscripten::pathconf"); debug!("emscripten::pathconf");
0 0
} }

View File

@@ -3,25 +3,25 @@ use crate::EmEnv;
// TODO: Need to implement. // TODO: Need to implement.
/// emscripten: dlopen(filename: *const c_char, flag: c_int) -> *mut c_void /// emscripten: dlopen(filename: *const c_char, flag: c_int) -> *mut c_void
pub fn _dlopen(_ctx: &mut EmEnv, _filename: u32, _flag: u32) -> i32 { pub fn _dlopen(_ctx: &EmEnv, _filename: u32, _flag: u32) -> i32 {
debug!("emscripten::_dlopen"); debug!("emscripten::_dlopen");
-1 -1
} }
/// emscripten: dlclose(handle: *mut c_void) -> c_int /// emscripten: dlclose(handle: *mut c_void) -> c_int
pub fn _dlclose(_ctx: &mut EmEnv, _filename: u32) -> i32 { pub fn _dlclose(_ctx: &EmEnv, _filename: u32) -> i32 {
debug!("emscripten::_dlclose"); debug!("emscripten::_dlclose");
-1 -1
} }
/// emscripten: dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void /// emscripten: dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void
pub fn _dlsym(_ctx: &mut EmEnv, _filepath: u32, _symbol: u32) -> i32 { pub fn _dlsym(_ctx: &EmEnv, _filepath: u32, _symbol: u32) -> i32 {
debug!("emscripten::_dlsym"); debug!("emscripten::_dlsym");
-1 -1
} }
/// emscripten: dlerror() -> *mut c_char /// emscripten: dlerror() -> *mut c_char
pub fn _dlerror(_ctx: &mut EmEnv) -> i32 { pub fn _dlerror(_ctx: &EmEnv) -> i32 {
debug!("emscripten::_dlerror"); debug!("emscripten::_dlerror");
-1 -1
} }

View File

@@ -2,21 +2,21 @@ use crate::EmEnv;
use libc::c_int; use libc::c_int;
// NOTE: Not implemented by Emscripten // NOTE: Not implemented by Emscripten
pub fn ___lock(_ctx: &mut EmEnv, _what: c_int) { pub fn ___lock(_ctx: &EmEnv, _what: c_int) {
debug!("emscripten::___lock {}", _what); debug!("emscripten::___lock {}", _what);
} }
// NOTE: Not implemented by Emscripten // NOTE: Not implemented by Emscripten
pub fn ___unlock(_ctx: &mut EmEnv, _what: c_int) { pub fn ___unlock(_ctx: &EmEnv, _what: c_int) {
debug!("emscripten::___unlock {}", _what); debug!("emscripten::___unlock {}", _what);
} }
// NOTE: Not implemented by Emscripten // NOTE: Not implemented by Emscripten
pub fn ___wait(_ctx: &mut EmEnv, _which: u32, _varargs: u32, _three: u32, _four: u32) { pub fn ___wait(_ctx: &EmEnv, _which: u32, _varargs: u32, _three: u32, _four: u32) {
debug!("emscripten::___wait"); debug!("emscripten::___wait");
} }
pub fn _flock(_ctx: &mut EmEnv, _fd: u32, _op: u32) -> u32 { pub fn _flock(_ctx: &EmEnv, _fd: u32, _op: u32) -> u32 {
debug!("emscripten::_flock"); debug!("emscripten::_flock");
0 0
} }

View File

@@ -62,7 +62,7 @@ pub fn _llvm_fma_f64(value: f64, a: f64, b: f64) -> f64 {
value.mul_add(a, b) value.mul_add(a, b)
} }
pub fn _emscripten_random(_ctx: &mut EmEnv) -> f64 { pub fn _emscripten_random(_ctx: &EmEnv) -> f64 {
debug!("emscripten::_emscripten_random"); debug!("emscripten::_emscripten_random");
-1.0 -1.0
} }

View File

@@ -6,7 +6,7 @@ use libc::{c_int, c_void, memcpy, size_t};
use wasmer::{Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE}; use wasmer::{Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE};
/// emscripten: _emscripten_memcpy_big /// emscripten: _emscripten_memcpy_big
pub fn _emscripten_memcpy_big(ctx: &mut EmEnv, dest: u32, src: u32, len: u32) -> u32 { pub fn _emscripten_memcpy_big(ctx: &EmEnv, dest: u32, src: u32, len: u32) -> u32 {
debug!( debug!(
"emscripten::_emscripten_memcpy_big {}, {}, {}", "emscripten::_emscripten_memcpy_big {}, {}, {}",
dest, src, len dest, src, len
@@ -20,7 +20,7 @@ pub fn _emscripten_memcpy_big(ctx: &mut EmEnv, dest: u32, src: u32, len: u32) ->
} }
/// emscripten: _emscripten_get_heap_size /// emscripten: _emscripten_get_heap_size
pub fn _emscripten_get_heap_size(ctx: &mut EmEnv) -> u32 { pub fn _emscripten_get_heap_size(ctx: &EmEnv) -> u32 {
trace!("emscripten::_emscripten_get_heap_size"); trace!("emscripten::_emscripten_get_heap_size");
let result = ctx.memory(0).size().bytes().0 as u32; let result = ctx.memory(0).size().bytes().0 as u32;
trace!("=> {}", result); trace!("=> {}", result);
@@ -38,7 +38,7 @@ fn align_up(mut val: usize, multiple: usize) -> usize {
/// emscripten: _emscripten_resize_heap /// emscripten: _emscripten_resize_heap
/// Note: this function only allows growing the size of heap /// Note: this function only allows growing the size of heap
pub fn _emscripten_resize_heap(ctx: &mut EmEnv, requested_size: u32) -> u32 { pub fn _emscripten_resize_heap(ctx: &EmEnv, requested_size: u32) -> u32 {
debug!("emscripten::_emscripten_resize_heap {}", requested_size); debug!("emscripten::_emscripten_resize_heap {}", requested_size);
let current_memory_pages = ctx.memory(0).size(); let current_memory_pages = ctx.memory(0).size();
let current_memory = current_memory_pages.bytes().0 as u32; let current_memory = current_memory_pages.bytes().0 as u32;
@@ -69,7 +69,7 @@ pub fn _emscripten_resize_heap(ctx: &mut EmEnv, requested_size: u32) -> u32 {
} }
/// emscripten: sbrk /// emscripten: sbrk
pub fn sbrk(ctx: &mut EmEnv, increment: i32) -> i32 { pub fn sbrk(ctx: &EmEnv, increment: i32) -> i32 {
debug!("emscripten::sbrk"); debug!("emscripten::sbrk");
// let old_dynamic_top = 0; // let old_dynamic_top = 0;
// let new_dynamic_top = 0; // let new_dynamic_top = 0;
@@ -97,7 +97,7 @@ pub fn sbrk(ctx: &mut EmEnv, increment: i32) -> i32 {
} }
/// emscripten: getTotalMemory /// emscripten: getTotalMemory
pub fn get_total_memory(_ctx: &mut EmEnv) -> u32 { pub fn get_total_memory(_ctx: &EmEnv) -> u32 {
debug!("emscripten::get_total_memory"); debug!("emscripten::get_total_memory");
// instance.memories[0].current_pages() // instance.memories[0].current_pages()
// TODO: Fix implementation // TODO: Fix implementation
@@ -105,7 +105,7 @@ pub fn get_total_memory(_ctx: &mut EmEnv) -> u32 {
} }
/// emscripten: enlargeMemory /// emscripten: enlargeMemory
pub fn enlarge_memory(_ctx: &mut EmEnv) -> u32 { pub fn enlarge_memory(_ctx: &EmEnv) -> u32 {
debug!("emscripten::enlarge_memory"); debug!("emscripten::enlarge_memory");
// instance.memories[0].grow(100); // instance.memories[0].grow(100);
// TODO: Fix implementation // TODO: Fix implementation
@@ -113,7 +113,7 @@ pub fn enlarge_memory(_ctx: &mut EmEnv) -> u32 {
} }
/// emscripten: abortOnCannotGrowMemory /// emscripten: abortOnCannotGrowMemory
pub fn abort_on_cannot_grow_memory(ctx: &mut EmEnv, _requested_size: u32) -> u32 { pub fn abort_on_cannot_grow_memory(ctx: &EmEnv, _requested_size: u32) -> u32 {
debug!( debug!(
"emscripten::abort_on_cannot_grow_memory {}", "emscripten::abort_on_cannot_grow_memory {}",
_requested_size _requested_size
@@ -123,32 +123,32 @@ pub fn abort_on_cannot_grow_memory(ctx: &mut EmEnv, _requested_size: u32) -> u32
} }
/// emscripten: abortOnCannotGrowMemory /// emscripten: abortOnCannotGrowMemory
pub fn abort_on_cannot_grow_memory_old(ctx: &mut EmEnv) -> u32 { pub fn abort_on_cannot_grow_memory_old(ctx: &EmEnv) -> u32 {
debug!("emscripten::abort_on_cannot_grow_memory"); debug!("emscripten::abort_on_cannot_grow_memory");
abort_with_message(ctx, "Cannot enlarge memory arrays!"); abort_with_message(ctx, "Cannot enlarge memory arrays!");
0 0
} }
/// emscripten: segfault /// emscripten: segfault
pub fn segfault(ctx: &mut EmEnv) { pub fn segfault(ctx: &EmEnv) {
debug!("emscripten::segfault"); debug!("emscripten::segfault");
abort_with_message(ctx, "segmentation fault"); abort_with_message(ctx, "segmentation fault");
} }
/// emscripten: alignfault /// emscripten: alignfault
pub fn alignfault(ctx: &mut EmEnv) { pub fn alignfault(ctx: &EmEnv) {
debug!("emscripten::alignfault"); debug!("emscripten::alignfault");
abort_with_message(ctx, "alignment fault"); abort_with_message(ctx, "alignment fault");
} }
/// emscripten: ftfault /// emscripten: ftfault
pub fn ftfault(ctx: &mut EmEnv) { pub fn ftfault(ctx: &EmEnv) {
debug!("emscripten::ftfault"); debug!("emscripten::ftfault");
abort_with_message(ctx, "Function table mask error"); abort_with_message(ctx, "Function table mask error");
} }
/// emscripten: ___map_file /// emscripten: ___map_file
pub fn ___map_file(_ctx: &mut EmEnv, _one: u32, _two: u32) -> c_int { pub fn ___map_file(_ctx: &EmEnv, _one: u32, _two: u32) -> c_int {
debug!("emscripten::___map_file"); debug!("emscripten::___map_file");
// NOTE: TODO: Em returns -1 here as well. May need to implement properly // NOTE: TODO: Em returns -1 here as well. May need to implement properly
-1 -1

View File

@@ -7,33 +7,33 @@ type PidT = c_int;
use crate::EmEnv; use crate::EmEnv;
pub fn abort_with_message(ctx: &mut EmEnv, message: &str) { pub fn abort_with_message(ctx: &EmEnv, message: &str) {
debug!("emscripten::abort_with_message"); debug!("emscripten::abort_with_message");
println!("{}", message); println!("{}", message);
_abort(ctx); _abort(ctx);
} }
/// The name of this call is `abort` but we want to avoid conflicts with libc::abort /// The name of this call is `abort` but we want to avoid conflicts with libc::abort
pub fn em_abort(ctx: &mut EmEnv, arg: u32) { pub fn em_abort(ctx: &EmEnv, arg: u32) {
debug!("emscripten::abort"); debug!("emscripten::abort");
eprintln!("Program aborted with value {}", arg); eprintln!("Program aborted with value {}", arg);
_abort(ctx); _abort(ctx);
} }
pub fn _abort(_ctx: &mut EmEnv) { pub fn _abort(_ctx: &EmEnv) {
debug!("emscripten::_abort"); debug!("emscripten::_abort");
unsafe { unsafe {
abort(); abort();
} }
} }
pub fn _prctl(ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _prctl(ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_prctl"); debug!("emscripten::_prctl");
abort_with_message(ctx, "missing function: prctl"); abort_with_message(ctx, "missing function: prctl");
-1 -1
} }
pub fn _fork(_ctx: &mut EmEnv) -> PidT { pub fn _fork(_ctx: &EmEnv) -> PidT {
debug!("emscripten::_fork"); debug!("emscripten::_fork");
// unsafe { // unsafe {
// fork() // fork()
@@ -41,132 +41,132 @@ pub fn _fork(_ctx: &mut EmEnv) -> PidT {
-1 -1
} }
pub fn _endgrent(_ctx: &mut EmEnv) { pub fn _endgrent(_ctx: &EmEnv) {
debug!("emscripten::_endgrent"); debug!("emscripten::_endgrent");
} }
pub fn _execve(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { pub fn _execve(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_execve"); debug!("emscripten::_execve");
-1 -1
} }
#[allow(unreachable_code)] #[allow(unreachable_code)]
pub fn _exit(_ctx: &mut EmEnv, status: c_int) { pub fn _exit(_ctx: &EmEnv, status: c_int) {
// -> ! // -> !
debug!("emscripten::_exit {}", status); debug!("emscripten::_exit {}", status);
unsafe { exit(status) } unsafe { exit(status) }
} }
pub fn _kill(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn _kill(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_kill"); debug!("emscripten::_kill");
-1 -1
} }
pub fn _sched_yield(_ctx: &mut EmEnv) -> i32 { pub fn _sched_yield(_ctx: &EmEnv) -> i32 {
debug!("emscripten::_sched_yield"); debug!("emscripten::_sched_yield");
-1 -1
} }
pub fn _llvm_stacksave(_ctx: &mut EmEnv) -> i32 { pub fn _llvm_stacksave(_ctx: &EmEnv) -> i32 {
debug!("emscripten::_llvm_stacksave"); debug!("emscripten::_llvm_stacksave");
-1 -1
} }
pub fn _llvm_stackrestore(_ctx: &mut EmEnv, _one: i32) { pub fn _llvm_stackrestore(_ctx: &EmEnv, _one: i32) {
debug!("emscripten::_llvm_stackrestore"); debug!("emscripten::_llvm_stackrestore");
} }
pub fn _raise(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _raise(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_raise"); debug!("emscripten::_raise");
-1 -1
} }
pub fn _sem_init(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { pub fn _sem_init(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_sem_init: {}, {}, {}", _one, _two, _three); debug!("emscripten::_sem_init: {}, {}, {}", _one, _two, _three);
0 0
} }
pub fn _sem_destroy(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _sem_destroy(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_sem_destroy"); debug!("emscripten::_sem_destroy");
0 0
} }
pub fn _sem_post(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _sem_post(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_sem_post"); debug!("emscripten::_sem_post");
-1 -1
} }
pub fn _sem_wait(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _sem_wait(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_sem_post"); debug!("emscripten::_sem_post");
-1 -1
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _getgrent(_ctx: &mut EmEnv) -> c_int { pub fn _getgrent(_ctx: &EmEnv) -> c_int {
debug!("emscripten::_getgrent"); debug!("emscripten::_getgrent");
-1 -1
} }
pub fn _setgrent(_ctx: &mut EmEnv) { pub fn _setgrent(_ctx: &EmEnv) {
debug!("emscripten::_setgrent"); debug!("emscripten::_setgrent");
} }
pub fn _setgroups(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn _setgroups(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_setgroups"); debug!("emscripten::_setgroups");
-1 -1
} }
pub fn _setitimer(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { pub fn _setitimer(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_setitimer"); debug!("emscripten::_setitimer");
-1 -1
} }
pub fn _usleep(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _usleep(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_usleep"); debug!("emscripten::_usleep");
-1 -1
} }
pub fn _nanosleep(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn _nanosleep(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_nanosleep"); debug!("emscripten::_nanosleep");
-1 -1
} }
pub fn _utime(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn _utime(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_utime"); debug!("emscripten::_utime");
-1 -1
} }
pub fn _utimes(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn _utimes(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_utimes"); debug!("emscripten::_utimes");
-1 -1
} }
pub fn _wait(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _wait(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_wait"); debug!("emscripten::_wait");
-1 -1
} }
pub fn _wait3(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { pub fn _wait3(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_wait3"); debug!("emscripten::_wait3");
-1 -1
} }
pub fn _wait4(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 { pub fn _wait4(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
debug!("emscripten::_wait4"); debug!("emscripten::_wait4");
-1 -1
} }
pub fn _waitid(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 { pub fn _waitid(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 {
debug!("emscripten::_waitid"); debug!("emscripten::_waitid");
-1 -1
} }
pub fn _waitpid(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { pub fn _waitpid(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_waitpid"); debug!("emscripten::_waitpid");
-1 -1
} }
pub fn abort_stack_overflow(ctx: &mut EmEnv, _what: c_int) { pub fn abort_stack_overflow(ctx: &EmEnv, _what: c_int) {
debug!("emscripten::abort_stack_overflow"); debug!("emscripten::abort_stack_overflow");
// TODO: Message incomplete. Need to finish em runtime data first // TODO: Message incomplete. Need to finish em runtime data first
abort_with_message( abort_with_message(
@@ -175,24 +175,24 @@ pub fn abort_stack_overflow(ctx: &mut EmEnv, _what: c_int) {
); );
} }
pub fn _llvm_trap(ctx: &mut EmEnv) { pub fn _llvm_trap(ctx: &EmEnv) {
debug!("emscripten::_llvm_trap"); debug!("emscripten::_llvm_trap");
abort_with_message(ctx, "abort!"); abort_with_message(ctx, "abort!");
} }
pub fn _llvm_eh_typeid_for(_ctx: &mut EmEnv, _type_info_addr: u32) -> i32 { pub fn _llvm_eh_typeid_for(_ctx: &EmEnv, _type_info_addr: u32) -> i32 {
debug!("emscripten::_llvm_eh_typeid_for"); debug!("emscripten::_llvm_eh_typeid_for");
-1 -1
} }
pub fn _system(_ctx: &mut EmEnv, _one: i32) -> c_int { pub fn _system(_ctx: &EmEnv, _one: i32) -> c_int {
debug!("emscripten::_system"); debug!("emscripten::_system");
// TODO: May need to change this Em impl to a working version // TODO: May need to change this Em impl to a working version
eprintln!("Can't call external programs"); eprintln!("Can't call external programs");
EAGAIN EAGAIN
} }
pub fn _popen(_ctx: &mut EmEnv, _one: i32, _two: i32) -> c_int { pub fn _popen(_ctx: &EmEnv, _one: i32, _two: i32) -> c_int {
debug!("emscripten::_popen"); debug!("emscripten::_popen");
// TODO: May need to change this Em impl to a working version // TODO: May need to change this Em impl to a working version
eprintln!("Missing function: popen"); eprintln!("Missing function: popen");

View File

@@ -1,16 +1,11 @@
use crate::EmEnv; use crate::EmEnv;
pub fn _pthread_attr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_attr_destroy(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_attr_destroy"); trace!("emscripten::_pthread_attr_destroy");
0 0
} }
pub fn _pthread_attr_getstack( pub fn _pthread_attr_getstack(_ctx: &EmEnv, _stackaddr: i32, _stacksize: i32, _other: i32) -> i32 {
_ctx: &mut EmEnv,
_stackaddr: i32,
_stacksize: i32,
_other: i32,
) -> i32 {
trace!( trace!(
"emscripten::_pthread_attr_getstack({}, {}, {})", "emscripten::_pthread_attr_getstack({}, {}, {})",
_stackaddr, _stackaddr,
@@ -23,175 +18,175 @@ pub fn _pthread_attr_getstack(
0 0
} }
pub fn _pthread_attr_init(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_attr_init(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_attr_init({})", _a); trace!("emscripten::_pthread_attr_init({})", _a);
0 0
} }
pub fn _pthread_attr_setstacksize(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_attr_setstacksize(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_attr_setstacksize"); trace!("emscripten::_pthread_attr_setstacksize");
0 0
} }
pub fn _pthread_cleanup_pop(_ctx: &mut EmEnv, _a: i32) { pub fn _pthread_cleanup_pop(_ctx: &EmEnv, _a: i32) {
trace!("emscripten::_pthread_cleanup_pop"); trace!("emscripten::_pthread_cleanup_pop");
} }
pub fn _pthread_cleanup_push(_ctx: &mut EmEnv, _a: i32, _b: i32) { pub fn _pthread_cleanup_push(_ctx: &EmEnv, _a: i32, _b: i32) {
trace!("emscripten::_pthread_cleanup_push"); trace!("emscripten::_pthread_cleanup_push");
} }
pub fn _pthread_cond_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_cond_destroy(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_cond_destroy"); trace!("emscripten::_pthread_cond_destroy");
0 0
} }
pub fn _pthread_cond_init(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_cond_init(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_cond_init"); trace!("emscripten::_pthread_cond_init");
0 0
} }
pub fn _pthread_cond_signal(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_cond_signal(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_cond_signal"); trace!("emscripten::_pthread_cond_signal");
0 0
} }
pub fn _pthread_cond_timedwait(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32) -> i32 { pub fn _pthread_cond_timedwait(_ctx: &EmEnv, _a: i32, _b: i32, _c: i32) -> i32 {
trace!("emscripten::_pthread_cond_timedwait"); trace!("emscripten::_pthread_cond_timedwait");
0 0
} }
pub fn _pthread_cond_wait(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_cond_wait(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_cond_wait"); trace!("emscripten::_pthread_cond_wait");
0 0
} }
pub fn _pthread_condattr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_condattr_destroy(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_condattr_destroy"); trace!("emscripten::_pthread_condattr_destroy");
0 0
} }
pub fn _pthread_condattr_init(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_condattr_init(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_condattr_init"); trace!("emscripten::_pthread_condattr_init");
0 0
} }
pub fn _pthread_condattr_setclock(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_condattr_setclock(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_condattr_setclock"); trace!("emscripten::_pthread_condattr_setclock");
0 0
} }
pub fn _pthread_create(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 { pub fn _pthread_create(_ctx: &EmEnv, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 {
trace!("emscripten::_pthread_create"); trace!("emscripten::_pthread_create");
// 11 seems to mean "no" // 11 seems to mean "no"
11 11
} }
pub fn _pthread_detach(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_detach(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_detach"); trace!("emscripten::_pthread_detach");
0 0
} }
pub fn _pthread_equal(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_equal(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_equal"); trace!("emscripten::_pthread_equal");
0 0
} }
pub fn _pthread_exit(_ctx: &mut EmEnv, _a: i32) { pub fn _pthread_exit(_ctx: &EmEnv, _a: i32) {
trace!("emscripten::_pthread_exit"); trace!("emscripten::_pthread_exit");
} }
pub fn _pthread_getattr_np(_ctx: &mut EmEnv, _thread: i32, _attr: i32) -> i32 { pub fn _pthread_getattr_np(_ctx: &EmEnv, _thread: i32, _attr: i32) -> i32 {
trace!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr); trace!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr);
0 0
} }
pub fn _pthread_getspecific(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_getspecific(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_getspecific"); trace!("emscripten::_pthread_getspecific");
0 0
} }
pub fn _pthread_join(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_join(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_join"); trace!("emscripten::_pthread_join");
0 0
} }
pub fn _pthread_self(_ctx: &mut EmEnv) -> i32 { pub fn _pthread_self(_ctx: &EmEnv) -> i32 {
trace!("emscripten::_pthread_self"); trace!("emscripten::_pthread_self");
0 0
} }
pub fn _pthread_key_create(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_key_create(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_key_create"); trace!("emscripten::_pthread_key_create");
0 0
} }
pub fn _pthread_mutex_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_mutex_destroy(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_mutex_destroy"); trace!("emscripten::_pthread_mutex_destroy");
0 0
} }
pub fn _pthread_mutex_init(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_mutex_init(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_mutex_init"); trace!("emscripten::_pthread_mutex_init");
0 0
} }
pub fn _pthread_mutexattr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_mutexattr_destroy(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_mutexattr_destroy"); trace!("emscripten::_pthread_mutexattr_destroy");
0 0
} }
pub fn _pthread_mutexattr_init(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_mutexattr_init(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_mutexattr_init"); trace!("emscripten::_pthread_mutexattr_init");
0 0
} }
pub fn _pthread_mutexattr_settype(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_mutexattr_settype(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_mutexattr_settype"); trace!("emscripten::_pthread_mutexattr_settype");
0 0
} }
pub fn _pthread_once(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_once(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_once"); trace!("emscripten::_pthread_once");
0 0
} }
pub fn _pthread_rwlock_destroy(_ctx: &mut EmEnv, _rwlock: i32) -> i32 { pub fn _pthread_rwlock_destroy(_ctx: &EmEnv, _rwlock: i32) -> i32 {
trace!("emscripten::_pthread_rwlock_destroy({})", _rwlock); trace!("emscripten::_pthread_rwlock_destroy({})", _rwlock);
0 0
} }
pub fn _pthread_rwlock_init(_ctx: &mut EmEnv, _rwlock: i32, _attr: i32) -> i32 { pub fn _pthread_rwlock_init(_ctx: &EmEnv, _rwlock: i32, _attr: i32) -> i32 {
trace!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr); trace!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr);
0 0
} }
pub fn _pthread_rwlock_rdlock(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_rwlock_rdlock(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_rwlock_rdlock"); trace!("emscripten::_pthread_rwlock_rdlock");
0 0
} }
pub fn _pthread_rwlock_unlock(_ctx: &mut EmEnv, _a: i32) -> i32 { pub fn _pthread_rwlock_unlock(_ctx: &EmEnv, _a: i32) -> i32 {
trace!("emscripten::_pthread_rwlock_unlock"); trace!("emscripten::_pthread_rwlock_unlock");
0 0
} }
pub fn _pthread_rwlock_wrlock(_ctx: &mut EmEnv, _rwlock: i32) -> i32 { pub fn _pthread_rwlock_wrlock(_ctx: &EmEnv, _rwlock: i32) -> i32 {
trace!("emscripten::_pthread_rwlock_wrlock({})", _rwlock); trace!("emscripten::_pthread_rwlock_wrlock({})", _rwlock);
0 0
} }
pub fn _pthread_setcancelstate(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_setcancelstate(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_setcancelstate"); trace!("emscripten::_pthread_setcancelstate");
0 0
} }
pub fn _pthread_setspecific(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { pub fn _pthread_setspecific(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 {
trace!("emscripten::_pthread_setspecific"); trace!("emscripten::_pthread_setspecific");
0 0
} }
pub fn _pthread_sigmask(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32) -> i32 { pub fn _pthread_sigmask(_ctx: &EmEnv, _a: i32, _b: i32, _c: i32) -> i32 {
trace!("emscripten::_pthread_sigmask"); trace!("emscripten::_pthread_sigmask");
0 0
} }

View File

@@ -2,7 +2,7 @@
use crate::EmEnv; use crate::EmEnv;
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _sigemptyset(ctx: &mut EmEnv, set: u32) -> i32 { pub fn _sigemptyset(ctx: &EmEnv, set: u32) -> i32 {
debug!("emscripten::_sigemptyset"); debug!("emscripten::_sigemptyset");
let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32; let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32;
unsafe { unsafe {
@@ -11,18 +11,18 @@ pub fn _sigemptyset(ctx: &mut EmEnv, set: u32) -> i32 {
0 0
} }
pub fn _sigaction(_ctx: &mut EmEnv, _signum: u32, _act: u32, _oldact: u32) -> i32 { pub fn _sigaction(_ctx: &EmEnv, _signum: u32, _act: u32, _oldact: u32) -> i32 {
debug!("emscripten::_sigaction {}, {}, {}", _signum, _act, _oldact); debug!("emscripten::_sigaction {}, {}, {}", _signum, _act, _oldact);
0 0
} }
pub fn _siginterrupt(_ctx: &mut EmEnv, _a: u32, _b: u32) -> i32 { pub fn _siginterrupt(_ctx: &EmEnv, _a: u32, _b: u32) -> i32 {
debug!("emscripten::_siginterrupt {}, {}", _a, _b); debug!("emscripten::_siginterrupt {}, {}", _a, _b);
0 0
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _sigaddset(ctx: &mut EmEnv, set: u32, signum: u32) -> i32 { pub fn _sigaddset(ctx: &EmEnv, set: u32, signum: u32) -> i32 {
debug!("emscripten::_sigaddset {}, {}", set, signum); debug!("emscripten::_sigaddset {}, {}", set, signum);
let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32; let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32;
unsafe { unsafe {
@@ -31,17 +31,17 @@ pub fn _sigaddset(ctx: &mut EmEnv, set: u32, signum: u32) -> i32 {
0 0
} }
pub fn _sigsuspend(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _sigsuspend(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_sigsuspend"); debug!("emscripten::_sigsuspend");
-1 -1
} }
pub fn _sigprocmask(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { pub fn _sigprocmask(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_sigprocmask"); debug!("emscripten::_sigprocmask");
0 0
} }
pub fn _signal(_ctx: &mut EmEnv, _sig: u32, _two: i32) -> i32 { pub fn _signal(_ctx: &EmEnv, _sig: u32, _two: i32) -> i32 {
debug!("emscripten::_signal ({})", _sig); debug!("emscripten::_signal ({})", _sig);
0 0
} }

View File

@@ -52,7 +52,7 @@ use std::io::Error;
use std::slice; use std::slice;
/// exit /// exit
pub fn ___syscall1(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) { pub fn ___syscall1(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) {
debug!("emscripten::___syscall1 (exit) {}", _which); debug!("emscripten::___syscall1 (exit) {}", _which);
let status: i32 = varargs.get(ctx); let status: i32 = varargs.get(ctx);
unsafe { unsafe {
@@ -61,7 +61,7 @@ pub fn ___syscall1(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) {
} }
/// read /// read
pub fn ___syscall3(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall3(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
// -> ssize_t // -> ssize_t
debug!("emscripten::___syscall3 (read) {}", _which); debug!("emscripten::___syscall3 (read) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
@@ -75,7 +75,7 @@ pub fn ___syscall3(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
} }
/// write /// write
pub fn ___syscall4(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall4(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall4 (write) {}", _which); debug!("emscripten::___syscall4 (write) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
let buf: i32 = varargs.get(ctx); let buf: i32 = varargs.get(ctx);
@@ -86,7 +86,7 @@ pub fn ___syscall4(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in
} }
/// close /// close
pub fn ___syscall6(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall6(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall6 (close) {}", _which); debug!("emscripten::___syscall6 (close) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
debug!("fd: {}", fd); debug!("fd: {}", fd);
@@ -94,7 +94,7 @@ pub fn ___syscall6(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in
} }
// chdir // chdir
pub fn ___syscall12(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall12(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall12 (chdir) {}", _which); debug!("emscripten::___syscall12 (chdir) {}", _which);
let path_ptr = varargs.get_str(ctx); let path_ptr = varargs.get_str(ctx);
let real_path_owned = get_cstr_path(ctx, path_ptr as *const _); let real_path_owned = get_cstr_path(ctx, path_ptr as *const _);
@@ -112,59 +112,59 @@ pub fn ___syscall12(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
ret ret
} }
pub fn ___syscall10(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall10(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall10"); debug!("emscripten::___syscall10");
-1 -1
} }
pub fn ___syscall14(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall14(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall14"); debug!("emscripten::___syscall14");
-1 -1
} }
pub fn ___syscall15(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall15(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall15"); debug!("emscripten::___syscall15");
-1 -1
} }
// getpid // getpid
pub fn ___syscall20(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall20(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall20 (getpid)"); debug!("emscripten::___syscall20 (getpid)");
unsafe { getpid() } unsafe { getpid() }
} }
pub fn ___syscall21(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall21(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall21"); debug!("emscripten::___syscall21");
-1 -1
} }
pub fn ___syscall25(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall25(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall25"); debug!("emscripten::___syscall25");
-1 -1
} }
pub fn ___syscall29(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall29(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall29"); debug!("emscripten::___syscall29");
-1 -1
} }
pub fn ___syscall32(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall32(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall32"); debug!("emscripten::___syscall32");
-1 -1
} }
pub fn ___syscall33(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall33(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall33"); debug!("emscripten::___syscall33");
-1 -1
} }
pub fn ___syscall36(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall36(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall36"); debug!("emscripten::___syscall36");
-1 -1
} }
// rename // rename
pub fn ___syscall38(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { pub fn ___syscall38(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall38 (rename)"); debug!("emscripten::___syscall38 (rename)");
let old_path = varargs.get_str(ctx); let old_path = varargs.get_str(ctx);
let new_path = varargs.get_str(ctx); let new_path = varargs.get_str(ctx);
@@ -191,7 +191,7 @@ pub fn ___syscall38(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32
} }
// rmdir // rmdir
pub fn ___syscall40(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall40(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall40 (rmdir)"); debug!("emscripten::___syscall40 (rmdir)");
let pathname_addr = varargs.get_str(ctx); let pathname_addr = varargs.get_str(ctx);
let real_path_owned = get_cstr_path(ctx, pathname_addr as *const _); let real_path_owned = get_cstr_path(ctx, pathname_addr as *const _);
@@ -204,7 +204,7 @@ pub fn ___syscall40(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
} }
// pipe // pipe
pub fn ___syscall42(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall42(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall42 (pipe)"); debug!("emscripten::___syscall42 (pipe)");
// offset to a file descriptor, which contains a read end and write end, 2 integers // offset to a file descriptor, which contains a read end and write end, 2 integers
let fd_offset: u32 = varargs.get(ctx); let fd_offset: u32 = varargs.get(ctx);
@@ -232,28 +232,28 @@ pub fn ___syscall42(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
result result
} }
pub fn ___syscall51(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall51(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall51"); debug!("emscripten::___syscall51");
-1 -1
} }
pub fn ___syscall52(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall52(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall52"); debug!("emscripten::___syscall52");
-1 -1
} }
pub fn ___syscall53(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall53(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall53"); debug!("emscripten::___syscall53");
-1 -1
} }
pub fn ___syscall60(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall60(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall60"); debug!("emscripten::___syscall60");
-1 -1
} }
// dup2 // dup2
pub fn ___syscall63(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall63(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall63 (dup2) {}", _which); debug!("emscripten::___syscall63 (dup2) {}", _which);
let src: i32 = varargs.get(ctx); let src: i32 = varargs.get(ctx);
@@ -263,93 +263,93 @@ pub fn ___syscall63(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
} }
// getppid // getppid
pub fn ___syscall64(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall64(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall64 (getppid)"); debug!("emscripten::___syscall64 (getppid)");
unsafe { getpid() } unsafe { getpid() }
} }
pub fn ___syscall66(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall66(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall66"); debug!("emscripten::___syscall66");
-1 -1
} }
pub fn ___syscall75(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall75(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall75"); debug!("emscripten::___syscall75");
-1 -1
} }
pub fn ___syscall91(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall91(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall91 - stub"); debug!("emscripten::___syscall91 - stub");
0 0
} }
pub fn ___syscall96(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall96(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall96"); debug!("emscripten::___syscall96");
-1 -1
} }
pub fn ___syscall97(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall97(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall97"); debug!("emscripten::___syscall97");
-1 -1
} }
pub fn ___syscall110(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall110(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall110"); debug!("emscripten::___syscall110");
-1 -1
} }
pub fn ___syscall121(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall121(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall121"); debug!("emscripten::___syscall121");
-1 -1
} }
pub fn ___syscall125(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall125(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall125"); debug!("emscripten::___syscall125");
-1 -1
} }
pub fn ___syscall133(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall133(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall133"); debug!("emscripten::___syscall133");
-1 -1
} }
pub fn ___syscall144(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall144(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall144"); debug!("emscripten::___syscall144");
-1 -1
} }
pub fn ___syscall147(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall147(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall147"); debug!("emscripten::___syscall147");
-1 -1
} }
pub fn ___syscall150(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall150(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall150"); debug!("emscripten::___syscall150");
-1 -1
} }
pub fn ___syscall151(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall151(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall151"); debug!("emscripten::___syscall151");
-1 -1
} }
pub fn ___syscall152(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall152(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall152"); debug!("emscripten::___syscall152");
-1 -1
} }
pub fn ___syscall153(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall153(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall153"); debug!("emscripten::___syscall153");
-1 -1
} }
pub fn ___syscall163(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall163(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall163"); debug!("emscripten::___syscall163");
-1 -1
} }
// getcwd // getcwd
pub fn ___syscall183(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { pub fn ___syscall183(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall183"); debug!("emscripten::___syscall183");
let buf_offset: WasmPtr<libc::c_char, Array> = varargs.get(ctx); let buf_offset: WasmPtr<libc::c_char, Array> = varargs.get(ctx);
let _size: c_int = varargs.get(ctx); let _size: c_int = varargs.get(ctx);
@@ -366,7 +366,7 @@ pub fn ___syscall183(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i3
} }
// mmap2 // mmap2
pub fn ___syscall192(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall192(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall192 (mmap2) {}", _which); debug!("emscripten::___syscall192 (mmap2) {}", _which);
let _addr: i32 = varargs.get(ctx); let _addr: i32 = varargs.get(ctx);
let len: u32 = varargs.get(ctx); let len: u32 = varargs.get(ctx);
@@ -401,7 +401,7 @@ pub fn ___syscall192(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// lseek /// lseek
pub fn ___syscall140(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall140(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
// -> c_int // -> c_int
debug!("emscripten::___syscall140 (lseek) {}", _which); debug!("emscripten::___syscall140 (lseek) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
@@ -429,7 +429,7 @@ pub fn ___syscall140(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32
/// readv /// readv
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall145(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { pub fn ___syscall145(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
// -> ssize_t // -> ssize_t
debug!("emscripten::___syscall145 (readv) {}", _which); debug!("emscripten::___syscall145 (readv) {}", _which);
@@ -466,7 +466,7 @@ pub fn ___syscall145(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i3
// writev // writev
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall146(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall146(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
// -> ssize_t // -> ssize_t
debug!("emscripten::___syscall146 (writev) {}", _which); debug!("emscripten::___syscall146 (writev) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
@@ -507,7 +507,7 @@ pub fn ___syscall146(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32
ret as _ ret as _
} }
pub fn ___syscall191(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall191(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
let _resource: i32 = varargs.get(ctx); let _resource: i32 = varargs.get(ctx);
debug!( debug!(
"emscripten::___syscall191 - mostly stub, resource: {}", "emscripten::___syscall191 - mostly stub, resource: {}",
@@ -524,13 +524,13 @@ pub fn ___syscall191(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32
0 0
} }
pub fn ___syscall193(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall193(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall193"); debug!("emscripten::___syscall193");
-1 -1
} }
// stat64 // stat64
pub fn ___syscall195(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall195(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall195 (stat64) {}", _which); debug!("emscripten::___syscall195 (stat64) {}", _which);
let pathname_addr = varargs.get_str(ctx); let pathname_addr = varargs.get_str(ctx);
let buf: u32 = varargs.get(ctx); let buf: u32 = varargs.get(ctx);
@@ -561,7 +561,7 @@ pub fn ___syscall195(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
// fstat64 // fstat64
pub fn ___syscall197(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall197(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall197 (fstat64) {}", _which); debug!("emscripten::___syscall197 (fstat64) {}", _which);
let fd: c_int = varargs.get(ctx); let fd: c_int = varargs.get(ctx);
@@ -580,129 +580,129 @@ pub fn ___syscall197(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
0 0
} }
pub fn ___syscall209(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall209(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall209"); debug!("emscripten::___syscall209");
-1 -1
} }
pub fn ___syscall211(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall211(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall211"); debug!("emscripten::___syscall211");
-1 -1
} }
pub fn ___syscall218(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall218(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall218"); debug!("emscripten::___syscall218");
-1 -1
} }
pub fn ___syscall268(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall268(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall268"); debug!("emscripten::___syscall268");
-1 -1
} }
pub fn ___syscall269(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall269(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall269"); debug!("emscripten::___syscall269");
-1 -1
} }
pub fn ___syscall272(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall272(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall272"); debug!("emscripten::___syscall272");
-1 -1
} }
pub fn ___syscall295(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall295(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall295"); debug!("emscripten::___syscall295");
-1 -1
} }
pub fn ___syscall296(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall296(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall296"); debug!("emscripten::___syscall296");
-1 -1
} }
pub fn ___syscall297(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall297(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall297"); debug!("emscripten::___syscall297");
-1 -1
} }
pub fn ___syscall298(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall298(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall298"); debug!("emscripten::___syscall298");
-1 -1
} }
pub fn ___syscall300(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall300(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall300"); debug!("emscripten::___syscall300");
-1 -1
} }
pub fn ___syscall301(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall301(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall301"); debug!("emscripten::___syscall301");
-1 -1
} }
pub fn ___syscall302(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall302(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall302"); debug!("emscripten::___syscall302");
-1 -1
} }
pub fn ___syscall303(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall303(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall303"); debug!("emscripten::___syscall303");
-1 -1
} }
pub fn ___syscall304(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall304(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall304"); debug!("emscripten::___syscall304");
-1 -1
} }
pub fn ___syscall305(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall305(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall305"); debug!("emscripten::___syscall305");
-1 -1
} }
pub fn ___syscall306(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall306(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall306"); debug!("emscripten::___syscall306");
-1 -1
} }
pub fn ___syscall307(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall307(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall307"); debug!("emscripten::___syscall307");
-1 -1
} }
pub fn ___syscall308(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall308(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall308"); debug!("emscripten::___syscall308");
-1 -1
} }
// utimensat // utimensat
pub fn ___syscall320(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall320(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall320 (utimensat), {}", _which); debug!("emscripten::___syscall320 (utimensat), {}", _which);
0 0
} }
pub fn ___syscall331(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall331(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall331"); debug!("emscripten::___syscall331");
-1 -1
} }
pub fn ___syscall333(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall333(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall333"); debug!("emscripten::___syscall333");
-1 -1
} }
pub fn ___syscall334(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall334(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall334"); debug!("emscripten::___syscall334");
-1 -1
} }
pub fn ___syscall337(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall337(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall337"); debug!("emscripten::___syscall337");
-1 -1
} }
// prlimit64 // prlimit64
pub fn ___syscall340(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall340(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall340 (prlimit64), {}", _which); debug!("emscripten::___syscall340 (prlimit64), {}", _which);
// NOTE: Doesn't really matter. Wasm modules cannot exceed WASM_PAGE_SIZE anyway. // NOTE: Doesn't really matter. Wasm modules cannot exceed WASM_PAGE_SIZE anyway.
let _pid: i32 = varargs.get(ctx); let _pid: i32 = varargs.get(ctx);
@@ -728,7 +728,7 @@ pub fn ___syscall340(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
0 0
} }
pub fn ___syscall345(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall345(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall345"); debug!("emscripten::___syscall345");
-1 -1
} }

View File

@@ -156,7 +156,7 @@ use libc::SO_NOSIGPIPE;
const SO_NOSIGPIPE: c_int = 0; const SO_NOSIGPIPE: c_int = 0;
/// open /// open
pub fn ___syscall5(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall5(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall5 (open) {}", _which); debug!("emscripten::___syscall5 (open) {}", _which);
let pathname_addr = varargs.get_str(ctx); let pathname_addr = varargs.get_str(ctx);
let flags: i32 = varargs.get(ctx); let flags: i32 = varargs.get(ctx);
@@ -180,7 +180,7 @@ pub fn ___syscall5(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in
} }
/// link /// link
pub fn ___syscall9(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall9(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall9 (link) {}", _which); debug!("emscripten::___syscall9 (link) {}", _which);
let oldname_ptr = varargs.get_str(ctx); let oldname_ptr = varargs.get_str(ctx);
@@ -196,7 +196,7 @@ pub fn ___syscall9(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in
} }
/// getrusage /// getrusage
pub fn ___syscall77(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall77(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall77 (getrusage) {}", _which); debug!("emscripten::___syscall77 (getrusage) {}", _which);
let resource: c_int = varargs.get(ctx); let resource: c_int = varargs.get(ctx);
@@ -208,7 +208,7 @@ pub fn ___syscall77(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
} }
/// symlink /// symlink
pub fn ___syscall83(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall83(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall83 (symlink) {}", _which); debug!("emscripten::___syscall83 (symlink) {}", _which);
let path1 = varargs.get_str(ctx); let path1 = varargs.get_str(ctx);
@@ -236,7 +236,7 @@ pub fn ___syscall83(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
} }
/// readlink /// readlink
pub fn ___syscall85(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { pub fn ___syscall85(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall85 (readlink)"); debug!("emscripten::___syscall85 (readlink)");
let pathname_addr = varargs.get_str(ctx); let pathname_addr = varargs.get_str(ctx);
let buf = varargs.get_str(ctx); let buf = varargs.get_str(ctx);
@@ -265,7 +265,7 @@ pub fn ___syscall85(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32
} }
/// ftruncate64 /// ftruncate64
pub fn ___syscall194(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall194(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall194 (ftruncate64) {}", _which); debug!("emscripten::___syscall194 (ftruncate64) {}", _which);
let _fd: c_int = varargs.get(ctx); let _fd: c_int = varargs.get(ctx);
let _length: i64 = varargs.get(ctx); let _length: i64 = varargs.get(ctx);
@@ -282,7 +282,7 @@ pub fn ___syscall194(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// lchown /// lchown
pub fn ___syscall198(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall198(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall198 (lchown) {}", _which); debug!("emscripten::___syscall198 (lchown) {}", _which);
let path_ptr = varargs.get_str(ctx); let path_ptr = varargs.get_str(ctx);
let real_path_owned = utils::get_cstr_path(ctx, path_ptr as *const _); let real_path_owned = utils::get_cstr_path(ctx, path_ptr as *const _);
@@ -305,7 +305,7 @@ pub fn ___syscall198(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// getgroups /// getgroups
pub fn ___syscall205(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall205(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall205 (getgroups) {}", _which); debug!("emscripten::___syscall205 (getgroups) {}", _which);
let ngroups_max: c_int = varargs.get(ctx); let ngroups_max: c_int = varargs.get(ctx);
let groups: c_int = varargs.get(ctx); let groups: c_int = varargs.get(ctx);
@@ -322,7 +322,7 @@ pub fn ___syscall205(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
// chown // chown
pub fn ___syscall212(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall212(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall212 (chown) {}", _which); debug!("emscripten::___syscall212 (chown) {}", _which);
let pathname_addr = varargs.get_str(ctx); let pathname_addr = varargs.get_str(ctx);
@@ -339,7 +339,7 @@ pub fn ___syscall212(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// madvise /// madvise
pub fn ___syscall219(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall219(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall212 (chown) {}", _which); debug!("emscripten::___syscall212 (chown) {}", _which);
let addr_ptr: c_int = varargs.get(ctx); let addr_ptr: c_int = varargs.get(ctx);
@@ -352,7 +352,7 @@ pub fn ___syscall219(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// access /// access
pub fn ___syscall33(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall33(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall33 (access) {}", _which); debug!("emscripten::___syscall33 (access) {}", _which);
let path = varargs.get_str(ctx); let path = varargs.get_str(ctx);
let real_path_owned = utils::get_cstr_path(ctx, path as *const _); let real_path_owned = utils::get_cstr_path(ctx, path as *const _);
@@ -373,14 +373,14 @@ pub fn ___syscall33(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
} }
/// nice /// nice
pub fn ___syscall34(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall34(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall34 (nice) {}", _which); debug!("emscripten::___syscall34 (nice) {}", _which);
let inc_r: c_int = varargs.get(ctx); let inc_r: c_int = varargs.get(ctx);
unsafe { nice(inc_r) } unsafe { nice(inc_r) }
} }
// mkdir // mkdir
pub fn ___syscall39(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall39(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall39 (mkdir) {}", _which); debug!("emscripten::___syscall39 (mkdir) {}", _which);
let pathname_addr = varargs.get_str(ctx); let pathname_addr = varargs.get_str(ctx);
let real_path_owned = utils::get_cstr_path(ctx, pathname_addr as *const _); let real_path_owned = utils::get_cstr_path(ctx, pathname_addr as *const _);
@@ -394,20 +394,20 @@ pub fn ___syscall39(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
} }
/// dup /// dup
pub fn ___syscall41(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall41(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall41 (dup) {}", _which); debug!("emscripten::___syscall41 (dup) {}", _which);
let fd: c_int = varargs.get(ctx); let fd: c_int = varargs.get(ctx);
unsafe { dup(fd) } unsafe { dup(fd) }
} }
/// getgid32 /// getgid32
pub fn ___syscall200(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall200(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall200 (getgid32)"); debug!("emscripten::___syscall200 (getgid32)");
unsafe { getgid() as i32 } unsafe { getgid() as i32 }
} }
// geteuid32 // geteuid32
pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall201(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall201 (geteuid32)"); debug!("emscripten::___syscall201 (geteuid32)");
unsafe { unsafe {
// Maybe fix: Emscripten returns 0 always // Maybe fix: Emscripten returns 0 always
@@ -416,7 +416,7 @@ pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
} }
// getegid32 // getegid32
pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall202(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
// gid_t // gid_t
debug!("emscripten::___syscall202 (getegid32)"); debug!("emscripten::___syscall202 (getegid32)");
unsafe { unsafe {
@@ -426,7 +426,7 @@ pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
} }
/// fchown /// fchown
pub fn ___syscall207(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall207(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall207 (fchown) {}", _which); debug!("emscripten::___syscall207 (fchown) {}", _which);
let fd: c_int = varargs.get(ctx); let fd: c_int = varargs.get(ctx);
let owner: uid_t = varargs.get(ctx); let owner: uid_t = varargs.get(ctx);
@@ -435,7 +435,7 @@ pub fn ___syscall207(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// dup3 /// dup3
pub fn ___syscall330(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t { pub fn ___syscall330(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t {
// Implementation based on description at https://linux.die.net/man/2/dup3 // Implementation based on description at https://linux.die.net/man/2/dup3
debug!("emscripten::___syscall330 (dup3)"); debug!("emscripten::___syscall330 (dup3)");
let oldfd: c_int = varargs.get(ctx); let oldfd: c_int = varargs.get(ctx);
@@ -469,7 +469,7 @@ pub fn ___syscall330(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pi
} }
/// ioctl /// ioctl
pub fn ___syscall54(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall54(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall54 (ioctl) {}", _which); debug!("emscripten::___syscall54 (ioctl) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
@@ -511,7 +511,7 @@ const SOCK_CLOEXC: i32 = 0x80000;
// socketcall // socketcall
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall102(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall102(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall102 (socketcall) {}", _which); debug!("emscripten::___syscall102 (socketcall) {}", _which);
let call: u32 = varargs.get(ctx); let call: u32 = varargs.get(ctx);
let mut socket_varargs: VarArgs = varargs.get(ctx); let mut socket_varargs: VarArgs = varargs.get(ctx);
@@ -829,7 +829,7 @@ fn translate_socket_name_flag(name: i32) -> i32 {
} }
/// getpgid /// getpgid
pub fn ___syscall132(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall132(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall132 (getpgid)"); debug!("emscripten::___syscall132 (getpgid)");
let pid: pid_t = varargs.get(ctx); let pid: pid_t = varargs.get(ctx);
@@ -853,7 +853,7 @@ pub struct EmPollFd {
unsafe impl wasmer::ValueType for EmPollFd {} unsafe impl wasmer::ValueType for EmPollFd {}
/// poll /// poll
pub fn ___syscall168(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall168(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall168(poll)"); debug!("emscripten::___syscall168(poll)");
let fds: WasmPtr<EmPollFd> = varargs.get(ctx); let fds: WasmPtr<EmPollFd> = varargs.get(ctx);
let nfds: u32 = varargs.get(ctx); let nfds: u32 = varargs.get(ctx);
@@ -873,7 +873,7 @@ pub fn ___syscall168(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32
} }
// pread // pread
pub fn ___syscall180(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall180(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall180 (pread) {}", _which); debug!("emscripten::___syscall180 (pread) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
let buf: u32 = varargs.get(ctx); let buf: u32 = varargs.get(ctx);
@@ -890,7 +890,7 @@ pub fn ___syscall180(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
// pwrite // pwrite
pub fn ___syscall181(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall181(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall181 (pwrite) {}", _which); debug!("emscripten::___syscall181 (pwrite) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
let buf: u32 = varargs.get(ctx); let buf: u32 = varargs.get(ctx);
@@ -911,7 +911,7 @@ pub fn ___syscall181(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// fchmod /// fchmod
pub fn ___syscall94(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall94(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fchmod) {}", _which); debug!("emscripten::___syscall118 (fchmod) {}", _which);
let fd: c_int = varargs.get(ctx); let fd: c_int = varargs.get(ctx);
let mode: mode_t = varargs.get(ctx); let mode: mode_t = varargs.get(ctx);
@@ -920,7 +920,7 @@ pub fn ___syscall94(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
/// wait4 /// wait4
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall114(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t { pub fn ___syscall114(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t {
debug!("emscripten::___syscall114 (wait4)"); debug!("emscripten::___syscall114 (wait4)");
let pid: pid_t = varargs.get(ctx); let pid: pid_t = varargs.get(ctx);
let status: u32 = varargs.get(ctx); let status: u32 = varargs.get(ctx);
@@ -938,7 +938,7 @@ pub fn ___syscall114(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pi
} }
/// fsync /// fsync
pub fn ___syscall118(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall118(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fsync) {}", _which); debug!("emscripten::___syscall118 (fsync) {}", _which);
let fd: c_int = varargs.get(ctx); let fd: c_int = varargs.get(ctx);
unsafe { fsync(fd) } unsafe { fsync(fd) }
@@ -946,7 +946,7 @@ pub fn ___syscall118(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
// select // select
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall142(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall142(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall142 (newselect) {}", _which); debug!("emscripten::___syscall142 (newselect) {}", _which);
let nfds: i32 = varargs.get(ctx); let nfds: i32 = varargs.get(ctx);
@@ -968,7 +968,7 @@ pub fn ___syscall142(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// fdatasync /// fdatasync
pub fn ___syscall148(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall148(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall148 (fdatasync) {}", _which); debug!("emscripten::___syscall148 (fdatasync) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
@@ -977,7 +977,7 @@ pub fn ___syscall148(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
// setpgid // setpgid
pub fn ___syscall57(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall57(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall57 (setpgid) {}", _which); debug!("emscripten::___syscall57 (setpgid) {}", _which);
let pid: i32 = varargs.get(ctx); let pid: i32 = varargs.get(ctx);
@@ -993,7 +993,7 @@ pub fn ___syscall57(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i
/// uname /// uname
// NOTE: Wondering if we should return custom utsname, like Emscripten. // NOTE: Wondering if we should return custom utsname, like Emscripten.
pub fn ___syscall122(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall122(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall122 (uname) {}", _which); debug!("emscripten::___syscall122 (uname) {}", _which);
let buf: u32 = varargs.get(ctx); let buf: u32 = varargs.get(ctx);
debug!("=> buf: {}", buf); debug!("=> buf: {}", buf);
@@ -1002,7 +1002,7 @@ pub fn ___syscall122(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// lstat64 /// lstat64
pub fn ___syscall196(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall196(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall196 (lstat64) {}", _which); debug!("emscripten::___syscall196 (lstat64) {}", _which);
let path = varargs.get_str(ctx); let path = varargs.get_str(ctx);
let real_path_owned = utils::get_cstr_path(ctx, path as *const _); let real_path_owned = utils::get_cstr_path(ctx, path as *const _);
@@ -1035,7 +1035,7 @@ pub fn ___syscall196(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32
} }
// getuid // getuid
pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall199(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall199 (getuid)"); debug!("emscripten::___syscall199 (getuid)");
let uid = unsafe { getuid() as _ }; let uid = unsafe { getuid() as _ };
debug!(" => {}", uid); debug!(" => {}", uid);
@@ -1045,7 +1045,7 @@ pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 {
// getdents // getdents
// dirent structure is // dirent structure is
// i64, i64, u16 (280), i8, [i8; 256] // i64, i64, u16 (280), i8, [i8; 256]
pub fn ___syscall220(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { pub fn ___syscall220(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 {
use super::super::env::get_emscripten_data; use super::super::env::get_emscripten_data;
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
@@ -1109,7 +1109,7 @@ pub fn ___syscall220(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32
} }
// fcntl64 // fcntl64
pub fn ___syscall221(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall221(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall221 (fcntl64) {}", _which); debug!("emscripten::___syscall221 (fcntl64) {}", _which);
let fd: i32 = varargs.get(ctx); let fd: i32 = varargs.get(ctx);
let cmd: i32 = varargs.get(ctx); let cmd: i32 = varargs.get(ctx);
@@ -1127,7 +1127,7 @@ pub fn ___syscall221(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_
} }
/// fallocate /// fallocate
pub fn ___syscall324(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall324(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall324 (fallocate) {}", _which); debug!("emscripten::___syscall324 (fallocate) {}", _which);
let _fd: c_int = varargs.get(ctx); let _fd: c_int = varargs.get(ctx);
let _mode: c_int = varargs.get(ctx); let _mode: c_int = varargs.get(ctx);

View File

@@ -13,7 +13,7 @@ use std::os::raw::c_int;
type pid_t = c_int; type pid_t = c_int;
/// open /// open
pub fn ___syscall5(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall5(ctx: &EmEnv, which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall5 (open) {}", which); debug!("emscripten::___syscall5 (open) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -64,19 +64,19 @@ pub fn ___syscall5(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int
} }
/// link /// link
pub fn ___syscall9(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall9(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall9 (link) {}", _which); debug!("emscripten::___syscall9 (link) {}", _which);
unimplemented!("emscripten::___syscall9 (link) {}", _which); unimplemented!("emscripten::___syscall9 (link) {}", _which);
} }
/// ftruncate64 /// ftruncate64
pub fn ___syscall194(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall194(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall194 - stub"); debug!("emscripten::___syscall194 - stub");
unimplemented!("emscripten::___syscall194 - stub") unimplemented!("emscripten::___syscall194 - stub")
} }
// chown // chown
pub fn ___syscall212(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall212(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall212 (chown) {}", which); debug!("emscripten::___syscall212 (chown) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -84,19 +84,19 @@ pub fn ___syscall212(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c
} }
/// access /// access
pub fn ___syscall33(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall33(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall33 (access) {}", _which); debug!("emscripten::___syscall33 (access) {}", _which);
unimplemented!("emscripten::___syscall33 (access) {}", _which); unimplemented!("emscripten::___syscall33 (access) {}", _which);
} }
/// nice /// nice
pub fn ___syscall34(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall34(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall34 (nice) {}", _which); debug!("emscripten::___syscall34 (nice) {}", _which);
unimplemented!("emscripten::___syscall34 (nice) {}", _which); unimplemented!("emscripten::___syscall34 (nice) {}", _which);
} }
// mkdir // mkdir
pub fn ___syscall39(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int { pub fn ___syscall39(ctx: &EmEnv, which: c_int, mut varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall39 (mkdir) {}", which); debug!("emscripten::___syscall39 (mkdir) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -111,80 +111,80 @@ pub fn ___syscall39(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_in
} }
/// dup /// dup
pub fn ___syscall41(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall41(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall41 (dup) {}", _which); debug!("emscripten::___syscall41 (dup) {}", _which);
unimplemented!("emscripten::___syscall41 (dup) {}", _which); unimplemented!("emscripten::___syscall41 (dup) {}", _which);
} }
/// getrusage /// getrusage
pub fn ___syscall77(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall77(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall77 (getrusage) {}", _which); debug!("emscripten::___syscall77 (getrusage) {}", _which);
unimplemented!("emscripten::___syscall77 (getrusage) {}", _which); unimplemented!("emscripten::___syscall77 (getrusage) {}", _which);
} }
/// symlink /// symlink
pub fn ___syscall83(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall83(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall83 (symlink) {}", _which); debug!("emscripten::___syscall83 (symlink) {}", _which);
unimplemented!("emscripten::___syscall83 (symlink) {}", _which); unimplemented!("emscripten::___syscall83 (symlink) {}", _which);
} }
/// readlink /// readlink
pub fn ___syscall85(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall85(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall85 (readlink) {}", _which); debug!("emscripten::___syscall85 (readlink) {}", _which);
-1 -1
} }
/// getpgid /// getpgid
pub fn ___syscall132(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall132(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall132 (getpgid)"); debug!("emscripten::___syscall132 (getpgid)");
-1 -1
} }
/// lchown /// lchown
pub fn ___syscall198(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall198(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall198 (lchown) {}", _which); debug!("emscripten::___syscall198 (lchown) {}", _which);
unimplemented!("emscripten::___syscall198 (lchown) {}", _which); unimplemented!("emscripten::___syscall198 (lchown) {}", _which);
} }
/// getgid32 /// getgid32
pub fn ___syscall200(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall200(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall200 (getgid32)"); debug!("emscripten::___syscall200 (getgid32)");
unimplemented!("emscripten::___syscall200 (getgid32)"); unimplemented!("emscripten::___syscall200 (getgid32)");
} }
// geteuid32 // geteuid32
pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall201(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall201 (geteuid32)"); debug!("emscripten::___syscall201 (geteuid32)");
unimplemented!("emscripten::___syscall201 (geteuid32)"); unimplemented!("emscripten::___syscall201 (geteuid32)");
} }
// getegid32 // getegid32
pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall202(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
// gid_t // gid_t
debug!("emscripten::___syscall202 (getegid32)"); debug!("emscripten::___syscall202 (getegid32)");
unimplemented!("emscripten::___syscall202 (getegid32)"); unimplemented!("emscripten::___syscall202 (getegid32)");
} }
/// getgroups /// getgroups
pub fn ___syscall205(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall205(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall205 (getgroups) {}", _which); debug!("emscripten::___syscall205 (getgroups) {}", _which);
unimplemented!("emscripten::___syscall205 (getgroups) {}", _which); unimplemented!("emscripten::___syscall205 (getgroups) {}", _which);
} }
/// madvise /// madvise
pub fn ___syscall219(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall219(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall212 (chown) {}", _which); debug!("emscripten::___syscall212 (chown) {}", _which);
unimplemented!("emscripten::___syscall212 (chown) {}", _which); unimplemented!("emscripten::___syscall212 (chown) {}", _which);
} }
/// dup3 /// dup3
pub fn ___syscall330(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t { pub fn ___syscall330(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t {
debug!("emscripten::___syscall330 (dup3)"); debug!("emscripten::___syscall330 (dup3)");
-1 -1
} }
/// ioctl /// ioctl
pub fn ___syscall54(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall54(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall54 (ioctl) {}", which); debug!("emscripten::___syscall54 (ioctl) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -192,14 +192,14 @@ pub fn ___syscall54(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_
} }
/// fchmod /// fchmod
pub fn ___syscall94(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall94(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fchmod) {}", _which); debug!("emscripten::___syscall118 (fchmod) {}", _which);
unimplemented!("emscripten::___syscall118 (fchmod) {}", _which); unimplemented!("emscripten::___syscall118 (fchmod) {}", _which);
} }
// socketcall // socketcall
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall102(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall102(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall102 (socketcall) {}", which); debug!("emscripten::___syscall102 (socketcall) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -207,13 +207,13 @@ pub fn ___syscall102(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c
} }
/// fsync /// fsync
pub fn ___syscall118(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall118(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall118 (fsync) {}", _which); debug!("emscripten::___syscall118 (fsync) {}", _which);
unimplemented!("emscripten::___syscall118 (fsync) {}", _which); unimplemented!("emscripten::___syscall118 (fsync) {}", _which);
} }
// pread // pread
pub fn ___syscall180(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall180(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall180 (pread) {}", which); debug!("emscripten::___syscall180 (pread) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -221,7 +221,7 @@ pub fn ___syscall180(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c
} }
// pwrite // pwrite
pub fn ___syscall181(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall181(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall181 (pwrite) {}", which); debug!("emscripten::___syscall181 (pwrite) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -230,14 +230,14 @@ pub fn ___syscall181(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c
/// wait4 /// wait4
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall114(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t { pub fn ___syscall114(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t {
debug!("emscripten::___syscall114 (wait4)"); debug!("emscripten::___syscall114 (wait4)");
-1 -1
} }
// select // select
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn ___syscall142(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall142(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall142 (newselect) {}", which); debug!("emscripten::___syscall142 (newselect) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -245,13 +245,13 @@ pub fn ___syscall142(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c
} }
/// fdatasync /// fdatasync
pub fn ___syscall148(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall148(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall148 (fdatasync) {}", _which); debug!("emscripten::___syscall148 (fdatasync) {}", _which);
unimplemented!("emscripten::___syscall148 (fdatasync) {}", _which); unimplemented!("emscripten::___syscall148 (fdatasync) {}", _which);
} }
// setpgid // setpgid
pub fn ___syscall57(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall57(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall57 (setpgid) {}", which); debug!("emscripten::___syscall57 (setpgid) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -260,7 +260,7 @@ pub fn ___syscall57(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_
/// uname /// uname
// NOTE: Wondering if we should return custom utsname, like Emscripten. // NOTE: Wondering if we should return custom utsname, like Emscripten.
pub fn ___syscall122(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall122(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall122 (uname) {}", which); debug!("emscripten::___syscall122 (uname) {}", which);
#[cfg(not(feature = "debug"))] #[cfg(not(feature = "debug"))]
let _ = which; let _ = which;
@@ -268,43 +268,43 @@ pub fn ___syscall122(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c
} }
/// poll /// poll
pub fn ___syscall168(_ctx: &mut EmEnv, _which: i32, _varargs: VarArgs) -> i32 { pub fn ___syscall168(_ctx: &EmEnv, _which: i32, _varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall168(poll) - stub"); debug!("emscripten::___syscall168(poll) - stub");
-1 -1
} }
/// lstat64 /// lstat64
pub fn ___syscall196(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall196(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall196 (lstat64) - stub"); debug!("emscripten::___syscall196 (lstat64) - stub");
-1 -1
} }
// getuid // getuid
pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall199(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall199 (getuid)"); debug!("emscripten::___syscall199 (getuid)");
-1 -1
} }
// getdents // getdents
pub fn ___syscall220(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn ___syscall220(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall220"); debug!("emscripten::___syscall220");
-1 -1
} }
// fcntl64 // fcntl64
pub fn ___syscall221(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { pub fn ___syscall221(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall221 (fcntl64) {}", _which); debug!("emscripten::___syscall221 (fcntl64) {}", _which);
-1 -1
} }
/// fchown /// fchown
pub fn ___syscall207(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall207(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall207 (fchown) {}", _which); debug!("emscripten::___syscall207 (fchown) {}", _which);
unimplemented!("emscripten::___syscall207 (fchown) {}", _which) unimplemented!("emscripten::___syscall207 (fchown) {}", _which)
} }
/// fallocate /// fallocate
pub fn ___syscall324(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { pub fn ___syscall324(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall324 (fallocate) {}", _which); debug!("emscripten::___syscall324 (fallocate) {}", _which);
unimplemented!("emscripten::___syscall324 (fallocate) {}", _which) unimplemented!("emscripten::___syscall324 (fallocate) {}", _which)
} }

View File

@@ -52,7 +52,7 @@ const CLOCK_MONOTONIC_COARSE: clockid_t = 6;
/// emscripten: _gettimeofday /// emscripten: _gettimeofday
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _gettimeofday(ctx: &mut EmEnv, tp: c_int, tz: c_int) -> c_int { pub fn _gettimeofday(ctx: &EmEnv, tp: c_int, tz: c_int) -> c_int {
debug!("emscripten::_gettimeofday {} {}", tp, tz); debug!("emscripten::_gettimeofday {} {}", tp, tz);
#[repr(C)] #[repr(C)]
struct GuestTimeVal { struct GuestTimeVal {
@@ -75,7 +75,7 @@ pub fn _gettimeofday(ctx: &mut EmEnv, tp: c_int, tz: c_int) -> c_int {
0 0
} }
pub fn _clock_getres(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 { pub fn _clock_getres(_ctx: &EmEnv, _clk_id: i32, _tp: i32) -> i32 {
debug!("emscripten::_clock_getres"); debug!("emscripten::_clock_getres");
// clock_getres(clk_id, tp) // clock_getres(clk_id, tp)
0 0
@@ -83,7 +83,7 @@ pub fn _clock_getres(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 {
/// emscripten: _clock_gettime /// emscripten: _clock_gettime
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int { pub fn _clock_gettime(ctx: &EmEnv, clk_id: clockid_t, tp: c_int) -> c_int {
debug!("emscripten::_clock_gettime {} {}", clk_id, tp); debug!("emscripten::_clock_gettime {} {}", clk_id, tp);
// debug!("Memory {:?}", ctx.memory(0)[..]); // debug!("Memory {:?}", ctx.memory(0)[..]);
#[repr(C)] #[repr(C)]
@@ -115,41 +115,41 @@ pub fn _clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int {
0 0
} }
pub fn _clock_settime(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 { pub fn _clock_settime(_ctx: &EmEnv, _clk_id: i32, _tp: i32) -> i32 {
debug!("emscripten::_clock_settime"); debug!("emscripten::_clock_settime");
// clock_settime(clk_id, tp) // clock_settime(clk_id, tp)
0 0
} }
/// emscripten: ___clock_gettime /// emscripten: ___clock_gettime
pub fn ___clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int { pub fn ___clock_gettime(ctx: &EmEnv, clk_id: clockid_t, tp: c_int) -> c_int {
debug!("emscripten::___clock_gettime {} {}", clk_id, tp); debug!("emscripten::___clock_gettime {} {}", clk_id, tp);
_clock_gettime(ctx, clk_id, tp) _clock_gettime(ctx, clk_id, tp)
} }
/// emscripten: _clock /// emscripten: _clock
pub fn _clock(_ctx: &mut EmEnv) -> c_int { pub fn _clock(_ctx: &EmEnv) -> c_int {
debug!("emscripten::_clock"); debug!("emscripten::_clock");
0 // TODO: unimplemented 0 // TODO: unimplemented
} }
/// emscripten: _difftime /// emscripten: _difftime
pub fn _difftime(_ctx: &mut EmEnv, t0: u32, t1: u32) -> f64 { pub fn _difftime(_ctx: &EmEnv, t0: u32, t1: u32) -> f64 {
debug!("emscripten::_difftime"); debug!("emscripten::_difftime");
(t0 - t1) as _ (t0 - t1) as _
} }
pub fn _gmtime_r(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { pub fn _gmtime_r(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 {
debug!("emscripten::_gmtime_r"); debug!("emscripten::_gmtime_r");
-1 -1
} }
pub fn _mktime(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _mktime(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_mktime"); debug!("emscripten::_mktime");
-1 -1
} }
pub fn _gmtime(_ctx: &mut EmEnv, _one: i32) -> i32 { pub fn _gmtime(_ctx: &EmEnv, _one: i32) -> i32 {
debug!("emscripten::_gmtime"); debug!("emscripten::_gmtime");
-1 -1
} }
@@ -170,13 +170,13 @@ struct guest_tm {
} }
/// emscripten: _tvset /// emscripten: _tvset
pub fn _tvset(_ctx: &mut EmEnv) { pub fn _tvset(_ctx: &EmEnv) {
debug!("emscripten::_tvset UNIMPLEMENTED"); debug!("emscripten::_tvset UNIMPLEMENTED");
} }
/// formats time as a C string /// formats time as a C string
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
unsafe fn fmt_time(ctx: &mut EmEnv, time: u32) -> *const c_char { unsafe fn fmt_time(ctx: &EmEnv, time: u32) -> *const c_char {
let date = &*(emscripten_memory_pointer!(ctx.memory(0), time) as *mut guest_tm); let date = &*(emscripten_memory_pointer!(ctx.memory(0), time) as *mut guest_tm);
let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
@@ -201,7 +201,7 @@ unsafe fn fmt_time(ctx: &mut EmEnv, time: u32) -> *const c_char {
} }
/// emscripten: _asctime /// emscripten: _asctime
pub fn _asctime(ctx: &mut EmEnv, time: u32) -> u32 { pub fn _asctime(ctx: &EmEnv, time: u32) -> u32 {
debug!("emscripten::_asctime {}", time); debug!("emscripten::_asctime {}", time);
unsafe { unsafe {
@@ -215,7 +215,7 @@ pub fn _asctime(ctx: &mut EmEnv, time: u32) -> u32 {
} }
/// emscripten: _asctime_r /// emscripten: _asctime_r
pub fn _asctime_r(ctx: &mut EmEnv, time: u32, buf: u32) -> u32 { pub fn _asctime_r(ctx: &EmEnv, time: u32, buf: u32) -> u32 {
debug!("emscripten::_asctime_r {}, {}", time, buf); debug!("emscripten::_asctime_r {}, {}", time, buf);
unsafe { unsafe {
@@ -234,7 +234,7 @@ pub fn _asctime_r(ctx: &mut EmEnv, time: u32, buf: u32) -> u32 {
/// emscripten: _localtime /// emscripten: _localtime
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _localtime(ctx: &mut EmEnv, time_p: u32) -> c_int { pub fn _localtime(ctx: &EmEnv, time_p: u32) -> c_int {
debug!("emscripten::_localtime {}", time_p); debug!("emscripten::_localtime {}", time_p);
// NOTE: emscripten seems to want tzset() called in this function // NOTE: emscripten seems to want tzset() called in this function
// https://stackoverflow.com/questions/19170721/real-time-awareness-of-timezone-change-in-localtime-vs-localtime-r // https://stackoverflow.com/questions/19170721/real-time-awareness-of-timezone-change-in-localtime-vs-localtime-r
@@ -272,7 +272,7 @@ pub fn _localtime(ctx: &mut EmEnv, time_p: u32) -> c_int {
} }
/// emscripten: _localtime_r /// emscripten: _localtime_r
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _localtime_r(ctx: &mut EmEnv, time_p: u32, result: u32) -> c_int { pub fn _localtime_r(ctx: &EmEnv, time_p: u32, result: u32) -> c_int {
debug!("emscripten::_localtime_r {}", time_p); debug!("emscripten::_localtime_r {}", time_p);
// NOTE: emscripten seems to want tzset() called in this function // NOTE: emscripten seems to want tzset() called in this function
@@ -309,7 +309,7 @@ pub fn _localtime_r(ctx: &mut EmEnv, time_p: u32, result: u32) -> c_int {
/// emscripten: _time /// emscripten: _time
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _time(ctx: &mut EmEnv, time_p: u32) -> i32 { pub fn _time(ctx: &EmEnv, time_p: u32) -> i32 {
debug!("emscripten::_time {}", time_p); debug!("emscripten::_time {}", time_p);
unsafe { unsafe {
@@ -318,7 +318,7 @@ pub fn _time(ctx: &mut EmEnv, time_p: u32) -> i32 {
} }
} }
pub fn _ctime_r(ctx: &mut EmEnv, time_p: u32, buf: u32) -> u32 { pub fn _ctime_r(ctx: &EmEnv, time_p: u32, buf: u32) -> u32 {
debug!("emscripten::_ctime_r {} {}", time_p, buf); debug!("emscripten::_ctime_r {} {}", time_p, buf);
// var stack = stackSave(); // var stack = stackSave();
@@ -329,7 +329,7 @@ pub fn _ctime_r(ctx: &mut EmEnv, time_p: u32, buf: u32) -> u32 {
rv rv
} }
pub fn _ctime(ctx: &mut EmEnv, time_p: u32) -> u32 { pub fn _ctime(ctx: &EmEnv, time_p: u32) -> u32 {
debug!("emscripten::_ctime {}", time_p); debug!("emscripten::_ctime {}", time_p);
let tm_current = 2414544; let tm_current = 2414544;
_ctime_r(ctx, time_p, tm_current) _ctime_r(ctx, time_p, tm_current)
@@ -338,7 +338,7 @@ pub fn _ctime(ctx: &mut EmEnv, time_p: u32) -> u32 {
/// emscripten: _timegm /// emscripten: _timegm
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub fn _timegm(ctx: &mut EmEnv, time_ptr: u32) -> i32 { pub fn _timegm(ctx: &EmEnv, time_ptr: u32) -> i32 {
debug!("emscripten::_timegm {}", time_ptr); debug!("emscripten::_timegm {}", time_ptr);
unsafe { unsafe {
@@ -378,7 +378,7 @@ pub fn _timegm(ctx: &mut EmEnv, time_ptr: u32) -> i32 {
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub fn _timegm(_ctx: &mut EmEnv, _time_ptr: c_int) -> i32 { pub fn _timegm(_ctx: &EmEnv, _time_ptr: c_int) -> i32 {
debug!( debug!(
"emscripten::_timegm - UNIMPLEMENTED IN WINDOWS {}", "emscripten::_timegm - UNIMPLEMENTED IN WINDOWS {}",
_time_ptr _time_ptr
@@ -387,13 +387,7 @@ pub fn _timegm(_ctx: &mut EmEnv, _time_ptr: c_int) -> i32 {
} }
/// emscripten: _strftime /// emscripten: _strftime
pub fn _strftime( pub fn _strftime(ctx: &EmEnv, s_ptr: c_int, maxsize: u32, format_ptr: c_int, tm_ptr: c_int) -> i32 {
ctx: &mut EmEnv,
s_ptr: c_int,
maxsize: u32,
format_ptr: c_int,
tm_ptr: c_int,
) -> i32 {
debug!( debug!(
"emscripten::_strftime {} {} {} {}", "emscripten::_strftime {} {} {} {}",
s_ptr, maxsize, format_ptr, tm_ptr s_ptr, maxsize, format_ptr, tm_ptr
@@ -448,7 +442,7 @@ pub fn _strftime(
/// emscripten: _strftime_l /// emscripten: _strftime_l
pub fn _strftime_l( pub fn _strftime_l(
ctx: &mut EmEnv, ctx: &EmEnv,
s_ptr: c_int, s_ptr: c_int,
maxsize: u32, maxsize: u32,
format_ptr: c_int, format_ptr: c_int,

View File

@@ -1,20 +1,20 @@
use crate::EmEnv; use crate::EmEnv;
pub fn _getcontext(_ctx: &mut EmEnv, _ucp: i32) -> i32 { pub fn _getcontext(_ctx: &EmEnv, _ucp: i32) -> i32 {
debug!("emscripten::_getcontext({})", _ucp); debug!("emscripten::_getcontext({})", _ucp);
0 0
} }
pub fn _makecontext(_ctx: &mut EmEnv, _ucp: i32, _func: i32, _argc: i32, _argv: i32) { pub fn _makecontext(_ctx: &EmEnv, _ucp: i32, _func: i32, _argc: i32, _argv: i32) {
debug!( debug!(
"emscripten::_makecontext({}, {}, {}, {})", "emscripten::_makecontext({}, {}, {}, {})",
_ucp, _func, _argc, _argv _ucp, _func, _argc, _argv
); );
} }
pub fn _setcontext(_ctx: &mut EmEnv, _ucp: i32) -> i32 { pub fn _setcontext(_ctx: &EmEnv, _ucp: i32) -> i32 {
debug!("emscripten::_setcontext({})", _ucp); debug!("emscripten::_setcontext({})", _ucp);
0 0
} }
pub fn _swapcontext(_ctx: &mut EmEnv, _oucp: i32, _ucp: i32) -> i32 { pub fn _swapcontext(_ctx: &EmEnv, _oucp: i32, _ucp: i32) -> i32 {
debug!("emscripten::_swapcontext({}, {})", _oucp, _ucp); debug!("emscripten::_swapcontext({}, {})", _oucp, _ucp);
0 0
} }

View File

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

View File

@@ -93,7 +93,7 @@ pub fn get_emscripten_metadata(module: &Module) -> Result<Option<(u32, u32)>, St
} }
} }
pub unsafe fn write_to_buf(ctx: &mut EmEnv, string: *const c_char, buf: u32, max: u32) -> u32 { pub unsafe fn write_to_buf(ctx: &EmEnv, string: *const c_char, buf: u32, max: u32) -> u32 {
let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut c_char; let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut c_char;
for i in 0..max { for i in 0..max {
@@ -104,7 +104,7 @@ pub unsafe fn write_to_buf(ctx: &mut EmEnv, string: *const c_char, buf: u32, max
} }
/// This function expects nullbyte to be appended. /// This function expects nullbyte to be appended.
pub unsafe fn copy_cstr_into_wasm(ctx: &mut EmEnv, cstr: *const c_char) -> u32 { pub unsafe fn copy_cstr_into_wasm(ctx: &EmEnv, cstr: *const c_char) -> u32 {
let s = CStr::from_ptr(cstr).to_str().unwrap(); let s = CStr::from_ptr(cstr).to_str().unwrap();
let cstr_len = s.len(); let cstr_len = s.len();
let space_offset = env::call_malloc(ctx, (cstr_len as u32) + 1); let space_offset = env::call_malloc(ctx, (cstr_len as u32) + 1);
@@ -122,7 +122,7 @@ pub unsafe fn copy_cstr_into_wasm(ctx: &mut EmEnv, cstr: *const c_char) -> u32 {
space_offset space_offset
} }
pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a mut EmEnv, count: u32) -> (u32, &'a mut [T]) { pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a EmEnv, count: u32) -> (u32, &'a mut [T]) {
let offset = get_emscripten_data(ctx) let offset = get_emscripten_data(ctx)
.stack_alloc .stack_alloc
.as_ref() .as_ref()
@@ -136,7 +136,7 @@ pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a mut EmEnv, count: u32) ->
(offset, slice) (offset, slice)
} }
pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut EmEnv, s: &str) -> (u32, &'a [u8]) { pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a EmEnv, s: &str) -> (u32, &'a [u8]) {
let (offset, slice) = allocate_on_stack(ctx, (s.len() + 1) as u32); let (offset, slice) = allocate_on_stack(ctx, (s.len() + 1) as u32);
use std::iter; use std::iter;
@@ -148,7 +148,7 @@ pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut EmEnv, s: &str) -> (u32, &
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &mut EmEnv, cstrs: *mut *mut c_char) -> u32 { pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &EmEnv, cstrs: *mut *mut c_char) -> u32 {
let _total_num = { let _total_num = {
let mut ptr = cstrs; let mut ptr = cstrs;
let mut counter = 0; let mut counter = 0;
@@ -186,7 +186,7 @@ pub struct GuestStat {
} }
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
pub unsafe fn copy_stat_into_wasm(ctx: &mut EmEnv, buf: u32, stat: &stat) { pub unsafe fn copy_stat_into_wasm(ctx: &EmEnv, buf: u32, stat: &stat) {
let stat_ptr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut GuestStat; let stat_ptr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut GuestStat;
(*stat_ptr).st_dev = stat.st_dev as _; (*stat_ptr).st_dev = stat.st_dev as _;
(*stat_ptr).__st_dev_padding = 0; (*stat_ptr).__st_dev_padding = 0;
@@ -225,7 +225,7 @@ pub fn read_string_from_wasm(memory: &Memory, offset: u32) -> String {
/// This function trys to find an entry in mapdir /// This function trys to find an entry in mapdir
/// translating paths into their correct value /// translating paths into their correct value
pub fn get_cstr_path(ctx: &mut EmEnv, path: *const i8) -> Option<std::ffi::CString> { pub fn get_cstr_path(ctx: &EmEnv, path: *const i8) -> Option<std::ffi::CString> {
use std::collections::VecDeque; use std::collections::VecDeque;
let path_str = let path_str =
@@ -261,7 +261,7 @@ pub fn get_cstr_path(ctx: &mut EmEnv, path: *const i8) -> Option<std::ffi::CStri
/// gets the current directory /// gets the current directory
/// handles mapdir logic /// handles mapdir logic
pub fn get_current_directory(ctx: &mut EmEnv) -> Option<PathBuf> { pub fn get_current_directory(ctx: &EmEnv) -> Option<PathBuf> {
if let Some(val) = get_emscripten_data(ctx).mapped_dirs.get(".") { if let Some(val) = get_emscripten_data(ctx).mapped_dirs.get(".") {
return Some(val.clone()); return Some(val.clone());
} }

View File

@@ -11,14 +11,14 @@ pub struct VarArgs {
} }
impl VarArgs { impl VarArgs {
pub fn get<T: Sized>(&mut self, ctx: &mut EmEnv) -> T { pub fn get<T: Sized>(&mut self, ctx: &EmEnv) -> T {
let ptr = emscripten_memory_pointer!(ctx.memory(0), self.pointer); let ptr = emscripten_memory_pointer!(ctx.memory(0), self.pointer);
self.pointer += mem::size_of::<T>() as u32; self.pointer += mem::size_of::<T>() as u32;
unsafe { (ptr as *const T).read() } unsafe { (ptr as *const T).read() }
} }
// pub fn getStr<'a>(&mut self, ctx: &mut Ctx) -> &'a CStr { // pub fn getStr<'a>(&mut self, ctx: &mut Ctx) -> &'a CStr {
pub fn get_str(&mut self, ctx: &mut EmEnv) -> *const c_char { pub fn get_str(&mut self, ctx: &EmEnv) -> *const c_char {
let ptr_addr: u32 = self.get(ctx); let ptr_addr: u32 = self.get(ctx);
let ptr = emscripten_memory_pointer!(ctx.memory(0), ptr_addr) as *const c_char; let ptr = emscripten_memory_pointer!(ctx.memory(0), ptr_addr) as *const c_char;
ptr ptr

View File

@@ -1006,7 +1006,7 @@ impl InstanceHandle {
/// # Safety /// # Safety
/// This is unsafe because it doesn't work on just any `VMContext`, it must /// This is unsafe because it doesn't work on just any `VMContext`, it must
/// be a `VMContext` allocated as part of an `Instance`. /// be a `VMContext` allocated as part of an `Instance`.
pub unsafe fn from_vmctx(vmctx: *mut VMContext) -> Self { pub unsafe fn from_vmctx(vmctx: *const VMContext) -> Self {
let instance = (&*vmctx).instance(); let instance = (&*vmctx).instance();
Self { Self {

View File

@@ -176,7 +176,7 @@ impl WasiEnv {
} }
pub(crate) fn get_memory_and_wasi_state( pub(crate) fn get_memory_and_wasi_state(
&mut self, &self,
_mem_index: u32, _mem_index: u32,
) -> (&Memory, MutexGuard<WasiState>) { ) -> (&Memory, MutexGuard<WasiState>) {
let memory = self.memory(); let memory = self.memory();

View File

@@ -10,7 +10,7 @@ use crate::WasiEnv;
/// Wasm memory. If the memory clobbered by the current syscall is also used by /// Wasm memory. If the memory clobbered by the current syscall is also used by
/// that syscall, then it may break. /// that syscall, then it may break.
pub fn fd_filestat_get( pub fn fd_filestat_get(
env: &mut WasiEnv, env: &WasiEnv,
fd: types::__wasi_fd_t, fd: types::__wasi_fd_t,
buf: WasmPtr<snapshot0::__wasi_filestat_t>, buf: WasmPtr<snapshot0::__wasi_filestat_t>,
) -> types::__wasi_errno_t { ) -> types::__wasi_errno_t {
@@ -61,7 +61,7 @@ pub fn fd_filestat_get(
/// Wrapper around `syscalls::path_filestat_get` with extra logic to handle the size /// Wrapper around `syscalls::path_filestat_get` with extra logic to handle the size
/// difference of `wasi_filestat_t` /// difference of `wasi_filestat_t`
pub fn path_filestat_get( pub fn path_filestat_get(
env: &mut WasiEnv, env: &WasiEnv,
fd: types::__wasi_fd_t, fd: types::__wasi_fd_t,
flags: types::__wasi_lookupflags_t, flags: types::__wasi_lookupflags_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
@@ -100,7 +100,7 @@ pub fn path_filestat_get(
/// Wrapper around `syscalls::fd_seek` with extra logic to remap the values /// Wrapper around `syscalls::fd_seek` with extra logic to remap the values
/// of `__wasi_whence_t` /// of `__wasi_whence_t`
pub fn fd_seek( pub fn fd_seek(
env: &mut WasiEnv, env: &WasiEnv,
fd: types::__wasi_fd_t, fd: types::__wasi_fd_t,
offset: types::__wasi_filedelta_t, offset: types::__wasi_filedelta_t,
whence: snapshot0::__wasi_whence_t, whence: snapshot0::__wasi_whence_t,
@@ -119,7 +119,7 @@ pub fn fd_seek(
/// Wrapper around `syscalls::poll_oneoff` with extra logic to add the removed /// Wrapper around `syscalls::poll_oneoff` with extra logic to add the removed
/// userdata field back /// userdata field back
pub fn poll_oneoff( pub fn poll_oneoff(
env: &mut WasiEnv, env: &WasiEnv,
in_: WasmPtr<snapshot0::__wasi_subscription_t, Array>, in_: WasmPtr<snapshot0::__wasi_subscription_t, Array>,
out_: WasmPtr<types::__wasi_event_t, Array>, out_: WasmPtr<types::__wasi_event_t, Array>,
nsubscriptions: u32, nsubscriptions: u32,

View File

@@ -135,7 +135,7 @@ fn get_current_time_in_nanos() -> Result<__wasi_timestamp_t, __wasi_errno_t> {
/// A pointer to a buffer to write the argument string data. /// A pointer to a buffer to write the argument string data.
/// ///
pub fn args_get( pub fn args_get(
env: &mut WasiEnv, env: &WasiEnv,
argv: WasmPtr<WasmPtr<u8, Array>, Array>, argv: WasmPtr<WasmPtr<u8, Array>, Array>,
argv_buf: WasmPtr<u8, Array>, argv_buf: WasmPtr<u8, Array>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -170,7 +170,7 @@ pub fn args_get(
/// - `size_t *argv_buf_size` /// - `size_t *argv_buf_size`
/// The size of the argument string data. /// The size of the argument string data.
pub fn args_sizes_get( pub fn args_sizes_get(
env: &mut WasiEnv, env: &WasiEnv,
argc: WasmPtr<u32>, argc: WasmPtr<u32>,
argv_buf_size: WasmPtr<u32>, argv_buf_size: WasmPtr<u32>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -199,7 +199,7 @@ pub fn args_sizes_get(
/// - `__wasi_timestamp_t *resolution` /// - `__wasi_timestamp_t *resolution`
/// The resolution of the clock in nanoseconds /// The resolution of the clock in nanoseconds
pub fn clock_res_get( pub fn clock_res_get(
env: &mut WasiEnv, env: &WasiEnv,
clock_id: __wasi_clockid_t, clock_id: __wasi_clockid_t,
resolution: WasmPtr<__wasi_timestamp_t>, resolution: WasmPtr<__wasi_timestamp_t>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -221,7 +221,7 @@ pub fn clock_res_get(
/// - `__wasi_timestamp_t *time` /// - `__wasi_timestamp_t *time`
/// The value of the clock in nanoseconds /// The value of the clock in nanoseconds
pub fn clock_time_get( pub fn clock_time_get(
env: &mut WasiEnv, env: &WasiEnv,
clock_id: __wasi_clockid_t, clock_id: __wasi_clockid_t,
precision: __wasi_timestamp_t, precision: __wasi_timestamp_t,
time: WasmPtr<__wasi_timestamp_t>, time: WasmPtr<__wasi_timestamp_t>,
@@ -251,7 +251,7 @@ pub fn clock_time_get(
/// - `char *environ_buf` /// - `char *environ_buf`
/// A pointer to a buffer to write the environment variable string data. /// A pointer to a buffer to write the environment variable string data.
pub fn environ_get( pub fn environ_get(
env: &mut WasiEnv, env: &WasiEnv,
environ: WasmPtr<WasmPtr<u8, Array>, Array>, environ: WasmPtr<WasmPtr<u8, Array>, Array>,
environ_buf: WasmPtr<u8, Array>, environ_buf: WasmPtr<u8, Array>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -269,7 +269,7 @@ pub fn environ_get(
/// - `size_t *environ_buf_size` /// - `size_t *environ_buf_size`
/// The size of the environment variable string data. /// The size of the environment variable string data.
pub fn environ_sizes_get( pub fn environ_sizes_get(
env: &mut WasiEnv, env: &WasiEnv,
environ_count: WasmPtr<u32>, environ_count: WasmPtr<u32>,
environ_buf_size: WasmPtr<u32>, environ_buf_size: WasmPtr<u32>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -304,7 +304,7 @@ pub fn environ_sizes_get(
/// - `__wasi_advice_t advice` /// - `__wasi_advice_t advice`
/// The advice to give /// The advice to give
pub fn fd_advise( pub fn fd_advise(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
offset: __wasi_filesize_t, offset: __wasi_filesize_t,
len: __wasi_filesize_t, len: __wasi_filesize_t,
@@ -327,7 +327,7 @@ pub fn fd_advise(
/// - `__wasi_filesize_t len` /// - `__wasi_filesize_t len`
/// The length from the offset marking the end of the allocation /// The length from the offset marking the end of the allocation
pub fn fd_allocate( pub fn fd_allocate(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
offset: __wasi_filesize_t, offset: __wasi_filesize_t,
len: __wasi_filesize_t, len: __wasi_filesize_t,
@@ -372,7 +372,7 @@ pub fn fd_allocate(
/// If `fd` is a directory /// If `fd` is a directory
/// - `__WASI_EBADF` /// - `__WASI_EBADF`
/// 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: &WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
debug!("wasi::fd_close: fd={}", fd); debug!("wasi::fd_close: fd={}", fd);
let (memory, mut state) = env.get_memory_and_wasi_state(0); let (memory, mut state) = env.get_memory_and_wasi_state(0);
@@ -388,7 +388,7 @@ pub fn fd_close(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
/// Inputs: /// Inputs:
/// - `__wasi_fd_t fd` /// - `__wasi_fd_t fd`
/// 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: &WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
debug!("wasi::fd_datasync"); debug!("wasi::fd_datasync");
let (memory, mut 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));
@@ -412,7 +412,7 @@ pub fn fd_datasync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
/// - `__wasi_fdstat_t *buf` /// - `__wasi_fdstat_t *buf`
/// The location where the metadata will be written /// The location where the metadata will be written
pub fn fd_fdstat_get( pub fn fd_fdstat_get(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
buf_ptr: WasmPtr<__wasi_fdstat_t>, buf_ptr: WasmPtr<__wasi_fdstat_t>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -440,7 +440,7 @@ pub fn fd_fdstat_get(
/// - `__wasi_fdflags_t flags` /// - `__wasi_fdflags_t flags`
/// The flags to apply to `fd` /// The flags to apply to `fd`
pub fn fd_fdstat_set_flags( pub fn fd_fdstat_set_flags(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
flags: __wasi_fdflags_t, flags: __wasi_fdflags_t,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -466,7 +466,7 @@ pub fn fd_fdstat_set_flags(
/// - `__wasi_rights_t fs_rights_inheriting` /// - `__wasi_rights_t fs_rights_inheriting`
/// The inheriting rights to apply to `fd` /// The inheriting rights to apply to `fd`
pub fn fd_fdstat_set_rights( pub fn fd_fdstat_set_rights(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
fs_rights_base: __wasi_rights_t, fs_rights_base: __wasi_rights_t,
fs_rights_inheriting: __wasi_rights_t, fs_rights_inheriting: __wasi_rights_t,
@@ -497,7 +497,7 @@ pub fn fd_fdstat_set_rights(
/// - `__wasi_filestat_t *buf` /// - `__wasi_filestat_t *buf`
/// Where the metadata from `fd` will be written /// Where the metadata from `fd` will be written
pub fn fd_filestat_get( pub fn fd_filestat_get(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
buf: WasmPtr<__wasi_filestat_t>, buf: WasmPtr<__wasi_filestat_t>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -524,7 +524,7 @@ pub fn fd_filestat_get(
/// - `__wasi_filesize_t st_size` /// - `__wasi_filesize_t st_size`
/// New size that `fd` will be set to /// New size that `fd` will be set to
pub fn fd_filestat_set_size( pub fn fd_filestat_set_size(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
st_size: __wasi_filesize_t, st_size: __wasi_filesize_t,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -566,7 +566,7 @@ pub fn fd_filestat_set_size(
/// - `__wasi_fstflags_t fst_flags` /// - `__wasi_fstflags_t fst_flags`
/// Bit-vector for controlling which times get set /// Bit-vector for controlling which times get set
pub fn fd_filestat_set_times( pub fn fd_filestat_set_times(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
st_atim: __wasi_timestamp_t, st_atim: __wasi_timestamp_t,
st_mtim: __wasi_timestamp_t, st_mtim: __wasi_timestamp_t,
@@ -639,7 +639,7 @@ pub fn fd_filestat_set_times(
/// - `size_t nread` /// - `size_t nread`
/// The number of bytes read /// The number of bytes read
pub fn fd_pread( pub fn fd_pread(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
iovs: WasmPtr<__wasi_iovec_t, Array>, iovs: WasmPtr<__wasi_iovec_t, Array>,
iovs_len: u32, iovs_len: u32,
@@ -712,7 +712,7 @@ pub fn fd_pread(
/// - `__wasi_prestat *buf` /// - `__wasi_prestat *buf`
/// Where the metadata will be written /// Where the metadata will be written
pub fn fd_prestat_get( pub fn fd_prestat_get(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
buf: WasmPtr<__wasi_prestat_t>, buf: WasmPtr<__wasi_prestat_t>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -727,7 +727,7 @@ pub fn fd_prestat_get(
} }
pub fn fd_prestat_dir_name( pub fn fd_prestat_dir_name(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
path_len: u32, path_len: u32,
@@ -787,7 +787,7 @@ pub fn fd_prestat_dir_name(
/// - `u32 *nwritten` /// - `u32 *nwritten`
/// Number of bytes written /// Number of bytes written
pub fn fd_pwrite( pub fn fd_pwrite(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
iovs: WasmPtr<__wasi_ciovec_t, Array>, iovs: WasmPtr<__wasi_ciovec_t, Array>,
iovs_len: u32, iovs_len: u32,
@@ -873,7 +873,7 @@ pub fn fd_pwrite(
/// - `u32 *nread` /// - `u32 *nread`
/// Number of bytes read /// Number of bytes read
pub fn fd_read( pub fn fd_read(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
iovs: WasmPtr<__wasi_iovec_t, Array>, iovs: WasmPtr<__wasi_iovec_t, Array>,
iovs_len: u32, iovs_len: u32,
@@ -956,7 +956,7 @@ pub fn fd_read(
/// The Number of bytes stored in `buf`; if less than `buf_len` then entire /// The Number of bytes stored in `buf`; if less than `buf_len` then entire
/// directory has been read /// directory has been read
pub fn fd_readdir( pub fn fd_readdir(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
buf: WasmPtr<u8, Array>, buf: WasmPtr<u8, Array>,
buf_len: u32, buf_len: u32,
@@ -1072,7 +1072,7 @@ pub fn fd_readdir(
/// File descriptor to copy /// File descriptor to copy
/// - `__wasi_fd_t to` /// - `__wasi_fd_t to`
/// 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: &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, mut 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));
@@ -1100,7 +1100,7 @@ pub fn fd_renumber(env: &mut WasiEnv, from: __wasi_fd_t, to: __wasi_fd_t) -> __w
/// - `__wasi_filesize_t *fd` /// - `__wasi_filesize_t *fd`
/// The new offset relative to the start of the file /// The new offset relative to the start of the file
pub fn fd_seek( pub fn fd_seek(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
offset: __wasi_filedelta_t, offset: __wasi_filedelta_t,
whence: __wasi_whence_t, whence: __wasi_whence_t,
@@ -1168,7 +1168,7 @@ pub fn fd_seek(
/// TODO: figure out which errors this should return /// TODO: figure out which errors this should return
/// - `__WASI_EPERM` /// - `__WASI_EPERM`
/// - `__WASI_ENOTCAPABLE` /// - `__WASI_ENOTCAPABLE`
pub fn fd_sync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { pub fn fd_sync(env: &WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
debug!("wasi::fd_sync"); debug!("wasi::fd_sync");
debug!("=> fd={}", fd); debug!("=> fd={}", fd);
let (memory, mut state) = env.get_memory_and_wasi_state(0); let (memory, mut state) = env.get_memory_and_wasi_state(0);
@@ -1203,7 +1203,7 @@ pub fn fd_sync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t {
/// - `__wasi_filesize_t *offset` /// - `__wasi_filesize_t *offset`
/// The offset of `fd` relative to the start of the file /// The offset of `fd` relative to the start of the file
pub fn fd_tell( pub fn fd_tell(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
offset: WasmPtr<__wasi_filesize_t>, offset: WasmPtr<__wasi_filesize_t>,
) -> __wasi_errno_t { ) -> __wasi_errno_t {
@@ -1237,7 +1237,7 @@ pub fn fd_tell(
/// Errors: /// Errors:
/// ///
pub fn fd_write( pub fn fd_write(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
iovs: WasmPtr<__wasi_ciovec_t, Array>, iovs: WasmPtr<__wasi_ciovec_t, Array>,
iovs_len: u32, iovs_len: u32,
@@ -1333,7 +1333,7 @@ pub fn fd_write(
/// - __WASI_RIGHT_PATH_CREATE_DIRECTORY /// - __WASI_RIGHT_PATH_CREATE_DIRECTORY
/// This right must be set on the directory that the file is created in (TODO: verify that this is true) /// This right must be set on the directory that the file is created in (TODO: verify that this is true)
pub fn path_create_directory( pub fn path_create_directory(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
path_len: u32, path_len: u32,
@@ -1436,7 +1436,7 @@ pub fn path_create_directory(
/// - `__wasi_file_stat_t *buf` /// - `__wasi_file_stat_t *buf`
/// The location where the metadata will be stored /// The location where the metadata will be stored
pub fn path_filestat_get( pub fn path_filestat_get(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
flags: __wasi_lookupflags_t, flags: __wasi_lookupflags_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
@@ -1493,7 +1493,7 @@ pub fn path_filestat_get(
/// - `__wasi_fstflags_t fst_flags` /// - `__wasi_fstflags_t fst_flags`
/// A bitmask controlling which attributes are set /// A bitmask controlling which attributes are set
pub fn path_filestat_set_times( pub fn path_filestat_set_times(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
flags: __wasi_lookupflags_t, flags: __wasi_lookupflags_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
@@ -1581,7 +1581,7 @@ pub fn path_filestat_set_times(
/// - `u32 old_path_len` /// - `u32 old_path_len`
/// Length of the `new_path` string /// Length of the `new_path` string
pub fn path_link( pub fn path_link(
env: &mut WasiEnv, env: &WasiEnv,
old_fd: __wasi_fd_t, old_fd: __wasi_fd_t,
old_flags: __wasi_lookupflags_t, old_flags: __wasi_lookupflags_t,
old_path: WasmPtr<u8, Array>, old_path: WasmPtr<u8, Array>,
@@ -1664,7 +1664,7 @@ pub fn path_link(
/// Possible Errors: /// Possible Errors:
/// - `__WASI_EACCES`, `__WASI_EBADF`, `__WASI_EFAULT`, `__WASI_EFBIG?`, `__WASI_EINVAL`, `__WASI_EIO`, `__WASI_ELOOP`, `__WASI_EMFILE`, `__WASI_ENAMETOOLONG?`, `__WASI_ENFILE`, `__WASI_ENOENT`, `__WASI_ENOTDIR`, `__WASI_EROFS`, and `__WASI_ENOTCAPABLE` /// - `__WASI_EACCES`, `__WASI_EBADF`, `__WASI_EFAULT`, `__WASI_EFBIG?`, `__WASI_EINVAL`, `__WASI_EIO`, `__WASI_ELOOP`, `__WASI_EMFILE`, `__WASI_ENAMETOOLONG?`, `__WASI_ENFILE`, `__WASI_ENOENT`, `__WASI_ENOTDIR`, `__WASI_EROFS`, and `__WASI_ENOTCAPABLE`
pub fn path_open( pub fn path_open(
env: &mut WasiEnv, env: &WasiEnv,
dirfd: __wasi_fd_t, dirfd: __wasi_fd_t,
dirflags: __wasi_lookupflags_t, dirflags: __wasi_lookupflags_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
@@ -1901,7 +1901,7 @@ pub fn path_open(
/// - `u32 buf_used` /// - `u32 buf_used`
/// The number of bytes written to `buf` /// The number of bytes written to `buf`
pub fn path_readlink( pub fn path_readlink(
env: &mut WasiEnv, env: &WasiEnv,
dir_fd: __wasi_fd_t, dir_fd: __wasi_fd_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
path_len: u32, path_len: u32,
@@ -1946,7 +1946,7 @@ pub fn path_readlink(
/// Returns __WASI_ENOTEMTPY if directory is not empty /// Returns __WASI_ENOTEMTPY if directory is not empty
pub fn path_remove_directory( pub fn path_remove_directory(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
path_len: u32, path_len: u32,
@@ -2022,7 +2022,7 @@ pub fn path_remove_directory(
/// - `u32 new_path_len` /// - `u32 new_path_len`
/// The number of bytes to read from `new_path` /// The number of bytes to read from `new_path`
pub fn path_rename( pub fn path_rename(
env: &mut WasiEnv, env: &WasiEnv,
old_fd: __wasi_fd_t, old_fd: __wasi_fd_t,
old_path: WasmPtr<u8, Array>, old_path: WasmPtr<u8, Array>,
old_path_len: u32, old_path_len: u32,
@@ -2133,7 +2133,7 @@ pub fn path_rename(
/// - `u32 new_path_len` /// - `u32 new_path_len`
/// The number of bytes to read from `new_path` /// The number of bytes to read from `new_path`
pub fn path_symlink( pub fn path_symlink(
env: &mut WasiEnv, env: &WasiEnv,
old_path: WasmPtr<u8, Array>, old_path: WasmPtr<u8, Array>,
old_path_len: u32, old_path_len: u32,
fd: __wasi_fd_t, fd: __wasi_fd_t,
@@ -2212,7 +2212,7 @@ pub fn path_symlink(
/// - `u32 path_len` /// - `u32 path_len`
/// The number of bytes in the `path` array /// The number of bytes in the `path` array
pub fn path_unlink_file( pub fn path_unlink_file(
env: &mut WasiEnv, env: &WasiEnv,
fd: __wasi_fd_t, fd: __wasi_fd_t,
path: WasmPtr<u8, Array>, path: WasmPtr<u8, Array>,
path_len: u32, path_len: u32,
@@ -2306,7 +2306,7 @@ pub fn path_unlink_file(
/// - `u32 nevents` /// - `u32 nevents`
/// The number of events seen /// The number of events seen
pub fn poll_oneoff( pub fn poll_oneoff(
env: &mut WasiEnv, env: &WasiEnv,
in_: WasmPtr<__wasi_subscription_t, Array>, in_: WasmPtr<__wasi_subscription_t, Array>,
out_: WasmPtr<__wasi_event_t, Array>, out_: WasmPtr<__wasi_event_t, Array>,
nsubscriptions: u32, nsubscriptions: u32,
@@ -2492,13 +2492,13 @@ pub fn poll_oneoff(
__WASI_ESUCCESS __WASI_ESUCCESS
} }
pub fn proc_exit(env: &mut WasiEnv, code: __wasi_exitcode_t) { pub fn proc_exit(env: &WasiEnv, code: __wasi_exitcode_t) {
debug!("wasi::proc_exit, {}", code); debug!("wasi::proc_exit, {}", code);
RuntimeError::raise(Box::new(WasiError::Exit(code))); RuntimeError::raise(Box::new(WasiError::Exit(code)));
unreachable!(); unreachable!();
} }
pub fn proc_raise(env: &mut WasiEnv, sig: __wasi_signal_t) -> __wasi_errno_t { pub fn proc_raise(env: &WasiEnv, sig: __wasi_signal_t) -> __wasi_errno_t {
debug!("wasi::proc_raise"); debug!("wasi::proc_raise");
unimplemented!("wasi::proc_raise") unimplemented!("wasi::proc_raise")
} }
@@ -2510,7 +2510,7 @@ pub fn proc_raise(env: &mut WasiEnv, sig: __wasi_signal_t) -> __wasi_errno_t {
/// A pointer to a buffer where the random bytes will be written /// A pointer to a buffer where the random bytes will be written
/// - `size_t buf_len` /// - `size_t buf_len`
/// The number of bytes that will be written /// The number of bytes that will be written
pub fn random_get(env: &mut WasiEnv, buf: WasmPtr<u8, Array>, buf_len: u32) -> __wasi_errno_t { pub fn random_get(env: &WasiEnv, buf: WasmPtr<u8, Array>, buf_len: u32) -> __wasi_errno_t {
debug!("wasi::random_get buf_len: {}", buf_len); debug!("wasi::random_get buf_len: {}", buf_len);
let memory = env.memory(); let memory = env.memory();
@@ -2528,14 +2528,14 @@ pub fn random_get(env: &mut WasiEnv, buf: WasmPtr<u8, Array>, buf_len: u32) -> _
/// ### `sched_yield()` /// ### `sched_yield()`
/// Yields execution of the thread /// Yields execution of the thread
pub fn sched_yield(env: &mut WasiEnv) -> __wasi_errno_t { pub fn sched_yield(env: &WasiEnv) -> __wasi_errno_t {
debug!("wasi::sched_yield"); debug!("wasi::sched_yield");
::std::thread::yield_now(); ::std::thread::yield_now();
__WASI_ESUCCESS __WASI_ESUCCESS
} }
pub fn sock_recv( pub fn sock_recv(
env: &mut WasiEnv, env: &WasiEnv,
sock: __wasi_fd_t, sock: __wasi_fd_t,
ri_data: WasmPtr<__wasi_iovec_t, Array>, ri_data: WasmPtr<__wasi_iovec_t, Array>,
ri_data_len: u32, ri_data_len: u32,
@@ -2547,7 +2547,7 @@ pub fn sock_recv(
unimplemented!("wasi::sock_recv") unimplemented!("wasi::sock_recv")
} }
pub fn sock_send( pub fn sock_send(
env: &mut WasiEnv, env: &WasiEnv,
sock: __wasi_fd_t, sock: __wasi_fd_t,
si_data: WasmPtr<__wasi_ciovec_t, Array>, si_data: WasmPtr<__wasi_ciovec_t, Array>,
si_data_len: u32, si_data_len: u32,
@@ -2557,11 +2557,7 @@ pub fn sock_send(
debug!("wasi::sock_send"); debug!("wasi::sock_send");
unimplemented!("wasi::sock_send") unimplemented!("wasi::sock_send")
} }
pub fn sock_shutdown( pub fn sock_shutdown(env: &WasiEnv, sock: __wasi_fd_t, how: __wasi_sdflags_t) -> __wasi_errno_t {
env: &mut WasiEnv,
sock: __wasi_fd_t,
how: __wasi_sdflags_t,
) -> __wasi_errno_t {
debug!("wasi::sock_shutdown"); debug!("wasi::sock_shutdown");
unimplemented!("wasi::sock_shutdown") unimplemented!("wasi::sock_shutdown")
} }

View File

@@ -208,20 +208,20 @@ fn static_function_with_env() -> Result<()> {
&module, &module,
&imports! { &imports! {
"host" => { "host" => {
"0" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc<AtomicUsize>| { "0" => Function::new_native_with_env(&store, env.clone(), |env: &Arc<AtomicUsize>| {
assert_eq!(env.fetch_add(1, SeqCst), 0); assert_eq!(env.fetch_add(1, SeqCst), 0);
}), }),
"1" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc<AtomicUsize>, x: i32| -> i32 { "1" => Function::new_native_with_env(&store, env.clone(), |env: &Arc<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_native_with_env(&store, env.clone(), |env: &mut Arc<AtomicUsize>, x: i32, y: i64| { "2" => Function::new_native_with_env(&store, env.clone(), |env: &Arc<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_native_with_env(&store, env.clone(), |env: &mut Arc<AtomicUsize>, a: i32, b: i64, c: i32, d: f32, e: f64| { "3" => Function::new_native_with_env(&store, env.clone(), |env: &Arc<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);

View File

@@ -85,20 +85,14 @@ fn static_host_function_without_env() -> anyhow::Result<()> {
fn static_host_function_with_env() -> anyhow::Result<()> { fn static_host_function_with_env() -> anyhow::Result<()> {
let store = get_store(false); let store = get_store(false);
fn f(env: &mut Env, a: i32, b: i64, c: f32, d: f64) -> (f64, f32, i64, i32) { fn f(env: &Env, a: i32, b: i64, c: f32, d: f64) -> (f64, f32, i64, i32) {
assert_eq!(*env.0.borrow(), 100); assert_eq!(*env.0.borrow(), 100);
env.0.replace(101); env.0.replace(101);
(d * 4.0, c * 3.0, b * 2, a * 1) (d * 4.0, c * 3.0, b * 2, a * 1)
} }
fn f_ok( fn f_ok(env: &Env, a: i32, b: i64, c: f32, d: f64) -> Result<(f64, f32, i64, i32), Infallible> {
env: &mut Env,
a: i32,
b: i64,
c: f32,
d: f64,
) -> Result<(f64, f32, i64, i32), Infallible> {
assert_eq!(*env.0.borrow(), 100); assert_eq!(*env.0.borrow(), 100);
env.0.replace(101); env.0.replace(101);