diff --git a/benches/static_and_dynamic_functions.rs b/benches/static_and_dynamic_functions.rs index 35ae4926fab..b5575696270 100644 --- a/benches/static_and_dynamic_functions.rs +++ b/benches/static_and_dynamic_functions.rs @@ -36,7 +36,7 @@ pub fn run_basic_static_function(store: &Store, compiler_name: &str, c: &mut Cri let module = Module::new(&store, BASIC_WAT).unwrap(); let import_object = imports! { "env" => { - "multiply" => Function::new(&store, |a: i32, b: i32| a * b), + "multiply" => Function::new_native(&store, |a: i32, b: i32| a * b), }, }; let instance = Instance::new(&module, &import_object).unwrap(); @@ -97,7 +97,7 @@ pub fn run_basic_dynamic_function(store: &Store, compiler_name: &str, c: &mut Cr let module = Module::new(&store, BASIC_WAT).unwrap(); let import_object = imports! { "env" => { - "multiply" => Function::new(&store, |a: i32, b: i32| a * b), + "multiply" => Function::new_native(&store, |a: i32, b: i32| a * b), }, }; let instance = Instance::new(&module, &import_object).unwrap(); diff --git a/lib/api/src/externals/function.rs b/lib/api/src/externals/function.rs index 92506595150..fd86c106a8e 100644 --- a/lib/api/src/externals/function.rs +++ b/lib/api/src/externals/function.rs @@ -56,85 +56,23 @@ pub struct Function { } impl Function { - /// Creates a new host `Function` that is: + /// Creates a new host `Function` (dynamic) with the provided signature. /// - /// 1. Static/Monomorphic, i.e. all inputs and outputs have a - /// unique _statically declared type_. The outputs can be - /// wrapped in a `Result`. - /// 2. Independent, i.e. the function _does not_ receive an - /// environment argument. - pub fn new(store: &Store, func: F) -> Self - where - F: HostFunction, - Args: WasmTypeList, - Rets: WasmTypeList, - Env: Sized + 'static, - { - let function = inner::Function::::new(func); - let address = function.address() as *const VMFunctionBody; - let vmctx = std::ptr::null_mut() as *mut _ as *mut VMContext; - let signature = function.ty(); - - Self { - store: store.clone(), - definition: FunctionDefinition::Host(HostFunctionDefinition { has_env: false }), - exported: ExportFunction { - address, - vmctx, - signature, - kind: VMFunctionKind::Static, - }, - } - } - - /// Creates a new host `Function` that is: + /// # Example /// - /// 1. Static/Monomorphic, i.e. all inputs and outputs have a - /// unique statically declared type. The outputs can be wrapped - /// in a `Result`. - /// 2. Dependent, i.e. the function _does_ receive an environment - /// argument (given by `env`). - pub fn new_env(store: &Store, env: Env, func: F) -> Self - where - F: HostFunction, - Args: WasmTypeList, - Rets: WasmTypeList, - Env: Sized + 'static, - { - let function = inner::Function::::new(func); - let address = function.address(); - - // TODO: We need to refactor the Function context. - // Right now is structured as it's always a `VMContext`. However, only - // Wasm-defined functions have a `VMContext`. - // In the case of Host-defined functions `VMContext` is whatever environment - // the user want to attach to the function. - let box_env = Box::new(env); - let vmctx = Box::into_raw(box_env) as *mut _ as *mut VMContext; - let signature = function.ty(); - - Self { - store: store.clone(), - definition: FunctionDefinition::Host(HostFunctionDefinition { has_env: true }), - exported: ExportFunction { - address, - kind: VMFunctionKind::Static, - vmctx, - signature, - }, - } - } - - /// Creates a new host `Function` that is: + /// ``` + /// # use wasmer::{Function, FunctionType, Type, Store, Value}; + /// # let store = Store::default(); + /// + /// let signature = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); /// - /// 1. Dynamic/Polymorphic, i.e. all inputs are received in a - /// slice of `Val` (the set of all Wasm values), and all - /// outputs are stored in a vector of `Val`, wrapped in a - /// `Result`. - /// 2. Independent, i.e. the function _does not_ receive an - /// environment argument. + /// let f = Function::new(&store, &signature, |args| { + /// let sum = args[0].unwrap_i32() + args[1].unwrap_i32(); + /// Ok(vec![Value::I32(sum)]) + /// }); + /// ``` #[allow(clippy::cast_ptr_alignment)] - pub fn new_dynamic(store: &Store, ty: &FunctionType, func: F) -> Self + pub fn new(store: &Store, ty: &FunctionType, func: F) -> Self where F: Fn(&[Val]) -> Result, RuntimeError> + 'static, { @@ -160,16 +98,28 @@ impl Function { } } - /// Creates a new host `Function` that is: + /// Creates a new host `Function` (dynamic) with the provided signature and environment. /// - /// 1. Dynamic/Polymorphic, i.e. all inputs are received in a - /// slice of `Val` (the set of all Wasm values), and all - /// outputs are stored in a vector of `Val`, wrapped in a - /// `Result`. - /// 2. Dependent, i.e. the function _does_ receive an environment - /// argument (given by `env`). + /// # Example + /// + /// ``` + /// # use wasmer::{Function, FunctionType, Type, Store, Value}; + /// # let store = Store::default(); + /// + /// struct Env { + /// multiplier: i32, + /// }; + /// let env = Env { multiplier: 2 }; + /// + /// let signature = FunctionType::new(vec![Type::I32, Type::I32], vec![Type::I32]); + /// + /// let f = Function::new_with_env(&store, &signature, env, |env, args| { + /// let result = env.multiplier * (args[0].unwrap_i32() + args[1].unwrap_i32()); + /// Ok(vec![Value::I32(result)]) + /// }); + /// ``` #[allow(clippy::cast_ptr_alignment)] - pub fn new_dynamic_env(store: &Store, ty: &FunctionType, env: Env, func: F) -> Self + pub fn new_with_env(store: &Store, ty: &FunctionType, env: Env, func: F) -> Self where F: Fn(&mut Env, &[Val]) -> Result, RuntimeError> + 'static, Env: Sized + 'static, @@ -197,6 +147,99 @@ impl Function { } } + /// Creates a new host `Function` from a native function. + /// + /// The function signature is automatically retrieved using the + /// Rust typing system. + /// + /// # Example + /// + /// ``` + /// # use wasmer::{Store, Function}; + /// # let store = Store::default(); + /// + /// fn sum(a: i32, b: i32) -> i32 { + /// a + b + /// } + /// + /// let f = Function::new_native(&store, sum); + /// ``` + pub fn new_native(store: &Store, func: F) -> Self + where + F: HostFunction, + Args: WasmTypeList, + Rets: WasmTypeList, + Env: Sized + 'static, + { + let function = inner::Function::::new(func); + let address = function.address() as *const VMFunctionBody; + let vmctx = std::ptr::null_mut() as *mut _ as *mut VMContext; + let signature = function.ty(); + + Self { + store: store.clone(), + definition: FunctionDefinition::Host(HostFunctionDefinition { has_env: false }), + exported: ExportFunction { + address, + vmctx, + signature, + kind: VMFunctionKind::Static, + }, + } + } + + /// Creates a new host `Function` from a native function and a provided environment. + /// + /// The function signature is automatically retrieved using the + /// Rust typing system. + /// + /// # Example + /// + /// ``` + /// # use wasmer::{Store, Function}; + /// # let store = Store::default(); + /// + /// struct Env { + /// multiplier: i32, + /// }; + /// let env = Env { multiplier: 2 }; + /// + /// fn sum_and_multiply(env: &mut Env, a: i32, b: i32) -> i32 { + /// (a + b) * env.multiplier + /// } + /// + /// let f = Function::new_native_with_env(&store, env, sum_and_multiply); + /// ``` + pub fn new_native_with_env(store: &Store, env: Env, func: F) -> Self + where + F: HostFunction, + Args: WasmTypeList, + Rets: WasmTypeList, + Env: Sized + 'static, + { + let function = inner::Function::::new(func); + let address = function.address(); + + // TODO: We need to refactor the Function context. + // Right now is structured as it's always a `VMContext`. However, only + // Wasm-defined functions have a `VMContext`. + // In the case of Host-defined functions `VMContext` is whatever environment + // the user want to attach to the function. + let box_env = Box::new(env); + let vmctx = Box::into_raw(box_env) as *mut _ as *mut VMContext; + let signature = function.ty(); + + Self { + store: store.clone(), + definition: FunctionDefinition::Host(HostFunctionDefinition { has_env: true }), + exported: ExportFunction { + address, + kind: VMFunctionKind::Static, + vmctx, + signature, + }, + } + } /// Returns the [`FunctionType`] of the `Function`. pub fn ty(&self) -> &FunctionType { &self.exported.signature diff --git a/lib/api/src/import_object.rs b/lib/api/src/import_object.rs index 46f39f0bf9c..c2ceb09ffbc 100644 --- a/lib/api/src/import_object.rs +++ b/lib/api/src/import_object.rs @@ -34,7 +34,7 @@ pub trait LikeNamespace { /// let mut import_object = ImportObject::new(); /// let mut env = Exports::new(); /// -/// env.insert("foo", Function::new(foo)); +/// env.insert("foo", Function::new_native(foo)); /// import_object.register("env", env); /// /// fn foo(n: i32) -> i32 { @@ -160,7 +160,7 @@ impl IntoIterator for ImportObject { /// /// let import_object = imports! { /// "env" => { -/// "foo" => Function::new(&store, foo) +/// "foo" => Function::new_native(&store, foo) /// }, /// }; /// @@ -336,42 +336,42 @@ mod test { let _ = imports! { "env" => { - "func" => Function::new(&store, func), + "func" => Function::new_native(&store, func), }, }; let _ = imports! { "env" => { - "func" => Function::new(&store, func), + "func" => Function::new_native(&store, func), } }; let _ = imports! { "env" => { - "func" => Function::new(&store, func), + "func" => Function::new_native(&store, func), }, "abc" => { - "def" => Function::new(&store, func), + "def" => Function::new_native(&store, func), } }; let _ = imports! { "env" => { - "func" => Function::new(&store, func) + "func" => Function::new_native(&store, func) }, }; let _ = imports! { "env" => { - "func" => Function::new(&store, func) + "func" => Function::new_native(&store, func) } }; let _ = imports! { "env" => { - "func1" => Function::new(&store, func), - "func2" => Function::new(&store, func) + "func1" => Function::new_native(&store, func), + "func2" => Function::new_native(&store, func) } }; let _ = imports! { "env" => { - "func1" => Function::new(&store, func), - "func2" => Function::new(&store, func), + "func1" => Function::new_native(&store, func), + "func2" => Function::new_native(&store, func), } }; } diff --git a/lib/api/tests/externals.rs b/lib/api/tests/externals.rs index 87c19ccbc7c..49fdc6f0772 100644 --- a/lib/api/tests/externals.rs +++ b/lib/api/tests/externals.rs @@ -66,7 +66,7 @@ fn table_new() -> Result<()> { minimum: 0, maximum: None, }; - let f = Function::new(&store, || {}); + let f = Function::new_native(&store, || {}); let table = Table::new(&store, table_type, Value::FuncRef(f))?; assert_eq!(*table.ty(), table_type); @@ -91,7 +91,7 @@ fn table_get() -> Result<()> { minimum: 0, maximum: Some(1), }; - let f = Function::new(&store, |num: i32| num + 1); + let f = Function::new_native(&store, |num: i32| num + 1); let table = Table::new(&store, table_type, Value::FuncRef(f.clone()))?; assert_eq!(*table.ty(), table_type); let _elem = table.get(0).unwrap(); @@ -114,7 +114,7 @@ fn table_grow() -> Result<()> { minimum: 0, maximum: Some(10), }; - let f = Function::new(&store, |num: i32| num + 1); + let f = Function::new_native(&store, |num: i32| num + 1); let table = Table::new(&store, table_type, Value::FuncRef(f.clone()))?; // Growing to a bigger maximum should return None let old_len = table.grow(12, Value::FuncRef(f.clone())); @@ -180,24 +180,24 @@ fn memory_grow() -> Result<()> { #[test] fn function_new() -> Result<()> { let store = Store::default(); - let function = Function::new(&store, || {}); + let function = Function::new_native(&store, || {}); assert_eq!(function.ty().clone(), FunctionType::new(vec![], vec![])); - let function = Function::new(&store, |_a: i32| {}); + let function = Function::new_native(&store, |_a: i32| {}); assert_eq!( function.ty().clone(), FunctionType::new(vec![Type::I32], vec![]) ); - let function = Function::new(&store, |_a: i32, _b: i64, _c: f32, _d: f64| {}); + let function = Function::new_native(&store, |_a: i32, _b: i64, _c: f32, _d: f64| {}); assert_eq!( function.ty().clone(), FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]) ); - let function = Function::new(&store, || -> i32 { 1 }); + let function = Function::new_native(&store, || -> i32 { 1 }); assert_eq!( function.ty().clone(), FunctionType::new(vec![], vec![Type::I32]) ); - let function = Function::new(&store, || -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }); + let function = Function::new_native(&store, || -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }); assert_eq!( function.ty().clone(), FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]) @@ -211,14 +211,15 @@ fn function_new_env() -> Result<()> { #[derive(Clone)] struct MyEnv {}; let my_env = MyEnv {}; - let function = Function::new_env(&store, my_env.clone(), |_env: &mut MyEnv| {}); + let function = Function::new_native_with_env(&store, my_env.clone(), |_env: &mut MyEnv| {}); assert_eq!(function.ty().clone(), FunctionType::new(vec![], vec![])); - let function = Function::new_env(&store, my_env.clone(), |_env: &mut MyEnv, _a: i32| {}); + let function = + Function::new_native_with_env(&store, my_env.clone(), |_env: &mut MyEnv, _a: i32| {}); assert_eq!( function.ty().clone(), FunctionType::new(vec![Type::I32], vec![]) ); - let function = Function::new_env( + let function = Function::new_native_with_env( &store, my_env.clone(), |_env: &mut MyEnv, _a: i32, _b: i64, _c: f32, _d: f64| {}, @@ -227,12 +228,13 @@ fn function_new_env() -> Result<()> { function.ty().clone(), FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]) ); - let function = Function::new_env(&store, my_env.clone(), |_env: &mut MyEnv| -> i32 { 1 }); + let function = + Function::new_native_with_env(&store, my_env.clone(), |_env: &mut MyEnv| -> i32 { 1 }); assert_eq!( function.ty().clone(), FunctionType::new(vec![], vec![Type::I32]) ); - let function = Function::new_env( + let function = Function::new_native_with_env( &store, my_env.clone(), |_env: &mut MyEnv| -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }, @@ -248,24 +250,19 @@ fn function_new_env() -> Result<()> { fn function_new_dynamic() -> Result<()> { let store = Store::default(); let function_type = FunctionType::new(vec![], vec![]); - let function = - Function::new_dynamic(&store, &function_type, |_values: &[Value]| unimplemented!()); + let function = Function::new(&store, &function_type, |_values: &[Value]| unimplemented!()); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![Type::I32], vec![]); - let function = - Function::new_dynamic(&store, &function_type, |_values: &[Value]| unimplemented!()); + let function = Function::new(&store, &function_type, |_values: &[Value]| unimplemented!()); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]); - let function = - Function::new_dynamic(&store, &function_type, |_values: &[Value]| unimplemented!()); + let function = Function::new(&store, &function_type, |_values: &[Value]| unimplemented!()); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32]); - let function = - Function::new_dynamic(&store, &function_type, |_values: &[Value]| unimplemented!()); + let function = Function::new(&store, &function_type, |_values: &[Value]| unimplemented!()); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]); - let function = - Function::new_dynamic(&store, &function_type, |_values: &[Value]| unimplemented!()); + let function = Function::new(&store, &function_type, |_values: &[Value]| unimplemented!()); assert_eq!(function.ty().clone(), function_type); Ok(()) } @@ -278,7 +275,7 @@ fn function_new_dynamic_env() -> Result<()> { let my_env = MyEnv {}; let function_type = FunctionType::new(vec![], vec![]); - let function = Function::new_dynamic_env( + let function = Function::new_with_env( &store, &function_type, my_env.clone(), @@ -286,7 +283,7 @@ fn function_new_dynamic_env() -> Result<()> { ); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![Type::I32], vec![]); - let function = Function::new_dynamic_env( + let function = Function::new_with_env( &store, &function_type, my_env.clone(), @@ -294,7 +291,7 @@ fn function_new_dynamic_env() -> Result<()> { ); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![Type::I32, Type::I64, Type::F32, Type::F64], vec![]); - let function = Function::new_dynamic_env( + let function = Function::new_with_env( &store, &function_type, my_env.clone(), @@ -302,7 +299,7 @@ fn function_new_dynamic_env() -> Result<()> { ); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32]); - let function = Function::new_dynamic_env( + let function = Function::new_with_env( &store, &function_type, my_env.clone(), @@ -310,7 +307,7 @@ fn function_new_dynamic_env() -> Result<()> { ); assert_eq!(function.ty().clone(), function_type); let function_type = FunctionType::new(vec![], vec![Type::I32, Type::I64, Type::F32, Type::F64]); - let function = Function::new_dynamic_env( + let function = Function::new_with_env( &store, &function_type, my_env.clone(), @@ -323,13 +320,13 @@ fn function_new_dynamic_env() -> Result<()> { #[test] fn native_function_works() -> Result<()> { let store = Store::default(); - let function = Function::new(&store, || {}); + let function = Function::new_native(&store, || {}); let native_function: NativeFunc<(), ()> = function.native().unwrap(); let result = native_function.call(); assert!(result.is_ok()); // TODO: - /*let function = Function::new(&store, |a: i32| -> i32 { a + 1 }); + /*let function = Function::new_native(&store, |a: i32| -> i32 { a + 1 }); let native_function: NativeFunc = function.native().unwrap(); assert!(native_function.call(3).unwrap(), 4); */ @@ -337,21 +334,21 @@ fn native_function_works() -> Result<()> { fn rust_abi(a: i32, b: i64, c: f32, d: f64) -> u64 { (a as u64 * 1000) + (b as u64 * 100) + (c as u64 * 10) + (d as u64) } - let function = Function::new(&store, rust_abi); + let function = Function::new_native(&store, rust_abi); let native_function: NativeFunc<(i32, i64, f32, f64), u64> = function.native().unwrap(); assert_eq!(native_function.call(8, 4, 1.5, 5.).unwrap(), 8415); - let function = Function::new(&store, || -> i32 { 1 }); + let function = Function::new_native(&store, || -> i32 { 1 }); let native_function: NativeFunc<(), i32> = function.native().unwrap(); assert_eq!(native_function.call().unwrap(), 1); // TODO: - /*let function = Function::new(&store, |_a: i32| {}); + /*let function = Function::new_native(&store, |_a: i32| {}); let native_function: NativeFunc = function.native().unwrap(); assert!(native_function.call(4).is_ok());*/ // TODO: - /*let function = Function::new(&store, || -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }); + /*let function = Function::new_native(&store, || -> (i32, i64, f32, f64) { (1, 2, 3.0, 4.0) }); let native_function: NativeFunc<(), (i32, i64, f32, f64)> = function.native().unwrap(); assert_eq!(native_function.call().unwrap(), (1, 2, 3.0, 4.0)); */ diff --git a/lib/c-api/src/import/mod.rs b/lib/c-api/src/import/mod.rs index 480a6e9e351..d9fab34eeba 100644 --- a/lib/c-api/src/import/mod.rs +++ b/lib/c-api/src/import/mod.rs @@ -691,7 +691,7 @@ pub unsafe extern "C" fn wasmer_import_func_new( let env_ptr = Box::into_raw(Box::new(LegacyEnv::default())); - let func = Function::new_dynamic_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::low::CodePtr; diff --git a/lib/c-api/src/wasm_c_api.rs b/lib/c-api/src/wasm_c_api.rs index 8f581e7968b..0b51be5c1de 100644 --- a/lib/c-api/src/wasm_c_api.rs +++ b/lib/c-api/src/wasm_c_api.rs @@ -714,7 +714,7 @@ pub unsafe extern "C" fn wasm_func_new( .expect("Result conversion failed"); Ok(processed_results) }; - let f = Function::new_dynamic(store, &func_sig, inner_callback); + let f = Function::new(store, &func_sig, inner_callback); Some(Box::new(wasm_func_t { instance: None, inner: f, @@ -760,7 +760,7 @@ pub unsafe extern "C" fn wasm_func_new_with_env( .expect("Result conversion failed"); Ok(processed_results) }; - let f = Function::new_dynamic_env(store, &func_sig, env, inner_callback); + let f = Function::new_with_env(store, &func_sig, env, inner_callback); Some(Box::new(wasm_func_t { instance: None, inner: f, diff --git a/lib/compiler/src/function.rs b/lib/compiler/src/function.rs index a855cf8a49c..1a4c9f1de53 100644 --- a/lib/compiler/src/function.rs +++ b/lib/compiler/src/function.rs @@ -130,7 +130,7 @@ pub struct Compilation { /// let my_func_type = FunctionType::new(vec![Type::I32], vec![Type::I32]); /// let imports = imports!{ /// "namespace" => { - /// "my_func" => Function::new_dynamic(&store, my_func_type, my_func), + /// "my_func" => Function::new(&store, my_func_type, my_func), /// } /// } /// ``` diff --git a/lib/deprecated/runtime-core/src/typed_func.rs b/lib/deprecated/runtime-core/src/typed_func.rs index 22e4b11f446..7e1eeb690c6 100644 --- a/lib/deprecated/runtime-core/src/typed_func.rs +++ b/lib/deprecated/runtime-core/src/typed_func.rs @@ -248,7 +248,7 @@ impl DynamicFunc { }; Self { - new_function: new::wasmer::Function::new_dynamic_env( + new_function: new::wasmer::Function::new_with_env( &get_global_store(), signature, ctx, diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 89f7b63c801..9d086bb0986 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -648,13 +648,13 @@ pub fn generate_emscripten_env( env: &mut EmEnv, ) -> ImportObject { let abort_on_cannot_grow_memory_export = if globals.data.use_old_abort_on_cannot_grow_memory { - Function::new_env( + Function::new_native_with_env( store, env.clone(), crate::memory::abort_on_cannot_grow_memory_old, ) } else { - Function::new_env( + Function::new_native_with_env( store, env.clone(), crate::memory::abort_on_cannot_grow_memory, @@ -679,427 +679,427 @@ pub fn generate_emscripten_env( "tempDoublePtr" => Global::new(store, Val::I32(globals.data.temp_double_ptr as i32)), // inet - "_inet_addr" => Function::new_env(store, env.clone(), crate::inet::addr), + "_inet_addr" => Function::new_native_with_env(store, env.clone(), crate::inet::addr), // IO - "printf" => Function::new_env(store, env.clone(), crate::io::printf), - "putchar" => Function::new_env(store, env.clone(), crate::io::putchar), - "___lock" => Function::new_env(store, env.clone(), crate::lock::___lock), - "___unlock" => Function::new_env(store, env.clone(), crate::lock::___unlock), - "___wait" => Function::new_env(store, env.clone(), crate::lock::___wait), - "_flock" => Function::new_env(store, env.clone(), crate::lock::_flock), - "_chroot" => Function::new_env(store, env.clone(), crate::io::chroot), - "_getprotobyname" => Function::new_env(store, env.clone(), crate::io::getprotobyname), - "_getprotobynumber" => Function::new_env(store, env.clone(), crate::io::getprotobynumber), - "_getpwuid" => Function::new_env(store, env.clone(), crate::io::getpwuid), - "_sigdelset" => Function::new_env(store, env.clone(), crate::io::sigdelset), - "_sigfillset" => Function::new_env(store, env.clone(), crate::io::sigfillset), - "_tzset" => Function::new_env(store, env.clone(), crate::io::tzset), - "_strptime" => Function::new_env(store, env.clone(), crate::io::strptime), + "printf" => Function::new_native_with_env(store, env.clone(), crate::io::printf), + "putchar" => Function::new_native_with_env(store, env.clone(), crate::io::putchar), + "___lock" => Function::new_native_with_env(store, env.clone(), crate::lock::___lock), + "___unlock" => Function::new_native_with_env(store, env.clone(), crate::lock::___unlock), + "___wait" => Function::new_native_with_env(store, env.clone(), crate::lock::___wait), + "_flock" => Function::new_native_with_env(store, env.clone(), crate::lock::_flock), + "_chroot" => Function::new_native_with_env(store, env.clone(), crate::io::chroot), + "_getprotobyname" => Function::new_native_with_env(store, env.clone(), crate::io::getprotobyname), + "_getprotobynumber" => Function::new_native_with_env(store, env.clone(), crate::io::getprotobynumber), + "_getpwuid" => Function::new_native_with_env(store, env.clone(), crate::io::getpwuid), + "_sigdelset" => Function::new_native_with_env(store, env.clone(), crate::io::sigdelset), + "_sigfillset" => Function::new_native_with_env(store, env.clone(), crate::io::sigfillset), + "_tzset" => Function::new_native_with_env(store, env.clone(), crate::io::tzset), + "_strptime" => Function::new_native_with_env(store, env.clone(), crate::io::strptime), // exec - "_execvp" => Function::new_env(store, env.clone(), crate::exec::execvp), - "_execl" => Function::new_env(store, env.clone(), crate::exec::execl), - "_execle" => Function::new_env(store, env.clone(), crate::exec::execle), + "_execvp" => Function::new_native_with_env(store, env.clone(), crate::exec::execvp), + "_execl" => Function::new_native_with_env(store, env.clone(), crate::exec::execl), + "_execle" => Function::new_native_with_env(store, env.clone(), crate::exec::execle), // exit - "__exit" => Function::new_env(store, env.clone(), crate::exit::exit), + "__exit" => Function::new_native_with_env(store, env.clone(), crate::exit::exit), // Env - "___assert_fail" => Function::new_env(store, env.clone(), crate::env::___assert_fail), - "_getenv" => Function::new_env(store, env.clone(), crate::env::_getenv), - "_setenv" => Function::new_env(store, env.clone(), crate::env::_setenv), - "_putenv" => Function::new_env(store, env.clone(), crate::env::_putenv), - "_unsetenv" => Function::new_env(store, env.clone(), crate::env::_unsetenv), - "_getpwnam" => Function::new_env(store, env.clone(), crate::env::_getpwnam), - "_getgrnam" => Function::new_env(store, env.clone(), crate::env::_getgrnam), - "___buildEnvironment" => Function::new_env(store, env.clone(), crate::env::___build_environment), - "___setErrNo" => Function::new_env(store, env.clone(), crate::errno::___seterrno), - "_getpagesize" => Function::new_env(store, env.clone(), crate::env::_getpagesize), - "_sysconf" => Function::new_env(store, env.clone(), crate::env::_sysconf), - "_getaddrinfo" => Function::new_env(store, env.clone(), crate::env::_getaddrinfo), - "_times" => Function::new_env(store, env.clone(), crate::env::_times), - "_pathconf" => Function::new_env(store, env.clone(), crate::env::_pathconf), - "_fpathconf" => Function::new_env(store, env.clone(), crate::env::_fpathconf), + "___assert_fail" => Function::new_native_with_env(store, env.clone(), crate::env::___assert_fail), + "_getenv" => Function::new_native_with_env(store, env.clone(), crate::env::_getenv), + "_setenv" => Function::new_native_with_env(store, env.clone(), crate::env::_setenv), + "_putenv" => Function::new_native_with_env(store, env.clone(), crate::env::_putenv), + "_unsetenv" => Function::new_native_with_env(store, env.clone(), crate::env::_unsetenv), + "_getpwnam" => Function::new_native_with_env(store, env.clone(), crate::env::_getpwnam), + "_getgrnam" => Function::new_native_with_env(store, env.clone(), crate::env::_getgrnam), + "___buildEnvironment" => Function::new_native_with_env(store, env.clone(), crate::env::___build_environment), + "___setErrNo" => Function::new_native_with_env(store, env.clone(), crate::errno::___seterrno), + "_getpagesize" => Function::new_native_with_env(store, env.clone(), crate::env::_getpagesize), + "_sysconf" => Function::new_native_with_env(store, env.clone(), crate::env::_sysconf), + "_getaddrinfo" => Function::new_native_with_env(store, env.clone(), crate::env::_getaddrinfo), + "_times" => Function::new_native_with_env(store, env.clone(), crate::env::_times), + "_pathconf" => Function::new_native_with_env(store, env.clone(), crate::env::_pathconf), + "_fpathconf" => Function::new_native_with_env(store, env.clone(), crate::env::_fpathconf), // Syscalls - "___syscall1" => Function::new_env(store, env.clone(), crate::syscalls::___syscall1), - "___syscall3" => Function::new_env(store, env.clone(), crate::syscalls::___syscall3), - "___syscall4" => Function::new_env(store, env.clone(), crate::syscalls::___syscall4), - "___syscall5" => Function::new_env(store, env.clone(), crate::syscalls::___syscall5), - "___syscall6" => Function::new_env(store, env.clone(), crate::syscalls::___syscall6), - "___syscall9" => Function::new_env(store, env.clone(), crate::syscalls::___syscall9), - "___syscall10" => Function::new_env(store, env.clone(), crate::syscalls::___syscall10), - "___syscall12" => Function::new_env(store, env.clone(), crate::syscalls::___syscall12), - "___syscall14" => Function::new_env(store, env.clone(), crate::syscalls::___syscall14), - "___syscall15" => Function::new_env(store, env.clone(), crate::syscalls::___syscall15), - "___syscall20" => Function::new_env(store, env.clone(), crate::syscalls::___syscall20), - "___syscall21" => Function::new_env(store, env.clone(), crate::syscalls::___syscall21), - "___syscall25" => Function::new_env(store, env.clone(), crate::syscalls::___syscall25), - "___syscall29" => Function::new_env(store, env.clone(), crate::syscalls::___syscall29), - "___syscall32" => Function::new_env(store, env.clone(), crate::syscalls::___syscall32), - "___syscall33" => Function::new_env(store, env.clone(), crate::syscalls::___syscall33), - "___syscall34" => Function::new_env(store, env.clone(), crate::syscalls::___syscall34), - "___syscall36" => Function::new_env(store, env.clone(), crate::syscalls::___syscall36), - "___syscall39" => Function::new_env(store, env.clone(), crate::syscalls::___syscall39), - "___syscall38" => Function::new_env(store, env.clone(), crate::syscalls::___syscall38), - "___syscall40" => Function::new_env(store, env.clone(), crate::syscalls::___syscall40), - "___syscall41" => Function::new_env(store, env.clone(), crate::syscalls::___syscall41), - "___syscall42" => Function::new_env(store, env.clone(), crate::syscalls::___syscall42), - "___syscall51" => Function::new_env(store, env.clone(), crate::syscalls::___syscall51), - "___syscall52" => Function::new_env(store, env.clone(), crate::syscalls::___syscall52), - "___syscall53" => Function::new_env(store, env.clone(), crate::syscalls::___syscall53), - "___syscall54" => Function::new_env(store, env.clone(), crate::syscalls::___syscall54), - "___syscall57" => Function::new_env(store, env.clone(), crate::syscalls::___syscall57), - "___syscall60" => Function::new_env(store, env.clone(), crate::syscalls::___syscall60), - "___syscall63" => Function::new_env(store, env.clone(), crate::syscalls::___syscall63), - "___syscall64" => Function::new_env(store, env.clone(), crate::syscalls::___syscall64), - "___syscall66" => Function::new_env(store, env.clone(), crate::syscalls::___syscall66), - "___syscall75" => Function::new_env(store, env.clone(), crate::syscalls::___syscall75), - "___syscall77" => Function::new_env(store, env.clone(), crate::syscalls::___syscall77), - "___syscall83" => Function::new_env(store, env.clone(), crate::syscalls::___syscall83), - "___syscall85" => Function::new_env(store, env.clone(), crate::syscalls::___syscall85), - "___syscall91" => Function::new_env(store, env.clone(), crate::syscalls::___syscall91), - "___syscall94" => Function::new_env(store, env.clone(), crate::syscalls::___syscall94), - "___syscall96" => Function::new_env(store, env.clone(), crate::syscalls::___syscall96), - "___syscall97" => Function::new_env(store, env.clone(), crate::syscalls::___syscall97), - "___syscall102" => Function::new_env(store, env.clone(), crate::syscalls::___syscall102), - "___syscall110" => Function::new_env(store, env.clone(), crate::syscalls::___syscall110), - "___syscall114" => Function::new_env(store, env.clone(), crate::syscalls::___syscall114), - "___syscall118" => Function::new_env(store, env.clone(), crate::syscalls::___syscall118), - "___syscall121" => Function::new_env(store, env.clone(), crate::syscalls::___syscall121), - "___syscall122" => Function::new_env(store, env.clone(), crate::syscalls::___syscall122), - "___syscall125" => Function::new_env(store, env.clone(), crate::syscalls::___syscall125), - "___syscall132" => Function::new_env(store, env.clone(), crate::syscalls::___syscall132), - "___syscall133" => Function::new_env(store, env.clone(), crate::syscalls::___syscall133), - "___syscall140" => Function::new_env(store, env.clone(), crate::syscalls::___syscall140), - "___syscall142" => Function::new_env(store, env.clone(), crate::syscalls::___syscall142), - "___syscall144" => Function::new_env(store, env.clone(), crate::syscalls::___syscall144), - "___syscall145" => Function::new_env(store, env.clone(), crate::syscalls::___syscall145), - "___syscall146" => Function::new_env(store, env.clone(), crate::syscalls::___syscall146), - "___syscall147" => Function::new_env(store, env.clone(), crate::syscalls::___syscall147), - "___syscall148" => Function::new_env(store, env.clone(), crate::syscalls::___syscall148), - "___syscall150" => Function::new_env(store, env.clone(), crate::syscalls::___syscall150), - "___syscall151" => Function::new_env(store, env.clone(), crate::syscalls::___syscall151), - "___syscall152" => Function::new_env(store, env.clone(), crate::syscalls::___syscall152), - "___syscall153" => Function::new_env(store, env.clone(), crate::syscalls::___syscall153), - "___syscall163" => Function::new_env(store, env.clone(), crate::syscalls::___syscall163), - "___syscall168" => Function::new_env(store, env.clone(), crate::syscalls::___syscall168), - "___syscall180" => Function::new_env(store, env.clone(), crate::syscalls::___syscall180), - "___syscall181" => Function::new_env(store, env.clone(), crate::syscalls::___syscall181), - "___syscall183" => Function::new_env(store, env.clone(), crate::syscalls::___syscall183), - "___syscall191" => Function::new_env(store, env.clone(), crate::syscalls::___syscall191), - "___syscall192" => Function::new_env(store, env.clone(), crate::syscalls::___syscall192), - "___syscall193" => Function::new_env(store, env.clone(), crate::syscalls::___syscall193), - "___syscall194" => Function::new_env(store, env.clone(), crate::syscalls::___syscall194), - "___syscall195" => Function::new_env(store, env.clone(), crate::syscalls::___syscall195), - "___syscall196" => Function::new_env(store, env.clone(), crate::syscalls::___syscall196), - "___syscall197" => Function::new_env(store, env.clone(), crate::syscalls::___syscall197), - "___syscall198" => Function::new_env(store, env.clone(), crate::syscalls::___syscall198), - "___syscall199" => Function::new_env(store, env.clone(), crate::syscalls::___syscall199), - "___syscall200" => Function::new_env(store, env.clone(), crate::syscalls::___syscall200), - "___syscall201" => Function::new_env(store, env.clone(), crate::syscalls::___syscall201), - "___syscall202" => Function::new_env(store, env.clone(), crate::syscalls::___syscall202), - "___syscall205" => Function::new_env(store, env.clone(), crate::syscalls::___syscall205), - "___syscall207" => Function::new_env(store, env.clone(), crate::syscalls::___syscall207), - "___syscall209" => Function::new_env(store, env.clone(), crate::syscalls::___syscall209), - "___syscall211" => Function::new_env(store, env.clone(), crate::syscalls::___syscall211), - "___syscall212" => Function::new_env(store, env.clone(), crate::syscalls::___syscall212), - "___syscall218" => Function::new_env(store, env.clone(), crate::syscalls::___syscall218), - "___syscall219" => Function::new_env(store, env.clone(), crate::syscalls::___syscall219), - "___syscall220" => Function::new_env(store, env.clone(), crate::syscalls::___syscall220), - "___syscall221" => Function::new_env(store, env.clone(), crate::syscalls::___syscall221), - "___syscall268" => Function::new_env(store, env.clone(), crate::syscalls::___syscall268), - "___syscall269" => Function::new_env(store, env.clone(), crate::syscalls::___syscall269), - "___syscall272" => Function::new_env(store, env.clone(), crate::syscalls::___syscall272), - "___syscall295" => Function::new_env(store, env.clone(), crate::syscalls::___syscall295), - "___syscall296" => Function::new_env(store, env.clone(), crate::syscalls::___syscall296), - "___syscall297" => Function::new_env(store, env.clone(), crate::syscalls::___syscall297), - "___syscall298" => Function::new_env(store, env.clone(), crate::syscalls::___syscall298), - "___syscall300" => Function::new_env(store, env.clone(), crate::syscalls::___syscall300), - "___syscall301" => Function::new_env(store, env.clone(), crate::syscalls::___syscall301), - "___syscall302" => Function::new_env(store, env.clone(), crate::syscalls::___syscall302), - "___syscall303" => Function::new_env(store, env.clone(), crate::syscalls::___syscall303), - "___syscall304" => Function::new_env(store, env.clone(), crate::syscalls::___syscall304), - "___syscall305" => Function::new_env(store, env.clone(), crate::syscalls::___syscall305), - "___syscall306" => Function::new_env(store, env.clone(), crate::syscalls::___syscall306), - "___syscall307" => Function::new_env(store, env.clone(), crate::syscalls::___syscall307), - "___syscall308" => Function::new_env(store, env.clone(), crate::syscalls::___syscall308), - "___syscall320" => Function::new_env(store, env.clone(), crate::syscalls::___syscall320), - "___syscall324" => Function::new_env(store, env.clone(), crate::syscalls::___syscall324), - "___syscall330" => Function::new_env(store, env.clone(), crate::syscalls::___syscall330), - "___syscall331" => Function::new_env(store, env.clone(), crate::syscalls::___syscall331), - "___syscall333" => Function::new_env(store, env.clone(), crate::syscalls::___syscall333), - "___syscall334" => Function::new_env(store, env.clone(), crate::syscalls::___syscall334), - "___syscall337" => Function::new_env(store, env.clone(), crate::syscalls::___syscall337), - "___syscall340" => Function::new_env(store, env.clone(), crate::syscalls::___syscall340), - "___syscall345" => Function::new_env(store, env.clone(), crate::syscalls::___syscall345), + "___syscall1" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall1), + "___syscall3" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall3), + "___syscall4" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall4), + "___syscall5" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall5), + "___syscall6" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall6), + "___syscall9" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall9), + "___syscall10" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall10), + "___syscall12" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall12), + "___syscall14" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall14), + "___syscall15" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall15), + "___syscall20" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall20), + "___syscall21" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall21), + "___syscall25" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall25), + "___syscall29" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall29), + "___syscall32" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall32), + "___syscall33" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall33), + "___syscall34" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall34), + "___syscall36" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall36), + "___syscall39" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall39), + "___syscall38" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall38), + "___syscall40" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall40), + "___syscall41" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall41), + "___syscall42" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall42), + "___syscall51" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall51), + "___syscall52" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall52), + "___syscall53" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall53), + "___syscall54" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall54), + "___syscall57" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall57), + "___syscall60" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall60), + "___syscall63" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall63), + "___syscall64" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall64), + "___syscall66" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall66), + "___syscall75" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall75), + "___syscall77" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall77), + "___syscall83" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall83), + "___syscall85" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall85), + "___syscall91" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall91), + "___syscall94" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall94), + "___syscall96" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall96), + "___syscall97" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall97), + "___syscall102" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall102), + "___syscall110" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall110), + "___syscall114" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall114), + "___syscall118" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall118), + "___syscall121" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall121), + "___syscall122" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall122), + "___syscall125" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall125), + "___syscall132" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall132), + "___syscall133" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall133), + "___syscall140" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall140), + "___syscall142" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall142), + "___syscall144" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall144), + "___syscall145" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall145), + "___syscall146" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall146), + "___syscall147" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall147), + "___syscall148" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall148), + "___syscall150" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall150), + "___syscall151" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall151), + "___syscall152" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall152), + "___syscall153" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall153), + "___syscall163" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall163), + "___syscall168" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall168), + "___syscall180" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall180), + "___syscall181" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall181), + "___syscall183" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall183), + "___syscall191" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall191), + "___syscall192" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall192), + "___syscall193" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall193), + "___syscall194" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall194), + "___syscall195" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall195), + "___syscall196" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall196), + "___syscall197" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall197), + "___syscall198" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall198), + "___syscall199" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall199), + "___syscall200" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall200), + "___syscall201" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall201), + "___syscall202" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall202), + "___syscall205" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall205), + "___syscall207" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall207), + "___syscall209" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall209), + "___syscall211" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall211), + "___syscall212" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall212), + "___syscall218" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall218), + "___syscall219" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall219), + "___syscall220" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall220), + "___syscall221" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall221), + "___syscall268" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall268), + "___syscall269" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall269), + "___syscall272" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall272), + "___syscall295" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall295), + "___syscall296" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall296), + "___syscall297" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall297), + "___syscall298" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall298), + "___syscall300" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall300), + "___syscall301" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall301), + "___syscall302" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall302), + "___syscall303" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall303), + "___syscall304" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall304), + "___syscall305" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall305), + "___syscall306" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall306), + "___syscall307" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall307), + "___syscall308" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall308), + "___syscall320" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall320), + "___syscall324" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall324), + "___syscall330" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall330), + "___syscall331" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall331), + "___syscall333" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall333), + "___syscall334" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall334), + "___syscall337" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall337), + "___syscall340" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall340), + "___syscall345" => Function::new_native_with_env(store, env.clone(), crate::syscalls::___syscall345), // Process - "abort" => Function::new_env(store, env.clone(), crate::process::em_abort), - "_abort" => Function::new_env(store, env.clone(), crate::process::_abort), - "_prctl" => Function::new_env(store, env.clone(), crate::process::_prctl), - "abortStackOverflow" => Function::new_env(store, env.clone(), crate::process::abort_stack_overflow), - "_llvm_trap" => Function::new_env(store, env.clone(), crate::process::_llvm_trap), - "_fork" => Function::new_env(store, env.clone(), crate::process::_fork), - "_exit" => Function::new_env(store, env.clone(), crate::process::_exit), - "_system" => Function::new_env(store, env.clone(), crate::process::_system), - "_popen" => Function::new_env(store, env.clone(), crate::process::_popen), - "_endgrent" => Function::new_env(store, env.clone(), crate::process::_endgrent), - "_execve" => Function::new_env(store, env.clone(), crate::process::_execve), - "_kill" => Function::new_env(store, env.clone(), crate::process::_kill), - "_llvm_stackrestore" => Function::new_env(store, env.clone(), crate::process::_llvm_stackrestore), - "_llvm_stacksave" => Function::new_env(store, env.clone(), crate::process::_llvm_stacksave), - "_llvm_eh_typeid_for" => Function::new_env(store, env.clone(), crate::process::_llvm_eh_typeid_for), - "_raise" => Function::new_env(store, env.clone(), crate::process::_raise), - "_sem_init" => Function::new_env(store, env.clone(), crate::process::_sem_init), - "_sem_destroy" => Function::new_env(store, env.clone(), crate::process::_sem_destroy), - "_sem_post" => Function::new_env(store, env.clone(), crate::process::_sem_post), - "_sem_wait" => Function::new_env(store, env.clone(), crate::process::_sem_wait), - "_getgrent" => Function::new_env(store, env.clone(), crate::process::_getgrent), - "_sched_yield" => Function::new_env(store, env.clone(), crate::process::_sched_yield), - "_setgrent" => Function::new_env(store, env.clone(), crate::process::_setgrent), - "_setgroups" => Function::new_env(store, env.clone(), crate::process::_setgroups), - "_setitimer" => Function::new_env(store, env.clone(), crate::process::_setitimer), - "_usleep" => Function::new_env(store, env.clone(), crate::process::_usleep), - "_nanosleep" => Function::new_env(store, env.clone(), crate::process::_nanosleep), - "_utime" => Function::new_env(store, env.clone(), crate::process::_utime), - "_utimes" => Function::new_env(store, env.clone(), crate::process::_utimes), - "_wait" => Function::new_env(store, env.clone(), crate::process::_wait), - "_wait3" => Function::new_env(store, env.clone(), crate::process::_wait3), - "_wait4" => Function::new_env(store, env.clone(), crate::process::_wait4), - "_waitid" => Function::new_env(store, env.clone(), crate::process::_waitid), - "_waitpid" => Function::new_env(store, env.clone(), crate::process::_waitpid), + "abort" => Function::new_native_with_env(store, env.clone(), crate::process::em_abort), + "_abort" => Function::new_native_with_env(store, env.clone(), crate::process::_abort), + "_prctl" => Function::new_native_with_env(store, env.clone(), crate::process::_prctl), + "abortStackOverflow" => Function::new_native_with_env(store, env.clone(), crate::process::abort_stack_overflow), + "_llvm_trap" => Function::new_native_with_env(store, env.clone(), crate::process::_llvm_trap), + "_fork" => Function::new_native_with_env(store, env.clone(), crate::process::_fork), + "_exit" => Function::new_native_with_env(store, env.clone(), crate::process::_exit), + "_system" => Function::new_native_with_env(store, env.clone(), crate::process::_system), + "_popen" => Function::new_native_with_env(store, env.clone(), crate::process::_popen), + "_endgrent" => Function::new_native_with_env(store, env.clone(), crate::process::_endgrent), + "_execve" => Function::new_native_with_env(store, env.clone(), crate::process::_execve), + "_kill" => Function::new_native_with_env(store, env.clone(), crate::process::_kill), + "_llvm_stackrestore" => Function::new_native_with_env(store, env.clone(), crate::process::_llvm_stackrestore), + "_llvm_stacksave" => Function::new_native_with_env(store, env.clone(), crate::process::_llvm_stacksave), + "_llvm_eh_typeid_for" => Function::new_native_with_env(store, env.clone(), crate::process::_llvm_eh_typeid_for), + "_raise" => Function::new_native_with_env(store, env.clone(), crate::process::_raise), + "_sem_init" => Function::new_native_with_env(store, env.clone(), crate::process::_sem_init), + "_sem_destroy" => Function::new_native_with_env(store, env.clone(), crate::process::_sem_destroy), + "_sem_post" => Function::new_native_with_env(store, env.clone(), crate::process::_sem_post), + "_sem_wait" => Function::new_native_with_env(store, env.clone(), crate::process::_sem_wait), + "_getgrent" => Function::new_native_with_env(store, env.clone(), crate::process::_getgrent), + "_sched_yield" => Function::new_native_with_env(store, env.clone(), crate::process::_sched_yield), + "_setgrent" => Function::new_native_with_env(store, env.clone(), crate::process::_setgrent), + "_setgroups" => Function::new_native_with_env(store, env.clone(), crate::process::_setgroups), + "_setitimer" => Function::new_native_with_env(store, env.clone(), crate::process::_setitimer), + "_usleep" => Function::new_native_with_env(store, env.clone(), crate::process::_usleep), + "_nanosleep" => Function::new_native_with_env(store, env.clone(), crate::process::_nanosleep), + "_utime" => Function::new_native_with_env(store, env.clone(), crate::process::_utime), + "_utimes" => Function::new_native_with_env(store, env.clone(), crate::process::_utimes), + "_wait" => Function::new_native_with_env(store, env.clone(), crate::process::_wait), + "_wait3" => Function::new_native_with_env(store, env.clone(), crate::process::_wait3), + "_wait4" => Function::new_native_with_env(store, env.clone(), crate::process::_wait4), + "_waitid" => Function::new_native_with_env(store, env.clone(), crate::process::_waitid), + "_waitpid" => Function::new_native_with_env(store, env.clone(), crate::process::_waitpid), // Emscripten - "_emscripten_asm_const_i" => Function::new_env(store, env.clone(), crate::emscripten_target::asm_const_i), - "_emscripten_exit_with_live_runtime" => Function::new_env(store, env.clone(), crate::emscripten_target::exit_with_live_runtime), + "_emscripten_asm_const_i" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::asm_const_i), + "_emscripten_exit_with_live_runtime" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::exit_with_live_runtime), // Signal - "_sigemptyset" => Function::new_env(store, env.clone(), crate::signal::_sigemptyset), - "_sigaddset" => Function::new_env(store, env.clone(), crate::signal::_sigaddset), - "_sigprocmask" => Function::new_env(store, env.clone(), crate::signal::_sigprocmask), - "_sigaction" => Function::new_env(store, env.clone(), crate::signal::_sigaction), - "_signal" => Function::new_env(store, env.clone(), crate::signal::_signal), - "_sigsuspend" => Function::new_env(store, env.clone(), crate::signal::_sigsuspend), + "_sigemptyset" => Function::new_native_with_env(store, env.clone(), crate::signal::_sigemptyset), + "_sigaddset" => Function::new_native_with_env(store, env.clone(), crate::signal::_sigaddset), + "_sigprocmask" => Function::new_native_with_env(store, env.clone(), crate::signal::_sigprocmask), + "_sigaction" => Function::new_native_with_env(store, env.clone(), crate::signal::_sigaction), + "_signal" => Function::new_native_with_env(store, env.clone(), crate::signal::_signal), + "_sigsuspend" => Function::new_native_with_env(store, env.clone(), crate::signal::_sigsuspend), // Memory "abortOnCannotGrowMemory" => abort_on_cannot_grow_memory_export, - "_emscripten_memcpy_big" => Function::new_env(store, env.clone(), crate::memory::_emscripten_memcpy_big), - "_emscripten_get_heap_size" => Function::new_env(store, env.clone(), crate::memory::_emscripten_get_heap_size), - "_emscripten_resize_heap" => Function::new_env(store, env.clone(), crate::memory::_emscripten_resize_heap), - "enlargeMemory" => Function::new_env(store, env.clone(), crate::memory::enlarge_memory), - "segfault" => Function::new_env(store, env.clone(), crate::memory::segfault), - "alignfault" => Function::new_env(store, env.clone(), crate::memory::alignfault), - "ftfault" => Function::new_env(store, env.clone(), crate::memory::ftfault), - "getTotalMemory" => Function::new_env(store, env.clone(), crate::memory::get_total_memory), - "_sbrk" => Function::new_env(store, env.clone(), crate::memory::sbrk), - "___map_file" => Function::new_env(store, env.clone(), crate::memory::___map_file), + "_emscripten_memcpy_big" => Function::new_native_with_env(store, env.clone(), crate::memory::_emscripten_memcpy_big), + "_emscripten_get_heap_size" => Function::new_native_with_env(store, env.clone(), crate::memory::_emscripten_get_heap_size), + "_emscripten_resize_heap" => Function::new_native_with_env(store, env.clone(), crate::memory::_emscripten_resize_heap), + "enlargeMemory" => Function::new_native_with_env(store, env.clone(), crate::memory::enlarge_memory), + "segfault" => Function::new_native_with_env(store, env.clone(), crate::memory::segfault), + "alignfault" => Function::new_native_with_env(store, env.clone(), crate::memory::alignfault), + "ftfault" => Function::new_native_with_env(store, env.clone(), crate::memory::ftfault), + "getTotalMemory" => Function::new_native_with_env(store, env.clone(), crate::memory::get_total_memory), + "_sbrk" => Function::new_native_with_env(store, env.clone(), crate::memory::sbrk), + "___map_file" => Function::new_native_with_env(store, env.clone(), crate::memory::___map_file), // Exception - "___cxa_allocate_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_allocate_exception), - "___cxa_current_primary_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_current_primary_exception), - "___cxa_decrement_exception_refcount" => Function::new_env(store, env.clone(), crate::exception::___cxa_decrement_exception_refcount), - "___cxa_increment_exception_refcount" => Function::new_env(store, env.clone(), crate::exception::___cxa_increment_exception_refcount), - "___cxa_rethrow_primary_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_rethrow_primary_exception), - "___cxa_throw" => Function::new_env(store, env.clone(), crate::exception::___cxa_throw), - "___cxa_begin_catch" => Function::new_env(store, env.clone(), crate::exception::___cxa_begin_catch), - "___cxa_end_catch" => Function::new_env(store, env.clone(), crate::exception::___cxa_end_catch), - "___cxa_uncaught_exception" => Function::new_env(store, env.clone(), crate::exception::___cxa_uncaught_exception), - "___cxa_pure_virtual" => Function::new_env(store, env.clone(), crate::exception::___cxa_pure_virtual), + "___cxa_allocate_exception" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_allocate_exception), + "___cxa_current_primary_exception" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_current_primary_exception), + "___cxa_decrement_exception_refcount" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_decrement_exception_refcount), + "___cxa_increment_exception_refcount" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_increment_exception_refcount), + "___cxa_rethrow_primary_exception" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_rethrow_primary_exception), + "___cxa_throw" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_throw), + "___cxa_begin_catch" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_begin_catch), + "___cxa_end_catch" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_end_catch), + "___cxa_uncaught_exception" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_uncaught_exception), + "___cxa_pure_virtual" => Function::new_native_with_env(store, env.clone(), crate::exception::___cxa_pure_virtual), // Time - "_gettimeofday" => Function::new_env(store, env.clone(), crate::time::_gettimeofday), - "_clock_getres" => Function::new_env(store, env.clone(), crate::time::_clock_getres), - "_clock_gettime" => Function::new_env(store, env.clone(), crate::time::_clock_gettime), - "_clock_settime" => Function::new_env(store, env.clone(), crate::time::_clock_settime), - "___clock_gettime" => Function::new_env(store, env.clone(), crate::time::_clock_gettime), - "_clock" => Function::new_env(store, env.clone(), crate::time::_clock), - "_difftime" => Function::new_env(store, env.clone(), crate::time::_difftime), - "_asctime" => Function::new_env(store, env.clone(), crate::time::_asctime), - "_asctime_r" => Function::new_env(store, env.clone(), crate::time::_asctime_r), - "_localtime" => Function::new_env(store, env.clone(), crate::time::_localtime), - "_time" => Function::new_env(store, env.clone(), crate::time::_time), - "_timegm" => Function::new_env(store, env.clone(), crate::time::_timegm), - "_strftime" => Function::new_env(store, env.clone(), crate::time::_strftime), - "_strftime_l" => Function::new_env(store, env.clone(), crate::time::_strftime_l), - "_localtime_r" => Function::new_env(store, env.clone(), crate::time::_localtime_r), - "_gmtime_r" => Function::new_env(store, env.clone(), crate::time::_gmtime_r), - "_ctime" => Function::new_env(store, env.clone(), crate::time::_ctime), - "_ctime_r" => Function::new_env(store, env.clone(), crate::time::_ctime_r), - "_mktime" => Function::new_env(store, env.clone(), crate::time::_mktime), - "_gmtime" => Function::new_env(store, env.clone(), crate::time::_gmtime), + "_gettimeofday" => Function::new_native_with_env(store, env.clone(), crate::time::_gettimeofday), + "_clock_getres" => Function::new_native_with_env(store, env.clone(), crate::time::_clock_getres), + "_clock_gettime" => Function::new_native_with_env(store, env.clone(), crate::time::_clock_gettime), + "_clock_settime" => Function::new_native_with_env(store, env.clone(), crate::time::_clock_settime), + "___clock_gettime" => Function::new_native_with_env(store, env.clone(), crate::time::_clock_gettime), + "_clock" => Function::new_native_with_env(store, env.clone(), crate::time::_clock), + "_difftime" => Function::new_native_with_env(store, env.clone(), crate::time::_difftime), + "_asctime" => Function::new_native_with_env(store, env.clone(), crate::time::_asctime), + "_asctime_r" => Function::new_native_with_env(store, env.clone(), crate::time::_asctime_r), + "_localtime" => Function::new_native_with_env(store, env.clone(), crate::time::_localtime), + "_time" => Function::new_native_with_env(store, env.clone(), crate::time::_time), + "_timegm" => Function::new_native_with_env(store, env.clone(), crate::time::_timegm), + "_strftime" => Function::new_native_with_env(store, env.clone(), crate::time::_strftime), + "_strftime_l" => Function::new_native_with_env(store, env.clone(), crate::time::_strftime_l), + "_localtime_r" => Function::new_native_with_env(store, env.clone(), crate::time::_localtime_r), + "_gmtime_r" => Function::new_native_with_env(store, env.clone(), crate::time::_gmtime_r), + "_ctime" => Function::new_native_with_env(store, env.clone(), crate::time::_ctime), + "_ctime_r" => Function::new_native_with_env(store, env.clone(), crate::time::_ctime_r), + "_mktime" => Function::new_native_with_env(store, env.clone(), crate::time::_mktime), + "_gmtime" => Function::new_native_with_env(store, env.clone(), crate::time::_gmtime), // Math - "sqrt" => Function::new(store, crate::math::sqrt), - "floor" => Function::new(store, crate::math::floor), - "fabs" => Function::new(store, crate::math::fabs), - "f64-rem" => Function::new(store, crate::math::f64_rem), - "_llvm_copysign_f32" => Function::new(store, crate::math::_llvm_copysign_f32), - "_llvm_copysign_f64" => Function::new(store, crate::math::_llvm_copysign_f64), - "_llvm_log10_f64" => Function::new(store, crate::math::_llvm_log10_f64), - "_llvm_log2_f64" => Function::new(store, crate::math::_llvm_log2_f64), - "_llvm_log10_f32" => Function::new(store, crate::math::_llvm_log10_f32), - "_llvm_log2_f32" => Function::new(store, crate::math::_llvm_log2_f64), - "_llvm_sin_f64" => Function::new(store, crate::math::_llvm_sin_f64), - "_llvm_cos_f64" => Function::new(store, crate::math::_llvm_cos_f64), - "_llvm_exp2_f32" => Function::new(store, crate::math::_llvm_exp2_f32), - "_llvm_exp2_f64" => Function::new(store, crate::math::_llvm_exp2_f64), - "_llvm_trunc_f64" => Function::new(store, crate::math::_llvm_trunc_f64), - "_llvm_fma_f64" => Function::new(store, crate::math::_llvm_fma_f64), - "_emscripten_random" => Function::new_env(store, env.clone(), crate::math::_emscripten_random), + "sqrt" => Function::new_native(store, crate::math::sqrt), + "floor" => Function::new_native(store, crate::math::floor), + "fabs" => Function::new_native(store, crate::math::fabs), + "f64-rem" => Function::new_native(store, crate::math::f64_rem), + "_llvm_copysign_f32" => Function::new_native(store, crate::math::_llvm_copysign_f32), + "_llvm_copysign_f64" => Function::new_native(store, crate::math::_llvm_copysign_f64), + "_llvm_log10_f64" => Function::new_native(store, crate::math::_llvm_log10_f64), + "_llvm_log2_f64" => Function::new_native(store, crate::math::_llvm_log2_f64), + "_llvm_log10_f32" => Function::new_native(store, crate::math::_llvm_log10_f32), + "_llvm_log2_f32" => Function::new_native(store, crate::math::_llvm_log2_f64), + "_llvm_sin_f64" => Function::new_native(store, crate::math::_llvm_sin_f64), + "_llvm_cos_f64" => Function::new_native(store, crate::math::_llvm_cos_f64), + "_llvm_exp2_f32" => Function::new_native(store, crate::math::_llvm_exp2_f32), + "_llvm_exp2_f64" => Function::new_native(store, crate::math::_llvm_exp2_f64), + "_llvm_trunc_f64" => Function::new_native(store, crate::math::_llvm_trunc_f64), + "_llvm_fma_f64" => Function::new_native(store, crate::math::_llvm_fma_f64), + "_emscripten_random" => Function::new_native_with_env(store, env.clone(), crate::math::_emscripten_random), // Jump - "__setjmp" => Function::new_env(store, env.clone(), crate::jmp::__setjmp), - "__longjmp" => Function::new_env(store, env.clone(), crate::jmp::__longjmp), - "_longjmp" => Function::new_env(store, env.clone(), crate::jmp::_longjmp), - "_emscripten_longjmp" => Function::new_env(store, env.clone(), crate::jmp::_longjmp), + "__setjmp" => Function::new_native_with_env(store, env.clone(), crate::jmp::__setjmp), + "__longjmp" => Function::new_native_with_env(store, env.clone(), crate::jmp::__longjmp), + "_longjmp" => Function::new_native_with_env(store, env.clone(), crate::jmp::_longjmp), + "_emscripten_longjmp" => Function::new_native_with_env(store, env.clone(), crate::jmp::_longjmp), // Bitwise - "_llvm_bswap_i64" => Function::new_env(store, env.clone(), crate::bitwise::_llvm_bswap_i64), + "_llvm_bswap_i64" => Function::new_native_with_env(store, env.clone(), crate::bitwise::_llvm_bswap_i64), // libc - "_execv" => Function::new(store, crate::libc::execv), - "_endpwent" => Function::new(store, crate::libc::endpwent), - "_fexecve" => Function::new(store, crate::libc::fexecve), - "_fpathconf" => Function::new(store, crate::libc::fpathconf), - "_getitimer" => Function::new(store, crate::libc::getitimer), - "_getpwent" => Function::new(store, crate::libc::getpwent), - "_killpg" => Function::new(store, crate::libc::killpg), - "_pathconf" => Function::new_env(store, env.clone(), crate::libc::pathconf), - "_siginterrupt" => Function::new_env(store, env.clone(), crate::signal::_siginterrupt), - "_setpwent" => Function::new(store, crate::libc::setpwent), - "_sigismember" => Function::new(store, crate::libc::sigismember), - "_sigpending" => Function::new(store, crate::libc::sigpending), - "___libc_current_sigrtmax" => Function::new(store, crate::libc::current_sigrtmax), - "___libc_current_sigrtmin" => Function::new(store, crate::libc::current_sigrtmin), + "_execv" => Function::new_native(store, crate::libc::execv), + "_endpwent" => Function::new_native(store, crate::libc::endpwent), + "_fexecve" => Function::new_native(store, crate::libc::fexecve), + "_fpathconf" => Function::new_native(store, crate::libc::fpathconf), + "_getitimer" => Function::new_native(store, crate::libc::getitimer), + "_getpwent" => Function::new_native(store, crate::libc::getpwent), + "_killpg" => Function::new_native(store, crate::libc::killpg), + "_pathconf" => Function::new_native_with_env(store, env.clone(), crate::libc::pathconf), + "_siginterrupt" => Function::new_native_with_env(store, env.clone(), crate::signal::_siginterrupt), + "_setpwent" => Function::new_native(store, crate::libc::setpwent), + "_sigismember" => Function::new_native(store, crate::libc::sigismember), + "_sigpending" => Function::new_native(store, crate::libc::sigpending), + "___libc_current_sigrtmax" => Function::new_native(store, crate::libc::current_sigrtmax), + "___libc_current_sigrtmin" => Function::new_native(store, crate::libc::current_sigrtmin), // Linking - "_dlclose" => Function::new_env(store, env.clone(), crate::linking::_dlclose), - "_dlerror" => Function::new_env(store, env.clone(), crate::linking::_dlerror), - "_dlopen" => Function::new_env(store, env.clone(), crate::linking::_dlopen), - "_dlsym" => Function::new_env(store, env.clone(), crate::linking::_dlsym), + "_dlclose" => Function::new_native_with_env(store, env.clone(), crate::linking::_dlclose), + "_dlerror" => Function::new_native_with_env(store, env.clone(), crate::linking::_dlerror), + "_dlopen" => Function::new_native_with_env(store, env.clone(), crate::linking::_dlopen), + "_dlsym" => Function::new_native_with_env(store, env.clone(), crate::linking::_dlsym), // wasm32-unknown-emscripten - "_alarm" => Function::new_env(store, env.clone(), crate::emscripten_target::_alarm), - "_atexit" => Function::new_env(store, env.clone(), crate::emscripten_target::_atexit), - "setTempRet0" => Function::new_env(store, env.clone(), crate::emscripten_target::setTempRet0), - "getTempRet0" => Function::new_env(store, env.clone(), crate::emscripten_target::getTempRet0), - "invoke_i" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_i), - "invoke_ii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_ii), - "invoke_iii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iii), - "invoke_iiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiii), - "invoke_iifi" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iifi), - "invoke_v" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_v), - "invoke_vi" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vi), - "invoke_vj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vj), - "invoke_vjji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vjji), - "invoke_vii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vii), - "invoke_viii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viii), - "invoke_viiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiii), - "__Unwind_Backtrace" => Function::new_env(store, env.clone(), crate::emscripten_target::__Unwind_Backtrace), - "__Unwind_FindEnclosingFunction" => Function::new_env(store, env.clone(), crate::emscripten_target::__Unwind_FindEnclosingFunction), - "__Unwind_GetIPInfo" => Function::new_env(store, env.clone(), crate::emscripten_target::__Unwind_GetIPInfo), - "___cxa_find_matching_catch_2" => Function::new_env(store, env.clone(), crate::emscripten_target::___cxa_find_matching_catch_2), - "___cxa_find_matching_catch_3" => Function::new_env(store, env.clone(), crate::emscripten_target::___cxa_find_matching_catch_3), - "___cxa_free_exception" => Function::new_env(store, env.clone(), crate::emscripten_target::___cxa_free_exception), - "___resumeException" => Function::new_env(store, env.clone(), crate::emscripten_target::___resumeException), - "_dladdr" => Function::new_env(store, env.clone(), crate::emscripten_target::_dladdr), - "_pthread_attr_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_destroy), - "_pthread_attr_getstack" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_getstack), - "_pthread_attr_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_init), - "_pthread_attr_setstacksize" => Function::new_env(store, env.clone(), crate::pthread::_pthread_attr_setstacksize), - "_pthread_cleanup_pop" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cleanup_pop), - "_pthread_cleanup_push" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cleanup_push), - "_pthread_cond_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_destroy), - "_pthread_cond_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_init), - "_pthread_cond_signal" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_signal), - "_pthread_cond_timedwait" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_timedwait), - "_pthread_cond_wait" => Function::new_env(store, env.clone(), crate::pthread::_pthread_cond_wait), - "_pthread_condattr_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_condattr_destroy), - "_pthread_condattr_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_condattr_init), - "_pthread_condattr_setclock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_condattr_setclock), - "_pthread_create" => Function::new_env(store, env.clone(), crate::pthread::_pthread_create), - "_pthread_detach" => Function::new_env(store, env.clone(), crate::pthread::_pthread_detach), - "_pthread_equal" => Function::new_env(store, env.clone(), crate::pthread::_pthread_equal), - "_pthread_exit" => Function::new_env(store, env.clone(), crate::pthread::_pthread_exit), - "_pthread_self" => Function::new_env(store, env.clone(), crate::pthread::_pthread_self), - "_pthread_getattr_np" => Function::new_env(store, env.clone(), crate::pthread::_pthread_getattr_np), - "_pthread_getspecific" => Function::new_env(store, env.clone(), crate::pthread::_pthread_getspecific), - "_pthread_join" => Function::new_env(store, env.clone(), crate::pthread::_pthread_join), - "_pthread_key_create" => Function::new_env(store, env.clone(), crate::pthread::_pthread_key_create), - "_pthread_mutex_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutex_destroy), - "_pthread_mutex_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutex_init), - "_pthread_mutexattr_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutexattr_destroy), - "_pthread_mutexattr_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutexattr_init), - "_pthread_mutexattr_settype" => Function::new_env(store, env.clone(), crate::pthread::_pthread_mutexattr_settype), - "_pthread_once" => Function::new_env(store, env.clone(), crate::pthread::_pthread_once), - "_pthread_rwlock_destroy" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_destroy), - "_pthread_rwlock_init" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_init), - "_pthread_rwlock_rdlock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_rdlock), - "_pthread_rwlock_unlock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_unlock), - "_pthread_rwlock_wrlock" => Function::new_env(store, env.clone(), crate::pthread::_pthread_rwlock_wrlock), - "_pthread_setcancelstate" => Function::new_env(store, env.clone(), crate::pthread::_pthread_setcancelstate), - "_pthread_setspecific" => Function::new_env(store, env.clone(), crate::pthread::_pthread_setspecific), - "_pthread_sigmask" => Function::new_env(store, env.clone(), crate::pthread::_pthread_sigmask), - "___gxx_personality_v0" => Function::new_env(store, env.clone(), crate::emscripten_target::___gxx_personality_v0), - "_gai_strerror" => Function::new_env(store, env.clone(), crate::env::_gai_strerror), - "_getdtablesize" => Function::new_env(store, env.clone(), crate::emscripten_target::_getdtablesize), - "_gethostbyaddr" => Function::new_env(store, env.clone(), crate::emscripten_target::_gethostbyaddr), - "_gethostbyname" => Function::new_env(store, env.clone(), crate::emscripten_target::_gethostbyname), - "_gethostbyname_r" => Function::new_env(store, env.clone(), crate::emscripten_target::_gethostbyname_r), - "_getloadavg" => Function::new_env(store, env.clone(), crate::emscripten_target::_getloadavg), - "_getnameinfo" => Function::new_env(store, env.clone(), crate::emscripten_target::_getnameinfo), - "invoke_dii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_dii), - "invoke_diiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_diiii), - "invoke_iiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiii), - "invoke_iiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiii), - "invoke_iiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiii), - "invoke_iiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiii), - "invoke_iiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiii), - "invoke_iiiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiiii), - "invoke_iiiiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiiiii), - "invoke_vd" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vd), - "invoke_viiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiii), - "invoke_viiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiii), - "invoke_viiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiii), - "invoke_viiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiii), - "invoke_viiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiii), - "invoke_viiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiii), - "invoke_viiiiiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiiii), - "invoke_iij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iij), - "invoke_iji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iji), - "invoke_iiji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiji), - "invoke_iiijj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_iiijj), - "invoke_j" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_j), - "invoke_ji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_ji), - "invoke_jii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_jii), - "invoke_jij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_jij), - "invoke_jjj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_jjj), - "invoke_viiij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiij), - "invoke_viiijiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiijiiii), - "invoke_viiijiiiiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiijiiiiii), - "invoke_viij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viij), - "invoke_viiji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viiji), - "invoke_viijiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viijiii), - "invoke_viijj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viijj), - "invoke_vij" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vij), - "invoke_viji" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viji), - "invoke_vijiii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vijiii), - "invoke_vijj" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vijj), - "invoke_vidd" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_vidd), - "invoke_viid" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viid), - "invoke_viidii" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viidii), - "invoke_viidddddddd" => Function::new_env(store, env.clone(), crate::emscripten_target::invoke_viidddddddd), + "_alarm" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_alarm), + "_atexit" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_atexit), + "setTempRet0" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::setTempRet0), + "getTempRet0" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::getTempRet0), + "invoke_i" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_i), + "invoke_ii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_ii), + "invoke_iii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iii), + "invoke_iiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiii), + "invoke_iifi" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iifi), + "invoke_v" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_v), + "invoke_vi" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vi), + "invoke_vj" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vj), + "invoke_vjji" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vjji), + "invoke_vii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vii), + "invoke_viii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viii), + "invoke_viiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiii), + "__Unwind_Backtrace" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::__Unwind_Backtrace), + "__Unwind_FindEnclosingFunction" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::__Unwind_FindEnclosingFunction), + "__Unwind_GetIPInfo" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::__Unwind_GetIPInfo), + "___cxa_find_matching_catch_2" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::___cxa_find_matching_catch_2), + "___cxa_find_matching_catch_3" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::___cxa_find_matching_catch_3), + "___cxa_free_exception" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::___cxa_free_exception), + "___resumeException" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::___resumeException), + "_dladdr" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_dladdr), + "_pthread_attr_destroy" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_attr_destroy), + "_pthread_attr_getstack" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_attr_getstack), + "_pthread_attr_init" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_attr_init), + "_pthread_attr_setstacksize" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_attr_setstacksize), + "_pthread_cleanup_pop" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_cleanup_pop), + "_pthread_cleanup_push" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_cleanup_push), + "_pthread_cond_destroy" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_cond_destroy), + "_pthread_cond_init" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_cond_init), + "_pthread_cond_signal" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_cond_signal), + "_pthread_cond_timedwait" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_cond_timedwait), + "_pthread_cond_wait" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_cond_wait), + "_pthread_condattr_destroy" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_condattr_destroy), + "_pthread_condattr_init" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_condattr_init), + "_pthread_condattr_setclock" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_condattr_setclock), + "_pthread_create" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_create), + "_pthread_detach" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_detach), + "_pthread_equal" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_equal), + "_pthread_exit" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_exit), + "_pthread_self" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_self), + "_pthread_getattr_np" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_getattr_np), + "_pthread_getspecific" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_getspecific), + "_pthread_join" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_join), + "_pthread_key_create" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_key_create), + "_pthread_mutex_destroy" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_mutex_destroy), + "_pthread_mutex_init" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_mutex_init), + "_pthread_mutexattr_destroy" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_mutexattr_destroy), + "_pthread_mutexattr_init" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_mutexattr_init), + "_pthread_mutexattr_settype" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_mutexattr_settype), + "_pthread_once" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_once), + "_pthread_rwlock_destroy" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_rwlock_destroy), + "_pthread_rwlock_init" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_rwlock_init), + "_pthread_rwlock_rdlock" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_rwlock_rdlock), + "_pthread_rwlock_unlock" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_rwlock_unlock), + "_pthread_rwlock_wrlock" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_rwlock_wrlock), + "_pthread_setcancelstate" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_setcancelstate), + "_pthread_setspecific" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_setspecific), + "_pthread_sigmask" => Function::new_native_with_env(store, env.clone(), crate::pthread::_pthread_sigmask), + "___gxx_personality_v0" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::___gxx_personality_v0), + "_gai_strerror" => Function::new_native_with_env(store, env.clone(), crate::env::_gai_strerror), + "_getdtablesize" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_getdtablesize), + "_gethostbyaddr" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_gethostbyaddr), + "_gethostbyname" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_gethostbyname), + "_gethostbyname_r" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_gethostbyname_r), + "_getloadavg" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_getloadavg), + "_getnameinfo" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::_getnameinfo), + "invoke_dii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_dii), + "invoke_diiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_diiii), + "invoke_iiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiiii), + "invoke_iiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiiiii), + "invoke_iiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiii), + "invoke_iiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiii), + "invoke_iiiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiii), + "invoke_iiiiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiiii), + "invoke_iiiiiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiiiiiiiiii), + "invoke_vd" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vd), + "invoke_viiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiiii), + "invoke_viiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiiiii), + "invoke_viiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiii), + "invoke_viiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiii), + "invoke_viiiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiii), + "invoke_viiiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiii), + "invoke_viiiiiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiiiiiiiii), + "invoke_iij" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iij), + "invoke_iji" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iji), + "invoke_iiji" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiji), + "invoke_iiijj" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_iiijj), + "invoke_j" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_j), + "invoke_ji" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_ji), + "invoke_jii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_jii), + "invoke_jij" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_jij), + "invoke_jjj" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_jjj), + "invoke_viiij" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiij), + "invoke_viiijiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiijiiii), + "invoke_viiijiiiiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiijiiiiii), + "invoke_viij" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viij), + "invoke_viiji" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viiji), + "invoke_viijiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viijiii), + "invoke_viijj" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viijj), + "invoke_vij" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vij), + "invoke_viji" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viji), + "invoke_vijiii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vijiii), + "invoke_vijj" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vijj), + "invoke_vidd" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_vidd), + "invoke_viid" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viid), + "invoke_viidii" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viidii), + "invoke_viidddddddd" => Function::new_native_with_env(store, env.clone(), crate::emscripten_target::invoke_viidddddddd), // ucontext - "_getcontext" => Function::new_env(store, env.clone(), crate::ucontext::_getcontext), - "_makecontext" => Function::new_env(store, env.clone(), crate::ucontext::_makecontext), - "_setcontext" => Function::new_env(store, env.clone(), crate::ucontext::_setcontext), - "_swapcontext" => Function::new_env(store, env.clone(), crate::ucontext::_swapcontext), + "_getcontext" => Function::new_native_with_env(store, env.clone(), crate::ucontext::_getcontext), + "_makecontext" => Function::new_native_with_env(store, env.clone(), crate::ucontext::_makecontext), + "_setcontext" => Function::new_native_with_env(store, env.clone(), crate::ucontext::_setcontext), + "_swapcontext" => Function::new_native_with_env(store, env.clone(), crate::ucontext::_swapcontext), // unistd - "_confstr" => Function::new_env(store, env.clone(), crate::unistd::confstr), + "_confstr" => Function::new_native_with_env(store, env.clone(), crate::unistd::confstr), }; // Compatibility with newer versions of Emscripten @@ -1120,7 +1120,7 @@ pub fn generate_emscripten_env( for null_func_name in globals.null_func_names.iter() { env_ns.insert( null_func_name.as_str(), - Function::new_env(store, env.clone(), nullfunc), + Function::new_native_with_env(store, env.clone(), nullfunc), ); } @@ -1131,13 +1131,13 @@ pub fn generate_emscripten_env( "Infinity" => Global::new(store, Val::F64(f64::INFINITY)), }, "global.Math" => { - "pow" => Function::new(store, crate::math::pow), - "exp" => Function::new(store, crate::math::exp), - "log" => Function::new(store, crate::math::log), + "pow" => Function::new_native(store, crate::math::pow), + "exp" => Function::new_native(store, crate::math::exp), + "log" => Function::new_native(store, crate::math::log), }, "asm2wasm" => { - "f64-rem" => Function::new(store, crate::math::f64_rem), - "f64-to-int" => Function::new(store, crate::math::f64_to_int), + "f64-rem" => Function::new_native(store, crate::math::f64_rem), + "f64-to-int" => Function::new_native(store, crate::math::f64_to_int), }, }; diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 32b7691751d..733069c0ff2 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -195,51 +195,51 @@ pub fn generate_import_object_from_env( fn generate_import_object_snapshot0(store: &Store, env: WasiEnv) -> ImportObject { imports! { "wasi_unstable" => { - "args_get" => Function::new_env(store, env.clone(), args_get), - "args_sizes_get" => Function::new_env(store, env.clone(), args_sizes_get), - "clock_res_get" => Function::new_env(store, env.clone(), clock_res_get), - "clock_time_get" => Function::new_env(store, env.clone(), clock_time_get), - "environ_get" => Function::new_env(store, env.clone(), environ_get), - "environ_sizes_get" => Function::new_env(store, env.clone(), environ_sizes_get), - "fd_advise" => Function::new_env(store, env.clone(), fd_advise), - "fd_allocate" => Function::new_env(store, env.clone(), fd_allocate), - "fd_close" => Function::new_env(store, env.clone(), fd_close), - "fd_datasync" => Function::new_env(store, env.clone(), fd_datasync), - "fd_fdstat_get" => Function::new_env(store, env.clone(), fd_fdstat_get), - "fd_fdstat_set_flags" => Function::new_env(store, env.clone(), fd_fdstat_set_flags), - "fd_fdstat_set_rights" => Function::new_env(store, env.clone(), fd_fdstat_set_rights), - "fd_filestat_get" => Function::new_env(store, env.clone(), legacy::snapshot0::fd_filestat_get), - "fd_filestat_set_size" => Function::new_env(store, env.clone(), fd_filestat_set_size), - "fd_filestat_set_times" => Function::new_env(store, env.clone(), fd_filestat_set_times), - "fd_pread" => Function::new_env(store, env.clone(), fd_pread), - "fd_prestat_get" => Function::new_env(store, env.clone(), fd_prestat_get), - "fd_prestat_dir_name" => Function::new_env(store, env.clone(), fd_prestat_dir_name), - "fd_pwrite" => Function::new_env(store, env.clone(), fd_pwrite), - "fd_read" => Function::new_env(store, env.clone(), fd_read), - "fd_readdir" => Function::new_env(store, env.clone(), fd_readdir), - "fd_renumber" => Function::new_env(store, env.clone(), fd_renumber), - "fd_seek" => Function::new_env(store, env.clone(), legacy::snapshot0::fd_seek), - "fd_sync" => Function::new_env(store, env.clone(), fd_sync), - "fd_tell" => Function::new_env(store, env.clone(), fd_tell), - "fd_write" => Function::new_env(store, env.clone(), fd_write), - "path_create_directory" => Function::new_env(store, env.clone(), path_create_directory), - "path_filestat_get" => Function::new_env(store, env.clone(), legacy::snapshot0::path_filestat_get), - "path_filestat_set_times" => Function::new_env(store, env.clone(), path_filestat_set_times), - "path_link" => Function::new_env(store, env.clone(), path_link), - "path_open" => Function::new_env(store, env.clone(), path_open), - "path_readlink" => Function::new_env(store, env.clone(), path_readlink), - "path_remove_directory" => Function::new_env(store, env.clone(), path_remove_directory), - "path_rename" => Function::new_env(store, env.clone(), path_rename), - "path_symlink" => Function::new_env(store, env.clone(), path_symlink), - "path_unlink_file" => Function::new_env(store, env.clone(), path_unlink_file), - "poll_oneoff" => Function::new_env(store, env.clone(), legacy::snapshot0::poll_oneoff), - "proc_exit" => Function::new_env(store, env.clone(), proc_exit), - "proc_raise" => Function::new_env(store, env.clone(), proc_raise), - "random_get" => Function::new_env(store, env.clone(), random_get), - "sched_yield" => Function::new_env(store, env.clone(), sched_yield), - "sock_recv" => Function::new_env(store, env.clone(), sock_recv), - "sock_send" => Function::new_env(store, env.clone(), sock_send), - "sock_shutdown" => Function::new_env(store, env.clone(), sock_shutdown), + "args_get" => Function::new_native_with_env(store, env.clone(), args_get), + "args_sizes_get" => Function::new_native_with_env(store, env.clone(), args_sizes_get), + "clock_res_get" => Function::new_native_with_env(store, env.clone(), clock_res_get), + "clock_time_get" => Function::new_native_with_env(store, env.clone(), clock_time_get), + "environ_get" => Function::new_native_with_env(store, env.clone(), environ_get), + "environ_sizes_get" => Function::new_native_with_env(store, env.clone(), environ_sizes_get), + "fd_advise" => Function::new_native_with_env(store, env.clone(), fd_advise), + "fd_allocate" => Function::new_native_with_env(store, env.clone(), fd_allocate), + "fd_close" => Function::new_native_with_env(store, env.clone(), fd_close), + "fd_datasync" => Function::new_native_with_env(store, env.clone(), fd_datasync), + "fd_fdstat_get" => Function::new_native_with_env(store, env.clone(), fd_fdstat_get), + "fd_fdstat_set_flags" => Function::new_native_with_env(store, env.clone(), fd_fdstat_set_flags), + "fd_fdstat_set_rights" => Function::new_native_with_env(store, env.clone(), fd_fdstat_set_rights), + "fd_filestat_get" => Function::new_native_with_env(store, env.clone(), legacy::snapshot0::fd_filestat_get), + "fd_filestat_set_size" => Function::new_native_with_env(store, env.clone(), fd_filestat_set_size), + "fd_filestat_set_times" => Function::new_native_with_env(store, env.clone(), fd_filestat_set_times), + "fd_pread" => Function::new_native_with_env(store, env.clone(), fd_pread), + "fd_prestat_get" => Function::new_native_with_env(store, env.clone(), fd_prestat_get), + "fd_prestat_dir_name" => Function::new_native_with_env(store, env.clone(), fd_prestat_dir_name), + "fd_pwrite" => Function::new_native_with_env(store, env.clone(), fd_pwrite), + "fd_read" => Function::new_native_with_env(store, env.clone(), fd_read), + "fd_readdir" => Function::new_native_with_env(store, env.clone(), fd_readdir), + "fd_renumber" => Function::new_native_with_env(store, env.clone(), fd_renumber), + "fd_seek" => Function::new_native_with_env(store, env.clone(), legacy::snapshot0::fd_seek), + "fd_sync" => Function::new_native_with_env(store, env.clone(), fd_sync), + "fd_tell" => Function::new_native_with_env(store, env.clone(), fd_tell), + "fd_write" => Function::new_native_with_env(store, env.clone(), fd_write), + "path_create_directory" => Function::new_native_with_env(store, env.clone(), path_create_directory), + "path_filestat_get" => Function::new_native_with_env(store, env.clone(), legacy::snapshot0::path_filestat_get), + "path_filestat_set_times" => Function::new_native_with_env(store, env.clone(), path_filestat_set_times), + "path_link" => Function::new_native_with_env(store, env.clone(), path_link), + "path_open" => Function::new_native_with_env(store, env.clone(), path_open), + "path_readlink" => Function::new_native_with_env(store, env.clone(), path_readlink), + "path_remove_directory" => Function::new_native_with_env(store, env.clone(), path_remove_directory), + "path_rename" => Function::new_native_with_env(store, env.clone(), path_rename), + "path_symlink" => Function::new_native_with_env(store, env.clone(), path_symlink), + "path_unlink_file" => Function::new_native_with_env(store, env.clone(), path_unlink_file), + "poll_oneoff" => Function::new_native_with_env(store, env.clone(), legacy::snapshot0::poll_oneoff), + "proc_exit" => Function::new_native_with_env(store, env.clone(), proc_exit), + "proc_raise" => Function::new_native_with_env(store, env.clone(), proc_raise), + "random_get" => Function::new_native_with_env(store, env.clone(), random_get), + "sched_yield" => Function::new_native_with_env(store, env.clone(), sched_yield), + "sock_recv" => Function::new_native_with_env(store, env.clone(), sock_recv), + "sock_send" => Function::new_native_with_env(store, env.clone(), sock_send), + "sock_shutdown" => Function::new_native_with_env(store, env.clone(), sock_shutdown), }, } } @@ -248,51 +248,51 @@ fn generate_import_object_snapshot0(store: &Store, env: WasiEnv) -> ImportObject fn generate_import_object_snapshot1(store: &Store, env: WasiEnv) -> ImportObject { imports! { "wasi_snapshot_preview1" => { - "args_get" => Function::new_env(store, env.clone(), args_get), - "args_sizes_get" => Function::new_env(store, env.clone(), args_sizes_get), - "clock_res_get" => Function::new_env(store, env.clone(), clock_res_get), - "clock_time_get" => Function::new_env(store, env.clone(), clock_time_get), - "environ_get" => Function::new_env(store, env.clone(), environ_get), - "environ_sizes_get" => Function::new_env(store, env.clone(), environ_sizes_get), - "fd_advise" => Function::new_env(store, env.clone(), fd_advise), - "fd_allocate" => Function::new_env(store, env.clone(), fd_allocate), - "fd_close" => Function::new_env(store, env.clone(), fd_close), - "fd_datasync" => Function::new_env(store, env.clone(), fd_datasync), - "fd_fdstat_get" => Function::new_env(store, env.clone(), fd_fdstat_get), - "fd_fdstat_set_flags" => Function::new_env(store, env.clone(), fd_fdstat_set_flags), - "fd_fdstat_set_rights" => Function::new_env(store, env.clone(), fd_fdstat_set_rights), - "fd_filestat_get" => Function::new_env(store, env.clone(), fd_filestat_get), - "fd_filestat_set_size" => Function::new_env(store, env.clone(), fd_filestat_set_size), - "fd_filestat_set_times" => Function::new_env(store, env.clone(), fd_filestat_set_times), - "fd_pread" => Function::new_env(store, env.clone(), fd_pread), - "fd_prestat_get" => Function::new_env(store, env.clone(), fd_prestat_get), - "fd_prestat_dir_name" => Function::new_env(store, env.clone(), fd_prestat_dir_name), - "fd_pwrite" => Function::new_env(store, env.clone(), fd_pwrite), - "fd_read" => Function::new_env(store, env.clone(), fd_read), - "fd_readdir" => Function::new_env(store, env.clone(), fd_readdir), - "fd_renumber" => Function::new_env(store, env.clone(), fd_renumber), - "fd_seek" => Function::new_env(store, env.clone(), fd_seek), - "fd_sync" => Function::new_env(store, env.clone(), fd_sync), - "fd_tell" => Function::new_env(store, env.clone(), fd_tell), - "fd_write" => Function::new_env(store, env.clone(), fd_write), - "path_create_directory" => Function::new_env(store, env.clone(), path_create_directory), - "path_filestat_get" => Function::new_env(store, env.clone(), path_filestat_get), - "path_filestat_set_times" => Function::new_env(store, env.clone(), path_filestat_set_times), - "path_link" => Function::new_env(store, env.clone(), path_link), - "path_open" => Function::new_env(store, env.clone(), path_open), - "path_readlink" => Function::new_env(store, env.clone(), path_readlink), - "path_remove_directory" => Function::new_env(store, env.clone(), path_remove_directory), - "path_rename" => Function::new_env(store, env.clone(), path_rename), - "path_symlink" => Function::new_env(store, env.clone(), path_symlink), - "path_unlink_file" => Function::new_env(store, env.clone(), path_unlink_file), - "poll_oneoff" => Function::new_env(store, env.clone(), poll_oneoff), - "proc_exit" => Function::new_env(store, env.clone(), proc_exit), - "proc_raise" => Function::new_env(store, env.clone(), proc_raise), - "random_get" => Function::new_env(store, env.clone(), random_get), - "sched_yield" => Function::new_env(store, env.clone(), sched_yield), - "sock_recv" => Function::new_env(store, env.clone(), sock_recv), - "sock_send" => Function::new_env(store, env.clone(), sock_send), - "sock_shutdown" => Function::new_env(store, env.clone(), sock_shutdown), + "args_get" => Function::new_native_with_env(store, env.clone(), args_get), + "args_sizes_get" => Function::new_native_with_env(store, env.clone(), args_sizes_get), + "clock_res_get" => Function::new_native_with_env(store, env.clone(), clock_res_get), + "clock_time_get" => Function::new_native_with_env(store, env.clone(), clock_time_get), + "environ_get" => Function::new_native_with_env(store, env.clone(), environ_get), + "environ_sizes_get" => Function::new_native_with_env(store, env.clone(), environ_sizes_get), + "fd_advise" => Function::new_native_with_env(store, env.clone(), fd_advise), + "fd_allocate" => Function::new_native_with_env(store, env.clone(), fd_allocate), + "fd_close" => Function::new_native_with_env(store, env.clone(), fd_close), + "fd_datasync" => Function::new_native_with_env(store, env.clone(), fd_datasync), + "fd_fdstat_get" => Function::new_native_with_env(store, env.clone(), fd_fdstat_get), + "fd_fdstat_set_flags" => Function::new_native_with_env(store, env.clone(), fd_fdstat_set_flags), + "fd_fdstat_set_rights" => Function::new_native_with_env(store, env.clone(), fd_fdstat_set_rights), + "fd_filestat_get" => Function::new_native_with_env(store, env.clone(), fd_filestat_get), + "fd_filestat_set_size" => Function::new_native_with_env(store, env.clone(), fd_filestat_set_size), + "fd_filestat_set_times" => Function::new_native_with_env(store, env.clone(), fd_filestat_set_times), + "fd_pread" => Function::new_native_with_env(store, env.clone(), fd_pread), + "fd_prestat_get" => Function::new_native_with_env(store, env.clone(), fd_prestat_get), + "fd_prestat_dir_name" => Function::new_native_with_env(store, env.clone(), fd_prestat_dir_name), + "fd_pwrite" => Function::new_native_with_env(store, env.clone(), fd_pwrite), + "fd_read" => Function::new_native_with_env(store, env.clone(), fd_read), + "fd_readdir" => Function::new_native_with_env(store, env.clone(), fd_readdir), + "fd_renumber" => Function::new_native_with_env(store, env.clone(), fd_renumber), + "fd_seek" => Function::new_native_with_env(store, env.clone(), fd_seek), + "fd_sync" => Function::new_native_with_env(store, env.clone(), fd_sync), + "fd_tell" => Function::new_native_with_env(store, env.clone(), fd_tell), + "fd_write" => Function::new_native_with_env(store, env.clone(), fd_write), + "path_create_directory" => Function::new_native_with_env(store, env.clone(), path_create_directory), + "path_filestat_get" => Function::new_native_with_env(store, env.clone(), path_filestat_get), + "path_filestat_set_times" => Function::new_native_with_env(store, env.clone(), path_filestat_set_times), + "path_link" => Function::new_native_with_env(store, env.clone(), path_link), + "path_open" => Function::new_native_with_env(store, env.clone(), path_open), + "path_readlink" => Function::new_native_with_env(store, env.clone(), path_readlink), + "path_remove_directory" => Function::new_native_with_env(store, env.clone(), path_remove_directory), + "path_rename" => Function::new_native_with_env(store, env.clone(), path_rename), + "path_symlink" => Function::new_native_with_env(store, env.clone(), path_symlink), + "path_unlink_file" => Function::new_native_with_env(store, env.clone(), path_unlink_file), + "poll_oneoff" => Function::new_native_with_env(store, env.clone(), poll_oneoff), + "proc_exit" => Function::new_native_with_env(store, env.clone(), proc_exit), + "proc_raise" => Function::new_native_with_env(store, env.clone(), proc_raise), + "random_get" => Function::new_native_with_env(store, env.clone(), random_get), + "sched_yield" => Function::new_native_with_env(store, env.clone(), sched_yield), + "sock_recv" => Function::new_native_with_env(store, env.clone(), sock_recv), + "sock_send" => Function::new_native_with_env(store, env.clone(), sock_send), + "sock_shutdown" => Function::new_native_with_env(store, env.clone(), sock_shutdown), } } } diff --git a/tests/compilers/imports.rs b/tests/compilers/imports.rs index b978bf88381..d9d1f7a1892 100644 --- a/tests/compilers/imports.rs +++ b/tests/compilers/imports.rs @@ -50,22 +50,22 @@ fn dynamic_function() -> Result<()> { &module, &imports! { "host" => { - "0" => Function::new_dynamic(&store, &FunctionType::new(vec![], vec![]), |_values| { + "0" => Function::new(&store, &FunctionType::new(vec![], vec![]), |_values| { assert_eq!(HITS.fetch_add(1, SeqCst), 0); Ok(vec![]) }), - "1" => Function::new_dynamic(&store, &FunctionType::new(vec![ValType::I32], vec![ValType::I32]), |values| { + "1" => Function::new(&store, &FunctionType::new(vec![ValType::I32], vec![ValType::I32]), |values| { assert_eq!(values[0], Value::I32(0)); assert_eq!(HITS.fetch_add(1, SeqCst), 1); Ok(vec![Value::I32(1)]) }), - "2" => Function::new_dynamic(&store, &FunctionType::new(vec![ValType::I32, ValType::I64], vec![]), |values| { + "2" => Function::new(&store, &FunctionType::new(vec![ValType::I32, ValType::I64], vec![]), |values| { assert_eq!(values[0], Value::I32(2)); assert_eq!(values[1], Value::I64(3)); assert_eq!(HITS.fetch_add(1, SeqCst), 2); Ok(vec![]) }), - "3" => Function::new_dynamic(&store, &FunctionType::new(vec![ValType::I32, ValType::I64, ValType::I32, ValType::F32, ValType::F64], vec![]), |values| { + "3" => Function::new(&store, &FunctionType::new(vec![ValType::I32, ValType::I64, ValType::I32, ValType::F32, ValType::F64], vec![]), |values| { assert_eq!(values[0], Value::I32(100)); assert_eq!(values[1], Value::I64(200)); assert_eq!(values[2], Value::I32(300)); @@ -91,22 +91,22 @@ fn dynamic_function_with_env() -> Result<()> { &module, &imports! { "host" => { - "0" => Function::new_dynamic_env(&store, &FunctionType::new(vec![], vec![]), env.clone(), |env, _values| { + "0" => Function::new_with_env(&store, &FunctionType::new(vec![], vec![]), env.clone(), |env, _values| { assert_eq!(env.fetch_add(1, SeqCst), 0); Ok(vec![]) }), - "1" => Function::new_dynamic_env(&store, &FunctionType::new(vec![ValType::I32], vec![ValType::I32]), env.clone(), |env, values| { + "1" => Function::new_with_env(&store, &FunctionType::new(vec![ValType::I32], vec![ValType::I32]), env.clone(), |env, values| { assert_eq!(values[0], Value::I32(0)); assert_eq!(env.fetch_add(1, SeqCst), 1); Ok(vec![Value::I32(1)]) }), - "2" => Function::new_dynamic_env(&store, &FunctionType::new(vec![ValType::I32, ValType::I64], vec![]), env.clone(), |env, values| { + "2" => Function::new_with_env(&store, &FunctionType::new(vec![ValType::I32, ValType::I64], vec![]), env.clone(), |env, values| { assert_eq!(values[0], Value::I32(2)); assert_eq!(values[1], Value::I64(3)); assert_eq!(env.fetch_add(1, SeqCst), 2); Ok(vec![]) }), - "3" => Function::new_dynamic_env(&store, &FunctionType::new(vec![ValType::I32, ValType::I64, ValType::I32, ValType::F32, ValType::F64], vec![]), env.clone(), |env, values| { + "3" => Function::new_with_env(&store, &FunctionType::new(vec![ValType::I32, ValType::I64, ValType::I32, ValType::F32, ValType::F64], vec![]), env.clone(), |env, values| { assert_eq!(values[0], Value::I32(100)); assert_eq!(values[1], Value::I64(200)); assert_eq!(values[2], Value::I32(300)); @@ -132,20 +132,20 @@ fn static_function() -> Result<()> { &module, &imports! { "host" => { - "0" => Function::new(&store, || { + "0" => Function::new_native(&store, || { assert_eq!(HITS.fetch_add(1, SeqCst), 0); }), - "1" => Function::new(&store, |x: i32| -> i32 { + "1" => Function::new_native(&store, |x: i32| -> i32 { assert_eq!(x, 0); assert_eq!(HITS.fetch_add(1, SeqCst), 1); 1 }), - "2" => Function::new(&store, |x: i32, y: i64| { + "2" => Function::new_native(&store, |x: i32, y: i64| { assert_eq!(x, 2); assert_eq!(y, 3); assert_eq!(HITS.fetch_add(1, SeqCst), 2); }), - "3" => Function::new(&store, |a: i32, b: i64, c: i32, d: f32, e: f64| { + "3" => Function::new_native(&store, |a: i32, b: i64, c: i32, d: f32, e: f64| { assert_eq!(a, 100); assert_eq!(b, 200); assert_eq!(c, 300); @@ -170,20 +170,20 @@ fn static_function_with_results() -> Result<()> { &module, &imports! { "host" => { - "0" => Function::new(&store, || { + "0" => Function::new_native(&store, || { assert_eq!(HITS.fetch_add(1, SeqCst), 0); }), - "1" => Function::new(&store, |x: i32| -> Result { + "1" => Function::new_native(&store, |x: i32| -> Result { assert_eq!(x, 0); assert_eq!(HITS.fetch_add(1, SeqCst), 1); Ok(1) }), - "2" => Function::new(&store, |x: i32, y: i64| { + "2" => Function::new_native(&store, |x: i32, y: i64| { assert_eq!(x, 2); assert_eq!(y, 3); assert_eq!(HITS.fetch_add(1, SeqCst), 2); }), - "3" => Function::new(&store, |a: i32, b: i64, c: i32, d: f32, e: f64| { + "3" => Function::new_native(&store, |a: i32, b: i64, c: i32, d: f32, e: f64| { assert_eq!(a, 100); assert_eq!(b, 200); assert_eq!(c, 300); @@ -208,20 +208,20 @@ fn static_function_with_env() -> Result<()> { &module, &imports! { "host" => { - "0" => Function::new_env(&store, env.clone(), |env: &mut Arc| { + "0" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc| { assert_eq!(env.fetch_add(1, SeqCst), 0); }), - "1" => Function::new_env(&store, env.clone(), |env: &mut Arc, x: i32| -> i32 { + "1" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc, x: i32| -> i32 { assert_eq!(x, 0); assert_eq!(env.fetch_add(1, SeqCst), 1); 1 }), - "2" => Function::new_env(&store, env.clone(), |env: &mut Arc, x: i32, y: i64| { + "2" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc, x: i32, y: i64| { assert_eq!(x, 2); assert_eq!(y, 3); assert_eq!(env.fetch_add(1, SeqCst), 2); }), - "3" => Function::new_env(&store, env.clone(), |env: &mut Arc, a: i32, b: i64, c: i32, d: f32, e: f64| { + "3" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc, a: i32, b: i64, c: i32, d: f32, e: f64| { assert_eq!(a, 100); assert_eq!(b, 200); assert_eq!(c, 300); @@ -256,7 +256,7 @@ fn static_function_that_fails() -> Result<()> { &module, &imports! { "host" => { - "0" => Function::new(&store, || -> Result { + "0" => Function::new_native(&store, || -> Result { Err(RuntimeError::new("oops")) }), }, diff --git a/tests/compilers/multi_value_imports.rs b/tests/compilers/multi_value_imports.rs index c095d71eeed..d580b01b353 100644 --- a/tests/compilers/multi_value_imports.rs +++ b/tests/compilers/multi_value_imports.rs @@ -45,7 +45,7 @@ macro_rules! mvr_test { &module, &wasmer::imports! { "host" => { - "callback_fn" => wasmer::Function::new(&store, callback_fn) + "callback_fn" => wasmer::Function::new_native(&store, callback_fn) } } )?; @@ -67,7 +67,7 @@ macro_rules! mvr_test { fn dynamic() -> anyhow::Result<()> { let store = get_store(); let module = get_module(&store)?; - let callback_fn = wasmer::Function::new_dynamic(&store, &wasmer::FunctionType::new(vec![wasmer::ValType::I32], vec![ $( <$result_type>::expected_valtype() ),* ]), dynamic_callback_fn); + let callback_fn = wasmer::Function::new(&store, &wasmer::FunctionType::new(vec![wasmer::ValType::I32], vec![ $( <$result_type>::expected_valtype() ),* ]), dynamic_callback_fn); let instance = wasmer::Instance::new( &module, &wasmer::imports! { diff --git a/tests/compilers/native_functions.rs b/tests/compilers/native_functions.rs index fe528ff6f33..3cb47d76392 100644 --- a/tests/compilers/native_functions.rs +++ b/tests/compilers/native_functions.rs @@ -22,7 +22,7 @@ fn native_function_works_for_wasm() -> Result<()> { let import_object = imports! { "env" => { - "multiply" => Function::new(&store, |a: i32, b: i32| a * b), + "multiply" => Function::new_native(&store, |a: i32, b: i32| a * b), }, }; @@ -64,7 +64,7 @@ fn static_host_function_without_env() -> anyhow::Result<()> { // Native static host function that returns a tuple. { - let f = Function::new(&store, f); + let f = Function::new_native(&store, f); let f_native: NativeFunc<(i32, i64, f32, f64), (f64, f32, i64, i32)> = f.native().unwrap(); let result = f_native.call(1, 3, 5.0, 7.0)?; assert_eq!(result, (28.0, 15.0, 6, 1)); @@ -72,7 +72,7 @@ fn static_host_function_without_env() -> anyhow::Result<()> { // Native static host function that returns a result of a tuple. { - let f = Function::new(&store, f_ok); + let f = Function::new_native(&store, f_ok); let f_native: NativeFunc<(i32, i64, f32, f64), (f64, f32, i64, i32)> = f.native().unwrap(); let result = f_native.call(1, 3, 5.0, 7.0)?; assert_eq!(result, (28.0, 15.0, 6, 1)); @@ -112,7 +112,7 @@ fn static_host_function_with_env() -> anyhow::Result<()> { { let env = Env(Rc::new(RefCell::new(100))); - let f = Function::new_env(&store, env.clone(), f); + let f = Function::new_native_with_env(&store, env.clone(), f); let f_native: NativeFunc<(i32, i64, f32, f64), (f64, f32, i64, i32)> = f.native().unwrap(); assert_eq!(*env.0.borrow(), 100); @@ -127,7 +127,7 @@ fn static_host_function_with_env() -> anyhow::Result<()> { { let env = Env(Rc::new(RefCell::new(100))); - let f = Function::new_env(&store, env.clone(), f); + let f = Function::new_native_with_env(&store, env.clone(), f); let f_native: NativeFunc<(i32, i64, f32, f64), (f64, f32, i64, i32)> = f.native().unwrap(); assert_eq!(*env.0.borrow(), 100); @@ -145,7 +145,7 @@ fn static_host_function_with_env() -> anyhow::Result<()> { fn dynamic_host_function_without_env() -> anyhow::Result<()> { let store = get_store(); - let f = Function::new_dynamic( + let f = Function::new( &store, &FunctionType::new( vec![ValType::I32, ValType::I64, ValType::F32, ValType::F64], @@ -176,7 +176,7 @@ fn dynamic_host_function_with_env() -> anyhow::Result<()> { struct Env(Rc>); let env = Env(Rc::new(RefCell::new(100))); - let f = Function::new_dynamic_env( + let f = Function::new_with_env( &store, &FunctionType::new( vec![ValType::I32, ValType::I64, ValType::F32, ValType::F64], diff --git a/tests/compilers/serialize.rs b/tests/compilers/serialize.rs index f1d2905036c..db1b0957b0d 100644 --- a/tests/compilers/serialize.rs +++ b/tests/compilers/serialize.rs @@ -58,7 +58,7 @@ fn test_deserialize() -> Result<()> { &module, &imports! { "host" => { - "sum_part" => Function::new_dynamic(&store, &func_type, |params| { + "sum_part" => Function::new(&store, &func_type, |params| { let param_0: i64 = params[0].unwrap_i32() as i64; let param_1: i64 = params[1].unwrap_i64() as i64; let param_2: i64 = params[2].unwrap_i32() as i64; diff --git a/tests/compilers/traps.rs b/tests/compilers/traps.rs index 5af1e499c66..b74c280bd45 100644 --- a/tests/compilers/traps.rs +++ b/tests/compilers/traps.rs @@ -15,8 +15,7 @@ fn test_trap_return() -> Result<()> { let module = Module::new(&store, wat)?; let hello_type = FunctionType::new(vec![], vec![]); - let hello_func = - Function::new_dynamic(&store, &hello_type, |_| Err(RuntimeError::new("test 123"))); + let hello_func = Function::new(&store, &hello_type, |_| Err(RuntimeError::new("test 123"))); let instance = Instance::new( &module, @@ -87,7 +86,7 @@ fn test_trap_trace_cb() -> Result<()> { "#; let fn_type = FunctionType::new(vec![], vec![]); - let fn_func = Function::new_dynamic(&store, &fn_type, |_| Err(RuntimeError::new("cb throw"))); + let fn_func = Function::new(&store, &fn_type, |_| Err(RuntimeError::new("cb throw"))); let module = Module::new(&store, wat)?; let instance = Instance::new( @@ -247,7 +246,7 @@ fn trap_start_function_import() -> Result<()> { let module = Module::new(&store, &binary)?; let sig = FunctionType::new(vec![], vec![]); - let func = Function::new_dynamic(&store, &sig, |_| Err(RuntimeError::new("user trap"))); + let func = Function::new(&store, &sig, |_| Err(RuntimeError::new("user trap"))); let err = Instance::new( &module, &imports! { @@ -282,13 +281,13 @@ fn rust_panic_import() -> Result<()> { let module = Module::new(&store, &binary)?; let sig = FunctionType::new(vec![], vec![]); - let func = Function::new_dynamic(&store, &sig, |_| panic!("this is a panic")); + let func = Function::new(&store, &sig, |_| panic!("this is a panic")); let instance = Instance::new( &module, &imports! { "" => { "foo" => func, - "bar" => Function::new(&store, || panic!("this is another panic")) + "bar" => Function::new_native(&store, || panic!("this is another panic")) } }, )?; @@ -325,7 +324,7 @@ fn rust_panic_start_function() -> Result<()> { let module = Module::new(&store, &binary)?; let sig = FunctionType::new(vec![], vec![]); - let func = Function::new_dynamic(&store, &sig, |_| panic!("this is a panic")); + let func = Function::new(&store, &sig, |_| panic!("this is a panic")); let err = panic::catch_unwind(AssertUnwindSafe(|| { drop(Instance::new( &module, @@ -339,7 +338,7 @@ fn rust_panic_start_function() -> Result<()> { .unwrap_err(); assert_eq!(err.downcast_ref::<&'static str>(), Some(&"this is a panic")); - let func = Function::new(&store, || panic!("this is another panic")); + let func = Function::new_native(&store, || panic!("this is another panic")); let err = panic::catch_unwind(AssertUnwindSafe(|| { drop(Instance::new( &module, diff --git a/tests/lib/wast/src/spectest.rs b/tests/lib/wast/src/spectest.rs index a1a28a22fcb..7e956c7134b 100644 --- a/tests/lib/wast/src/spectest.rs +++ b/tests/lib/wast/src/spectest.rs @@ -3,16 +3,16 @@ use wasmer::*; /// Return an instance implementing the "spectest" interface used in the /// spec testsuite. pub fn spectest_importobject(store: &Store) -> ImportObject { - let print = Function::new(store, || {}); - let print_i32 = Function::new(store, |val: i32| println!("{}: i32", val)); - let print_i64 = Function::new(store, |val: i64| println!("{}: i64", val)); - let print_f32 = Function::new(store, |val: f32| println!("{}: f32", val)); - let print_f64 = Function::new(store, |val: f64| println!("{}: f64", val)); - let print_i32_f32 = Function::new(store, |i: i32, f: f32| { + let print = Function::new_native(store, || {}); + let print_i32 = Function::new_native(store, |val: i32| println!("{}: i32", val)); + let print_i64 = Function::new_native(store, |val: i64| println!("{}: i64", val)); + let print_f32 = Function::new_native(store, |val: f32| println!("{}: f32", val)); + let print_f64 = Function::new_native(store, |val: f64| println!("{}: f64", val)); + let print_i32_f32 = Function::new_native(store, |i: i32, f: f32| { println!("{}: i32", i); println!("{}: f32", f); }); - let print_f64_f64 = Function::new(store, |f1: f64, f2: f64| { + let print_f64_f64 = Function::new_native(store, |f1: f64, f2: f64| { println!("{}: f64", f1); println!("{}: f64", f2); });