From a97f339687263b25ed65067d35c229a7445fa4e9 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 30 Sep 2020 17:30:17 -0700 Subject: [PATCH 1/2] Make Function Env immutable Work in progress, we still have to update Emscripten --- lib/api/src/externals/function.rs | 23 +++--- lib/api/src/native.rs | 6 +- lib/vm/src/export.rs | 2 +- lib/vm/src/instance.rs | 10 +-- lib/vm/src/trap/traphandlers.rs | 10 +-- lib/vm/src/vmcontext.rs | 4 +- lib/wasi/src/lib.rs | 2 +- lib/wasi/src/syscalls/legacy/snapshot0.rs | 8 +- lib/wasi/src/syscalls/mod.rs | 94 +++++++++++------------ tests/compilers/imports.rs | 8 +- tests/compilers/native_functions.rs | 10 +-- 11 files changed, 82 insertions(+), 95 deletions(-) diff --git a/lib/api/src/externals/function.rs b/lib/api/src/externals/function.rs index fcf00b74342..f32cbf811b8 100644 --- a/lib/api/src/externals/function.rs +++ b/lib/api/src/externals/function.rs @@ -6,7 +6,6 @@ use crate::FunctionType; use crate::NativeFunc; use crate::RuntimeError; pub use inner::{FromToNativeWasmType, HostFunction, WasmTypeList, WithEnv, WithoutEnv}; -use std::cell::RefCell; use std::cmp::max; use std::fmt; use wasmer_vm::{ @@ -122,11 +121,11 @@ impl Function { #[allow(clippy::cast_ptr_alignment)] pub fn new_with_env(store: &Store, ty: &FunctionType, env: Env, func: F) -> Self where - F: Fn(&mut Env, &[Val]) -> Result, RuntimeError> + 'static, + F: Fn(&Env, &[Val]) -> Result, RuntimeError> + 'static, Env: Sized + 'static, { let dynamic_ctx = VMDynamicFunctionContext::from_context(VMDynamicFunctionWithEnv { - env: RefCell::new(env), + env: Box::new(env), func: Box::new(func), function_type: ty.clone(), }); @@ -205,7 +204,7 @@ impl Function { /// }; /// let env = Env { multiplier: 2 }; /// - /// fn sum_and_multiply(env: &mut Env, a: i32, b: i32) -> i32 { + /// fn sum_and_multiply(env: &Env, a: i32, b: i32) -> i32 { /// (a + b) * env.multiplier /// } /// @@ -227,7 +226,7 @@ impl Function { // 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 vmctx = Box::into_raw(box_env) as *mut _ as *const VMContext; let signature = function.ty(); Self { @@ -469,8 +468,8 @@ where { function_type: FunctionType, #[allow(clippy::type_complexity)] - func: Box Result, RuntimeError> + 'static>, - env: RefCell, + func: Box Result, RuntimeError> + 'static>, + env: Box, } impl VMDynamicFunction for VMDynamicFunctionWithEnv @@ -478,9 +477,7 @@ where Env: Sized + 'static, { fn call(&self, args: &[Val]) -> Result, RuntimeError> { - // TODO: the `&mut *self.env.as_ptr()` is likely invoking some "mild" - // undefined behavior due to how it's used in the static fn call - unsafe { (*self.func)(&mut *self.env.as_ptr(), &args) } + (*self.func)(&*self.env, &args) } fn function_type(&self) -> &FunctionType { &self.function_type @@ -1015,20 +1012,20 @@ mod inner { Rets: WasmTypeList, RetsAsResult: IntoResult, Env: Sized, - Func: Fn(&mut Env, $( $x , )*) -> RetsAsResult + Send + 'static, + Func: Fn(&Env, $( $x , )*) -> RetsAsResult + Send + 'static, { #[allow(non_snake_case)] fn function_body_ptr(self) -> *const VMFunctionBody { /// This is a function that wraps the real host /// function. Its address will be used inside the /// runtime. - extern fn func_wrapper<$( $x, )* Rets, RetsAsResult, Env, Func>( env: &mut Env, $( $x: $x::Native, )* ) -> Rets::CStruct + extern fn func_wrapper<$( $x, )* Rets, RetsAsResult, Env, Func>( env: &Env, $( $x: $x::Native, )* ) -> Rets::CStruct where $( $x: FromToNativeWasmType, )* Rets: WasmTypeList, RetsAsResult: IntoResult, Env: Sized, - Func: Fn(&mut Env, $( $x ),* ) -> RetsAsResult + 'static + Func: Fn(&Env, $( $x ),* ) -> RetsAsResult + 'static { let func: &Func = unsafe { &*(&() as *const () as *const Func) }; diff --git a/lib/api/src/native.rs b/lib/api/src/native.rs index 5a73083f2cb..6f518de063c 100644 --- a/lib/api/src/native.rs +++ b/lib/api/src/native.rs @@ -26,7 +26,7 @@ pub struct NativeFunc<'a, Args = (), Rets = ()> { definition: FunctionDefinition, store: Store, address: *const VMFunctionBody, - vmctx: *mut VMContext, + vmctx: *const VMContext, arg_kind: VMFunctionKind, // exported: ExportFunction, _phantom: PhantomData<(&'a (), Args, Rets)>, @@ -42,7 +42,7 @@ where pub(crate) fn new( store: Store, address: *const VMFunctionBody, - vmctx: *mut VMContext, + vmctx: *const VMContext, arg_kind: VMFunctionKind, definition: FunctionDefinition, ) -> Self { @@ -163,7 +163,7 @@ macro_rules! impl_native_traits { match self.arg_kind { VMFunctionKind::Static => { let results = catch_unwind(AssertUnwindSafe(|| unsafe { - let f = std::mem::transmute::<_, unsafe extern "C" fn( *mut VMContext, $( $x, )*) -> Rets::CStruct>(self.address); + let f = std::mem::transmute::<_, unsafe extern "C" fn( *const VMContext, $( $x, )*) -> Rets::CStruct>(self.address); // We always pass the vmctx f( self.vmctx, $( $x, )* ) })).map_err(|e| RuntimeError::new(format!("{:?}", e)))?; diff --git a/lib/vm/src/export.rs b/lib/vm/src/export.rs index 7879c92d16a..4567d860809 100644 --- a/lib/vm/src/export.rs +++ b/lib/vm/src/export.rs @@ -30,7 +30,7 @@ pub struct ExportFunction { /// The address of the native-code function. pub address: *const VMFunctionBody, /// Pointer to the containing `VMContext`. - pub vmctx: *mut VMContext, + pub vmctx: *const VMContext, /// The function type, used for compatibility checking. pub signature: FunctionType, /// The function kind (it defines how it's the signature that provided `address` have) diff --git a/lib/vm/src/instance.rs b/lib/vm/src/instance.rs index b38e9594a18..c1eb81ccb4b 100644 --- a/lib/vm/src/instance.rs +++ b/lib/vm/src/instance.rs @@ -272,8 +272,8 @@ impl Instance { } /// Return a raw pointer to the vmctx used by compiled wasm code. - pub fn vmctx_ptr(&self) -> *mut VMContext { - self.vmctx() as *const VMContext as *mut VMContext + pub fn vmctx_ptr(&self) -> *const VMContext { + self.vmctx() as *const VMContext } /// Lookup an export with the given name. @@ -384,7 +384,7 @@ impl Instance { // Make the call. unsafe { catch_traps(callee_vmctx, || { - mem::transmute::<*const VMFunctionBody, unsafe extern "C" fn(*mut VMContext)>( + mem::transmute::<*const VMFunctionBody, unsafe extern "C" fn(*const VMContext)>( callee_address, )(callee_vmctx) }) @@ -940,7 +940,7 @@ impl InstanceHandle { /// # Safety /// This is unsafe because it doesn't work on just any `VMContext`, it must /// be a `VMContext` allocated as part of an `Instance`. - pub unsafe fn from_vmctx(vmctx: *mut VMContext) -> Self { + pub unsafe fn from_vmctx(vmctx: *const VMContext) -> Self { let instance = (&*vmctx).instance(); Self { @@ -954,7 +954,7 @@ impl InstanceHandle { } /// Return a raw pointer to the vmctx used by compiled wasm code. - pub fn vmctx_ptr(&self) -> *mut VMContext { + pub fn vmctx_ptr(&self) -> *const VMContext { self.instance().vmctx_ptr() } diff --git a/lib/vm/src/trap/traphandlers.rs b/lib/vm/src/trap/traphandlers.rs index 613e8ec1035..be5783602bf 100644 --- a/lib/vm/src/trap/traphandlers.rs +++ b/lib/vm/src/trap/traphandlers.rs @@ -429,13 +429,13 @@ impl Trap { /// Wildly unsafe because it calls raw function pointers and reads/writes raw /// function pointers. pub unsafe fn wasmer_call_trampoline( - vmctx: *mut VMContext, + vmctx: *const VMContext, trampoline: VMTrampoline, callee: *const VMFunctionBody, values_vec: *mut u8, ) -> Result<(), Trap> { catch_traps(vmctx, || { - mem::transmute::<_, extern "C" fn(*mut VMContext, *const VMFunctionBody, *mut u8)>( + mem::transmute::<_, extern "C" fn(*const VMContext, *const VMFunctionBody, *mut u8)>( trampoline, )(vmctx, callee, values_vec) }) @@ -447,7 +447,7 @@ pub unsafe fn wasmer_call_trampoline( /// # Safety /// /// Highly unsafe since `closure` won't have any destructors run. -pub unsafe fn catch_traps(vmctx: *mut VMContext, mut closure: F) -> Result<(), Trap> +pub unsafe fn catch_traps(vmctx: *const VMContext, mut closure: F) -> Result<(), Trap> where F: FnMut(), { @@ -501,7 +501,7 @@ pub struct CallThreadState { jmp_buf: Cell<*const u8>, reset_guard_page: Cell, prev: Option<*const CallThreadState>, - vmctx: *mut VMContext, + vmctx: *const VMContext, handling_trap: Cell, } @@ -518,7 +518,7 @@ enum UnwindReason { } impl CallThreadState { - fn new(vmctx: *mut VMContext) -> Self { + fn new(vmctx: *const VMContext) -> Self { Self { unwind: Cell::new(UnwindReason::None), vmctx, diff --git a/lib/vm/src/vmcontext.rs b/lib/vm/src/vmcontext.rs index 367a207629c..0cf8477baa2 100644 --- a/lib/vm/src/vmcontext.rs +++ b/lib/vm/src/vmcontext.rs @@ -23,7 +23,7 @@ pub struct VMFunctionImport { pub body: *const VMFunctionBody, /// A pointer to the `VMContext` that owns the function. - pub vmctx: *mut VMContext, + pub vmctx: *const VMContext, } #[cfg(test)] @@ -729,7 +729,7 @@ pub struct VMCallerCheckedAnyfunc { /// Function signature id. pub type_index: VMSharedSignatureIndex, /// Function `VMContext`. - pub vmctx: *mut VMContext, + pub vmctx: *const VMContext, // If more elements are added here, remember to add offset_of tests below! } diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 74a0fab3819..60f83590f86 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -174,7 +174,7 @@ impl WasiEnv { } pub(crate) fn get_memory_and_wasi_state( - &mut self, + &self, _mem_index: u32, ) -> (&Memory, MutexGuard) { let memory = self.memory(); diff --git a/lib/wasi/src/syscalls/legacy/snapshot0.rs b/lib/wasi/src/syscalls/legacy/snapshot0.rs index f955b68b231..717b284187f 100644 --- a/lib/wasi/src/syscalls/legacy/snapshot0.rs +++ b/lib/wasi/src/syscalls/legacy/snapshot0.rs @@ -10,7 +10,7 @@ use crate::WasiEnv; /// Wasm memory. If the memory clobbered by the current syscall is also used by /// that syscall, then it may break. pub fn fd_filestat_get( - env: &mut WasiEnv, + env: &WasiEnv, fd: types::__wasi_fd_t, buf: WasmPtr, ) -> types::__wasi_errno_t { @@ -61,7 +61,7 @@ pub fn fd_filestat_get( /// Wrapper around `syscalls::path_filestat_get` with extra logic to handle the size /// difference of `wasi_filestat_t` pub fn path_filestat_get( - env: &mut WasiEnv, + env: &WasiEnv, fd: types::__wasi_fd_t, flags: types::__wasi_lookupflags_t, path: WasmPtr, @@ -100,7 +100,7 @@ pub fn path_filestat_get( /// Wrapper around `syscalls::fd_seek` with extra logic to remap the values /// of `__wasi_whence_t` pub fn fd_seek( - env: &mut WasiEnv, + env: &WasiEnv, fd: types::__wasi_fd_t, offset: types::__wasi_filedelta_t, whence: snapshot0::__wasi_whence_t, @@ -119,7 +119,7 @@ pub fn fd_seek( /// Wrapper around `syscalls::poll_oneoff` with extra logic to add the removed /// userdata field back pub fn poll_oneoff( - env: &mut WasiEnv, + env: &WasiEnv, in_: WasmPtr, out_: WasmPtr, nsubscriptions: u32, diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 6fbd345ff5a..affd98bf83f 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -135,7 +135,7 @@ fn get_current_time_in_nanos() -> Result<__wasi_timestamp_t, __wasi_errno_t> { /// A pointer to a buffer to write the argument string data. /// pub fn args_get( - env: &mut WasiEnv, + env: &WasiEnv, argv: WasmPtr, Array>, argv_buf: WasmPtr, ) -> __wasi_errno_t { @@ -170,7 +170,7 @@ pub fn args_get( /// - `size_t *argv_buf_size` /// The size of the argument string data. pub fn args_sizes_get( - env: &mut WasiEnv, + env: &WasiEnv, argc: WasmPtr, argv_buf_size: WasmPtr, ) -> __wasi_errno_t { @@ -199,7 +199,7 @@ pub fn args_sizes_get( /// - `__wasi_timestamp_t *resolution` /// The resolution of the clock in nanoseconds pub fn clock_res_get( - env: &mut WasiEnv, + env: &WasiEnv, clock_id: __wasi_clockid_t, resolution: WasmPtr<__wasi_timestamp_t>, ) -> __wasi_errno_t { @@ -221,7 +221,7 @@ pub fn clock_res_get( /// - `__wasi_timestamp_t *time` /// The value of the clock in nanoseconds pub fn clock_time_get( - env: &mut WasiEnv, + env: &WasiEnv, clock_id: __wasi_clockid_t, precision: __wasi_timestamp_t, time: WasmPtr<__wasi_timestamp_t>, @@ -251,7 +251,7 @@ pub fn clock_time_get( /// - `char *environ_buf` /// A pointer to a buffer to write the environment variable string data. pub fn environ_get( - env: &mut WasiEnv, + env: &WasiEnv, environ: WasmPtr, Array>, environ_buf: WasmPtr, ) -> __wasi_errno_t { @@ -269,7 +269,7 @@ pub fn environ_get( /// - `size_t *environ_buf_size` /// The size of the environment variable string data. pub fn environ_sizes_get( - env: &mut WasiEnv, + env: &WasiEnv, environ_count: WasmPtr, environ_buf_size: WasmPtr, ) -> __wasi_errno_t { @@ -304,7 +304,7 @@ pub fn environ_sizes_get( /// - `__wasi_advice_t advice` /// The advice to give pub fn fd_advise( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, offset: __wasi_filesize_t, len: __wasi_filesize_t, @@ -327,7 +327,7 @@ pub fn fd_advise( /// - `__wasi_filesize_t len` /// The length from the offset marking the end of the allocation pub fn fd_allocate( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, offset: __wasi_filesize_t, len: __wasi_filesize_t, @@ -372,7 +372,7 @@ pub fn fd_allocate( /// If `fd` is a directory /// - `__WASI_EBADF` /// If `fd` is invalid or not open -pub fn fd_close(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { +pub fn fd_close(env: &WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { debug!("wasi::fd_close: fd={}", fd); let (memory, mut state) = env.get_memory_and_wasi_state(0); @@ -388,7 +388,7 @@ pub fn fd_close(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { /// Inputs: /// - `__wasi_fd_t fd` /// The file descriptor to sync -pub fn fd_datasync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { +pub fn fd_datasync(env: &WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { debug!("wasi::fd_datasync"); let (memory, mut state) = env.get_memory_and_wasi_state(0); let fd_entry = wasi_try!(state.fs.get_fd(fd)); @@ -412,7 +412,7 @@ pub fn fd_datasync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { /// - `__wasi_fdstat_t *buf` /// The location where the metadata will be written pub fn fd_fdstat_get( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, buf_ptr: WasmPtr<__wasi_fdstat_t>, ) -> __wasi_errno_t { @@ -440,7 +440,7 @@ pub fn fd_fdstat_get( /// - `__wasi_fdflags_t flags` /// The flags to apply to `fd` pub fn fd_fdstat_set_flags( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, flags: __wasi_fdflags_t, ) -> __wasi_errno_t { @@ -466,7 +466,7 @@ pub fn fd_fdstat_set_flags( /// - `__wasi_rights_t fs_rights_inheriting` /// The inheriting rights to apply to `fd` pub fn fd_fdstat_set_rights( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, fs_rights_base: __wasi_rights_t, fs_rights_inheriting: __wasi_rights_t, @@ -497,7 +497,7 @@ pub fn fd_fdstat_set_rights( /// - `__wasi_filestat_t *buf` /// Where the metadata from `fd` will be written pub fn fd_filestat_get( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, buf: WasmPtr<__wasi_filestat_t>, ) -> __wasi_errno_t { @@ -524,7 +524,7 @@ pub fn fd_filestat_get( /// - `__wasi_filesize_t st_size` /// New size that `fd` will be set to pub fn fd_filestat_set_size( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, st_size: __wasi_filesize_t, ) -> __wasi_errno_t { @@ -566,7 +566,7 @@ pub fn fd_filestat_set_size( /// - `__wasi_fstflags_t fst_flags` /// Bit-vector for controlling which times get set pub fn fd_filestat_set_times( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, st_atim: __wasi_timestamp_t, st_mtim: __wasi_timestamp_t, @@ -639,7 +639,7 @@ pub fn fd_filestat_set_times( /// - `size_t nread` /// The number of bytes read pub fn fd_pread( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, iovs: WasmPtr<__wasi_iovec_t, Array>, iovs_len: u32, @@ -712,7 +712,7 @@ pub fn fd_pread( /// - `__wasi_prestat *buf` /// Where the metadata will be written pub fn fd_prestat_get( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, buf: WasmPtr<__wasi_prestat_t>, ) -> __wasi_errno_t { @@ -727,7 +727,7 @@ pub fn fd_prestat_get( } pub fn fd_prestat_dir_name( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, path: WasmPtr, path_len: u32, @@ -787,7 +787,7 @@ pub fn fd_prestat_dir_name( /// - `u32 *nwritten` /// Number of bytes written pub fn fd_pwrite( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, iovs: WasmPtr<__wasi_ciovec_t, Array>, iovs_len: u32, @@ -873,7 +873,7 @@ pub fn fd_pwrite( /// - `u32 *nread` /// Number of bytes read pub fn fd_read( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, iovs: WasmPtr<__wasi_iovec_t, Array>, iovs_len: u32, @@ -956,7 +956,7 @@ pub fn fd_read( /// The Number of bytes stored in `buf`; if less than `buf_len` then entire /// directory has been read pub fn fd_readdir( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, buf: WasmPtr, buf_len: u32, @@ -1072,7 +1072,7 @@ pub fn fd_readdir( /// File descriptor to copy /// - `__wasi_fd_t to` /// Location to copy file descriptor to -pub fn fd_renumber(env: &mut WasiEnv, from: __wasi_fd_t, to: __wasi_fd_t) -> __wasi_errno_t { +pub fn fd_renumber(env: &WasiEnv, from: __wasi_fd_t, to: __wasi_fd_t) -> __wasi_errno_t { debug!("wasi::fd_renumber: from={}, to={}", from, to); let (memory, mut state) = env.get_memory_and_wasi_state(0); let fd_entry = wasi_try!(state.fs.fd_map.get(&from).ok_or(__WASI_EBADF)); @@ -1100,7 +1100,7 @@ pub fn fd_renumber(env: &mut WasiEnv, from: __wasi_fd_t, to: __wasi_fd_t) -> __w /// - `__wasi_filesize_t *fd` /// The new offset relative to the start of the file pub fn fd_seek( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, offset: __wasi_filedelta_t, whence: __wasi_whence_t, @@ -1168,7 +1168,7 @@ pub fn fd_seek( /// TODO: figure out which errors this should return /// - `__WASI_EPERM` /// - `__WASI_ENOTCAPABLE` -pub fn fd_sync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { +pub fn fd_sync(env: &WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { debug!("wasi::fd_sync"); debug!("=> fd={}", fd); let (memory, mut state) = env.get_memory_and_wasi_state(0); @@ -1203,7 +1203,7 @@ pub fn fd_sync(env: &mut WasiEnv, fd: __wasi_fd_t) -> __wasi_errno_t { /// - `__wasi_filesize_t *offset` /// The offset of `fd` relative to the start of the file pub fn fd_tell( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, offset: WasmPtr<__wasi_filesize_t>, ) -> __wasi_errno_t { @@ -1237,7 +1237,7 @@ pub fn fd_tell( /// Errors: /// pub fn fd_write( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, iovs: WasmPtr<__wasi_ciovec_t, Array>, iovs_len: u32, @@ -1333,7 +1333,7 @@ pub fn fd_write( /// - __WASI_RIGHT_PATH_CREATE_DIRECTORY /// This right must be set on the directory that the file is created in (TODO: verify that this is true) pub fn path_create_directory( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, path: WasmPtr, path_len: u32, @@ -1436,7 +1436,7 @@ pub fn path_create_directory( /// - `__wasi_file_stat_t *buf` /// The location where the metadata will be stored pub fn path_filestat_get( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, flags: __wasi_lookupflags_t, path: WasmPtr, @@ -1493,7 +1493,7 @@ pub fn path_filestat_get( /// - `__wasi_fstflags_t fst_flags` /// A bitmask controlling which attributes are set pub fn path_filestat_set_times( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, flags: __wasi_lookupflags_t, path: WasmPtr, @@ -1581,7 +1581,7 @@ pub fn path_filestat_set_times( /// - `u32 old_path_len` /// Length of the `new_path` string pub fn path_link( - env: &mut WasiEnv, + env: &WasiEnv, old_fd: __wasi_fd_t, old_flags: __wasi_lookupflags_t, old_path: WasmPtr, @@ -1664,7 +1664,7 @@ pub fn path_link( /// Possible Errors: /// - `__WASI_EACCES`, `__WASI_EBADF`, `__WASI_EFAULT`, `__WASI_EFBIG?`, `__WASI_EINVAL`, `__WASI_EIO`, `__WASI_ELOOP`, `__WASI_EMFILE`, `__WASI_ENAMETOOLONG?`, `__WASI_ENFILE`, `__WASI_ENOENT`, `__WASI_ENOTDIR`, `__WASI_EROFS`, and `__WASI_ENOTCAPABLE` pub fn path_open( - env: &mut WasiEnv, + env: &WasiEnv, dirfd: __wasi_fd_t, dirflags: __wasi_lookupflags_t, path: WasmPtr, @@ -1901,7 +1901,7 @@ pub fn path_open( /// - `u32 buf_used` /// The number of bytes written to `buf` pub fn path_readlink( - env: &mut WasiEnv, + env: &WasiEnv, dir_fd: __wasi_fd_t, path: WasmPtr, path_len: u32, @@ -1946,7 +1946,7 @@ pub fn path_readlink( /// Returns __WASI_ENOTEMTPY if directory is not empty pub fn path_remove_directory( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, path: WasmPtr, path_len: u32, @@ -2022,7 +2022,7 @@ pub fn path_remove_directory( /// - `u32 new_path_len` /// The number of bytes to read from `new_path` pub fn path_rename( - env: &mut WasiEnv, + env: &WasiEnv, old_fd: __wasi_fd_t, old_path: WasmPtr, old_path_len: u32, @@ -2131,7 +2131,7 @@ pub fn path_rename( /// - `u32 new_path_len` /// The number of bytes to read from `new_path` pub fn path_symlink( - env: &mut WasiEnv, + env: &WasiEnv, old_path: WasmPtr, old_path_len: u32, fd: __wasi_fd_t, @@ -2210,7 +2210,7 @@ pub fn path_symlink( /// - `u32 path_len` /// The number of bytes in the `path` array pub fn path_unlink_file( - env: &mut WasiEnv, + env: &WasiEnv, fd: __wasi_fd_t, path: WasmPtr, path_len: u32, @@ -2304,7 +2304,7 @@ pub fn path_unlink_file( /// - `u32 nevents` /// The number of events seen pub fn poll_oneoff( - env: &mut WasiEnv, + env: &WasiEnv, in_: WasmPtr<__wasi_subscription_t, Array>, out_: WasmPtr<__wasi_event_t, Array>, nsubscriptions: u32, @@ -2490,13 +2490,13 @@ pub fn poll_oneoff( __WASI_ESUCCESS } -pub fn proc_exit(env: &mut WasiEnv, code: __wasi_exitcode_t) { +pub fn proc_exit(env: &WasiEnv, code: __wasi_exitcode_t) { debug!("wasi::proc_exit, {}", code); RuntimeError::raise(Box::new(WasiError::Exit(code))); unreachable!(); } -pub fn proc_raise(env: &mut WasiEnv, sig: __wasi_signal_t) -> __wasi_errno_t { +pub fn proc_raise(env: &WasiEnv, sig: __wasi_signal_t) -> __wasi_errno_t { debug!("wasi::proc_raise"); unimplemented!("wasi::proc_raise") } @@ -2508,7 +2508,7 @@ pub fn proc_raise(env: &mut WasiEnv, sig: __wasi_signal_t) -> __wasi_errno_t { /// A pointer to a buffer where the random bytes will be written /// - `size_t buf_len` /// The number of bytes that will be written -pub fn random_get(env: &mut WasiEnv, buf: WasmPtr, buf_len: u32) -> __wasi_errno_t { +pub fn random_get(env: &WasiEnv, buf: WasmPtr, buf_len: u32) -> __wasi_errno_t { debug!("wasi::random_get buf_len: {}", buf_len); let memory = env.memory(); @@ -2526,14 +2526,14 @@ pub fn random_get(env: &mut WasiEnv, buf: WasmPtr, buf_len: u32) -> _ /// ### `sched_yield()` /// Yields execution of the thread -pub fn sched_yield(env: &mut WasiEnv) -> __wasi_errno_t { +pub fn sched_yield(env: &WasiEnv) -> __wasi_errno_t { debug!("wasi::sched_yield"); ::std::thread::yield_now(); __WASI_ESUCCESS } pub fn sock_recv( - env: &mut WasiEnv, + env: &WasiEnv, sock: __wasi_fd_t, ri_data: WasmPtr<__wasi_iovec_t, Array>, ri_data_len: u32, @@ -2545,7 +2545,7 @@ pub fn sock_recv( unimplemented!("wasi::sock_recv") } pub fn sock_send( - env: &mut WasiEnv, + env: &WasiEnv, sock: __wasi_fd_t, si_data: WasmPtr<__wasi_ciovec_t, Array>, si_data_len: u32, @@ -2555,11 +2555,7 @@ pub fn sock_send( debug!("wasi::sock_send"); unimplemented!("wasi::sock_send") } -pub fn sock_shutdown( - env: &mut WasiEnv, - sock: __wasi_fd_t, - how: __wasi_sdflags_t, -) -> __wasi_errno_t { +pub fn sock_shutdown(env: &WasiEnv, sock: __wasi_fd_t, how: __wasi_sdflags_t) -> __wasi_errno_t { debug!("wasi::sock_shutdown"); unimplemented!("wasi::sock_shutdown") } diff --git a/tests/compilers/imports.rs b/tests/compilers/imports.rs index fa7a34bd4fb..94793c4fabf 100644 --- a/tests/compilers/imports.rs +++ b/tests/compilers/imports.rs @@ -208,20 +208,20 @@ fn static_function_with_env() -> Result<()> { &module, &imports! { "host" => { - "0" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc| { + "0" => Function::new_native_with_env(&store, env.clone(), |env: &Arc| { assert_eq!(env.fetch_add(1, SeqCst), 0); }), - "1" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc, x: i32| -> i32 { + "1" => Function::new_native_with_env(&store, env.clone(), |env: &Arc, x: i32| -> i32 { assert_eq!(x, 0); assert_eq!(env.fetch_add(1, SeqCst), 1); 1 }), - "2" => Function::new_native_with_env(&store, env.clone(), |env: &mut Arc, x: i32, y: i64| { + "2" => Function::new_native_with_env(&store, env.clone(), |env: &Arc, x: i32, y: i64| { assert_eq!(x, 2); assert_eq!(y, 3); assert_eq!(env.fetch_add(1, SeqCst), 2); }), - "3" => Function::new_native_with_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: &Arc, a: i32, b: i64, c: i32, d: f32, e: f64| { assert_eq!(a, 100); assert_eq!(b, 200); assert_eq!(c, 300); diff --git a/tests/compilers/native_functions.rs b/tests/compilers/native_functions.rs index 3a37cb31b7f..04e49bc2b30 100644 --- a/tests/compilers/native_functions.rs +++ b/tests/compilers/native_functions.rs @@ -85,20 +85,14 @@ fn static_host_function_without_env() -> anyhow::Result<()> { fn static_host_function_with_env() -> anyhow::Result<()> { let store = get_store(); - fn f(env: &mut Env, a: i32, b: i64, c: f32, d: f64) -> (f64, f32, i64, i32) { + fn f(env: &Env, a: i32, b: i64, c: f32, d: f64) -> (f64, f32, i64, i32) { assert_eq!(*env.0.borrow(), 100); env.0.replace(101); (d * 4.0, c * 3.0, b * 2, a * 1) } - fn f_ok( - env: &mut Env, - a: i32, - b: i64, - c: f32, - d: f64, - ) -> Result<(f64, f32, i64, i32), Infallible> { + fn f_ok(env: &Env, a: i32, b: i64, c: f32, d: f64) -> Result<(f64, f32, i64, i32), Infallible> { assert_eq!(*env.0.borrow(), 100); env.0.replace(101); From cbe91d7141cf985f846d5d7435a276e019ecc882 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 30 Sep 2020 17:41:40 -0700 Subject: [PATCH 2/2] Make EmEnv immutable --- lib/emscripten/src/bitwise.rs | 2 +- lib/emscripten/src/emscripten_target.rs | 148 +++++++++++------------ lib/emscripten/src/env/mod.rs | 22 ++-- lib/emscripten/src/env/unix/mod.rs | 18 +-- lib/emscripten/src/env/windows/mod.rs | 18 +-- lib/emscripten/src/errno.rs | 2 +- lib/emscripten/src/exception.rs | 20 ++-- lib/emscripten/src/exec.rs | 6 +- lib/emscripten/src/exit.rs | 2 +- lib/emscripten/src/inet.rs | 2 +- lib/emscripten/src/io/mod.rs | 12 +- lib/emscripten/src/io/unix.rs | 8 +- lib/emscripten/src/io/windows.rs | 8 +- lib/emscripten/src/jmp.rs | 6 +- lib/emscripten/src/lib.rs | 8 +- lib/emscripten/src/libc.rs | 4 +- lib/emscripten/src/linking.rs | 8 +- lib/emscripten/src/lock.rs | 8 +- lib/emscripten/src/math.rs | 2 +- lib/emscripten/src/memory.rs | 24 ++-- lib/emscripten/src/process.rs | 70 +++++------ lib/emscripten/src/pthread.rs | 74 ++++++------ lib/emscripten/src/signal.rs | 14 +-- lib/emscripten/src/syscalls/mod.rs | 150 ++++++++++++------------ lib/emscripten/src/syscalls/unix.rs | 74 ++++++------ lib/emscripten/src/syscalls/windows.rs | 74 ++++++------ lib/emscripten/src/time.rs | 46 ++++---- lib/emscripten/src/ucontext.rs | 8 +- lib/emscripten/src/unistd.rs | 2 +- lib/emscripten/src/utils.rs | 16 +-- lib/emscripten/src/varargs.rs | 4 +- 31 files changed, 430 insertions(+), 430 deletions(-) diff --git a/lib/emscripten/src/bitwise.rs b/lib/emscripten/src/bitwise.rs index fb9c20b66e0..5343dfe1c49 100644 --- a/lib/emscripten/src/bitwise.rs +++ b/lib/emscripten/src/bitwise.rs @@ -2,7 +2,7 @@ use crate::emscripten_target; use crate::EmEnv; ///emscripten: _llvm_bswap_i64 -pub fn _llvm_bswap_i64(ctx: &mut EmEnv, _low: i32, high: i32) -> i32 { +pub fn _llvm_bswap_i64(ctx: &EmEnv, _low: i32, high: i32) -> i32 { debug!("emscripten::_llvm_bswap_i64"); emscripten_target::setTempRet0(ctx, _low.swap_bytes()); high.swap_bytes() diff --git a/lib/emscripten/src/emscripten_target.rs b/lib/emscripten/src/emscripten_target.rs index 2458cc8f21b..ac7a8b1367d 100644 --- a/lib/emscripten/src/emscripten_target.rs +++ b/lib/emscripten/src/emscripten_target.rs @@ -5,31 +5,31 @@ use crate::EmEnv; #[cfg(target_os = "linux")] use libc::getdtablesize; -pub fn asm_const_i(_ctx: &mut EmEnv, _val: i32) -> i32 { +pub fn asm_const_i(_ctx: &EmEnv, _val: i32) -> i32 { debug!("emscripten::asm_const_i: {}", _val); 0 } -pub fn exit_with_live_runtime(_ctx: &mut EmEnv) { +pub fn exit_with_live_runtime(_ctx: &EmEnv) { debug!("emscripten::exit_with_live_runtime"); } -pub fn setTempRet0(ctx: &mut EmEnv, val: i32) { +pub fn setTempRet0(ctx: &EmEnv, val: i32) { trace!("emscripten::setTempRet0: {}", val); get_emscripten_data(ctx).temp_ret_0 = val; } -pub fn getTempRet0(ctx: &mut EmEnv) -> i32 { +pub fn getTempRet0(ctx: &EmEnv) -> i32 { trace!("emscripten::getTempRet0"); get_emscripten_data(ctx).temp_ret_0 } -pub fn _alarm(_ctx: &mut EmEnv, _seconds: u32) -> i32 { +pub fn _alarm(_ctx: &EmEnv, _seconds: u32) -> i32 { debug!("emscripten::_alarm({})", _seconds); 0 } -pub fn _atexit(_ctx: &mut EmEnv, _func: i32) -> i32 { +pub fn _atexit(_ctx: &EmEnv, _func: i32) -> i32 { debug!("emscripten::_atexit"); // TODO: implement atexit properly // __ATEXIT__.unshift({ @@ -38,38 +38,38 @@ pub fn _atexit(_ctx: &mut EmEnv, _func: i32) -> i32 { // }); 0 } -pub fn __Unwind_Backtrace(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn __Unwind_Backtrace(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { debug!("emscripten::__Unwind_Backtrace"); 0 } -pub fn __Unwind_FindEnclosingFunction(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn __Unwind_FindEnclosingFunction(_ctx: &EmEnv, _a: i32) -> i32 { debug!("emscripten::__Unwind_FindEnclosingFunction"); 0 } -pub fn __Unwind_GetIPInfo(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn __Unwind_GetIPInfo(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { debug!("emscripten::__Unwind_GetIPInfo"); 0 } -pub fn ___cxa_find_matching_catch_2(_ctx: &mut EmEnv) -> i32 { +pub fn ___cxa_find_matching_catch_2(_ctx: &EmEnv) -> i32 { debug!("emscripten::___cxa_find_matching_catch_2"); 0 } -pub fn ___cxa_find_matching_catch_3(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn ___cxa_find_matching_catch_3(_ctx: &EmEnv, _a: i32) -> i32 { debug!("emscripten::___cxa_find_matching_catch_3"); 0 } -pub fn ___cxa_free_exception(_ctx: &mut EmEnv, _a: i32) { +pub fn ___cxa_free_exception(_ctx: &EmEnv, _a: i32) { debug!("emscripten::___cxa_free_exception"); } -pub fn ___resumeException(_ctx: &mut EmEnv, _a: i32) { +pub fn ___resumeException(_ctx: &EmEnv, _a: i32) { debug!("emscripten::___resumeException"); } -pub fn _dladdr(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _dladdr(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { debug!("emscripten::_dladdr"); 0 } pub fn ___gxx_personality_v0( - _ctx: &mut EmEnv, + _ctx: &EmEnv, _a: i32, _b: i32, _c: i32, @@ -82,25 +82,25 @@ pub fn ___gxx_personality_v0( } #[cfg(target_os = "linux")] -pub fn _getdtablesize(_ctx: &mut EmEnv) -> i32 { +pub fn _getdtablesize(_ctx: &EmEnv) -> i32 { debug!("emscripten::getdtablesize"); unsafe { getdtablesize() } } #[cfg(not(target_os = "linux"))] -pub fn _getdtablesize(_ctx: &mut EmEnv) -> i32 { +pub fn _getdtablesize(_ctx: &EmEnv) -> i32 { debug!("emscripten::getdtablesize"); -1 } -pub fn _gethostbyaddr(_ctx: &mut EmEnv, _addr: i32, _addrlen: i32, _atype: i32) -> i32 { +pub fn _gethostbyaddr(_ctx: &EmEnv, _addr: i32, _addrlen: i32, _atype: i32) -> i32 { debug!("emscripten::gethostbyaddr"); 0 } -pub fn _gethostbyname(_ctx: &mut EmEnv, _name: i32) -> i32 { +pub fn _gethostbyname(_ctx: &EmEnv, _name: i32) -> i32 { debug!("emscripten::gethostbyname_r"); 0 } pub fn _gethostbyname_r( - _ctx: &mut EmEnv, + _ctx: &EmEnv, _name: i32, _ret: i32, _buf: i32, @@ -112,12 +112,12 @@ pub fn _gethostbyname_r( 0 } // NOTE: php.js has proper impl; libc has proper impl for linux -pub fn _getloadavg(_ctx: &mut EmEnv, _loadavg: i32, _nelem: i32) -> i32 { +pub fn _getloadavg(_ctx: &EmEnv, _loadavg: i32, _nelem: i32) -> i32 { debug!("emscripten::getloadavg"); 0 } pub fn _getnameinfo( - _ctx: &mut EmEnv, + _ctx: &EmEnv, _addr: i32, _addrlen: i32, _host: i32, @@ -170,61 +170,61 @@ macro_rules! invoke_no_return { } // Invoke functions -pub fn invoke_i(ctx: &mut EmEnv, index: i32) -> i32 { +pub fn invoke_i(ctx: &EmEnv, index: i32) -> i32 { debug!("emscripten::invoke_i"); invoke!(ctx, dyn_call_i, index) } -pub fn invoke_ii(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 { +pub fn invoke_ii(ctx: &EmEnv, index: i32, a1: i32) -> i32 { debug!("emscripten::invoke_ii"); invoke!(ctx, dyn_call_ii, index, a1) } -pub fn invoke_iii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 { +pub fn invoke_iii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) -> i32 { debug!("emscripten::invoke_iii"); invoke!(ctx, dyn_call_iii, index, a1, a2) } -pub fn invoke_iiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { +pub fn invoke_iiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { debug!("emscripten::invoke_iiii"); invoke!(ctx, dyn_call_iiii, index, a1, a2, a3) } -pub fn invoke_iifi(ctx: &mut EmEnv, index: i32, a1: i32, a2: f64, a3: i32) -> i32 { +pub fn invoke_iifi(ctx: &EmEnv, index: i32, a1: i32, a2: f64, a3: i32) -> i32 { debug!("emscripten::invoke_iifi"); invoke!(ctx, dyn_call_iifi, index, a1, a2, a3) } -pub fn invoke_v(ctx: &mut EmEnv, index: i32) { +pub fn invoke_v(ctx: &EmEnv, index: i32) { debug!("emscripten::invoke_v"); invoke_no_return!(ctx, dyn_call_v, index); } -pub fn invoke_vi(ctx: &mut EmEnv, index: i32, a1: i32) { +pub fn invoke_vi(ctx: &EmEnv, index: i32, a1: i32) { debug!("emscripten::invoke_vi"); invoke_no_return!(ctx, dyn_call_vi, index, a1); } -pub fn invoke_vii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) { +pub fn invoke_vii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) { debug!("emscripten::invoke_vii"); invoke_no_return!(ctx, dyn_call_vii, index, a1, a2); } -pub fn invoke_viii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) { +pub fn invoke_viii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) { debug!("emscripten::invoke_viii"); invoke_no_return!(ctx, dyn_call_viii, index, a1, a2, a3); } -pub fn invoke_viiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { +pub fn invoke_viiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { debug!("emscripten::invoke_viiii"); invoke_no_return!(ctx, dyn_call_viiii, index, a1, a2, a3, a4); } -pub fn invoke_dii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> f64 { +pub fn invoke_dii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) -> f64 { debug!("emscripten::invoke_dii"); invoke!(ctx, dyn_call_dii, index, a1, a2) } -pub fn invoke_diiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> f64 { +pub fn invoke_diiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> f64 { debug!("emscripten::invoke_diiii"); invoke!(ctx, dyn_call_diiii, index, a1, a2, a3, a4) } -pub fn invoke_iiiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { +pub fn invoke_iiiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { debug!("emscripten::invoke_iiiii"); invoke!(ctx, dyn_call_iiiii, index, a1, a2, a3, a4) } pub fn invoke_iiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -236,7 +236,7 @@ pub fn invoke_iiiiii( invoke!(ctx, dyn_call_iiiiii, index, a1, a2, a3, a4, a5) } pub fn invoke_iiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -249,7 +249,7 @@ pub fn invoke_iiiiiii( invoke!(ctx, dyn_call_iiiiiii, index, a1, a2, a3, a4, a5, a6) } pub fn invoke_iiiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -263,7 +263,7 @@ pub fn invoke_iiiiiiii( invoke!(ctx, dyn_call_iiiiiiii, index, a1, a2, a3, a4, a5, a6, a7) } pub fn invoke_iiiiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -290,7 +290,7 @@ pub fn invoke_iiiiiiiii( ) } pub fn invoke_iiiiiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -319,7 +319,7 @@ pub fn invoke_iiiiiiiiii( ) } pub fn invoke_iiiiiiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -349,16 +349,16 @@ pub fn invoke_iiiiiiiiiii( a10 ) } -pub fn invoke_vd(ctx: &mut EmEnv, index: i32, a1: f64) { +pub fn invoke_vd(ctx: &EmEnv, index: i32, a1: f64) { debug!("emscripten::invoke_vd"); invoke_no_return!(ctx, dyn_call_vd, index, a1) } -pub fn invoke_viiiii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { +pub fn invoke_viiiii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { debug!("emscripten::invoke_viiiii"); invoke_no_return!(ctx, dyn_call_viiiii, index, a1, a2, a3, a4, a5) } pub fn invoke_viiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -371,7 +371,7 @@ pub fn invoke_viiiiii( invoke_no_return!(ctx, dyn_call_viiiiii, index, a1, a2, a3, a4, a5, a6) } pub fn invoke_viiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -385,7 +385,7 @@ pub fn invoke_viiiiiii( invoke_no_return!(ctx, dyn_call_viiiiiii, index, a1, a2, a3, a4, a5, a6, a7) } pub fn invoke_viiiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -412,7 +412,7 @@ pub fn invoke_viiiiiiii( ) } pub fn invoke_viiiiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -441,7 +441,7 @@ pub fn invoke_viiiiiiiii( ) } pub fn invoke_viiiiiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -472,23 +472,23 @@ pub fn invoke_viiiiiiiiii( ) } -pub fn invoke_iij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { +pub fn invoke_iij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { debug!("emscripten::invoke_iij"); invoke!(ctx, dyn_call_iij, index, a1, a2, a3) } -pub fn invoke_iji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { +pub fn invoke_iji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { debug!("emscripten::invoke_iji"); invoke!(ctx, dyn_call_iji, index, a1, a2, a3) } -pub fn invoke_iiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { +pub fn invoke_iiji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { debug!("emscripten::invoke_iiji"); invoke!(ctx, dyn_call_iiji, index, a1, a2, a3, a4) } pub fn invoke_iiijj( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -500,7 +500,7 @@ pub fn invoke_iiijj( debug!("emscripten::invoke_iiijj"); invoke!(ctx, dyn_call_iiijj, index, a1, a2, a3, a4, a5, a6) } -pub fn invoke_j(ctx: &mut EmEnv, index: i32) -> i32 { +pub fn invoke_j(ctx: &EmEnv, index: i32) -> i32 { debug!("emscripten::invoke_j"); if let Some(dyn_call_j) = &get_emscripten_data(ctx).dyn_call_j { dyn_call_j.call(index).unwrap() @@ -508,7 +508,7 @@ pub fn invoke_j(ctx: &mut EmEnv, index: i32) -> i32 { panic!("dyn_call_j is set to None"); } } -pub fn invoke_ji(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 { +pub fn invoke_ji(ctx: &EmEnv, index: i32, a1: i32) -> i32 { debug!("emscripten::invoke_ji"); if let Some(dyn_call_ji) = &get_emscripten_data(ctx).dyn_call_ji { dyn_call_ji.call(index, a1).unwrap() @@ -516,7 +516,7 @@ pub fn invoke_ji(ctx: &mut EmEnv, index: i32, a1: i32) -> i32 { panic!("dyn_call_ji is set to None"); } } -pub fn invoke_jii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 { +pub fn invoke_jii(ctx: &EmEnv, index: i32, a1: i32, a2: i32) -> i32 { debug!("emscripten::invoke_jii"); if let Some(dyn_call_jii) = &get_emscripten_data(ctx).dyn_call_jii { dyn_call_jii.call(index, a1, a2).unwrap() @@ -525,7 +525,7 @@ pub fn invoke_jii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) -> i32 { } } -pub fn invoke_jij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { +pub fn invoke_jij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 { debug!("emscripten::invoke_jij"); if let Some(dyn_call_jij) = &get_emscripten_data(ctx).dyn_call_jij { dyn_call_jij.call(index, a1, a2, a3).unwrap() @@ -533,7 +533,7 @@ pub fn invoke_jij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) -> i32 panic!("dyn_call_jij is set to None"); } } -pub fn invoke_jjj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { +pub fn invoke_jjj(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) -> i32 { debug!("emscripten::invoke_jjj"); if let Some(dyn_call_jjj) = &get_emscripten_data(ctx).dyn_call_jjj { dyn_call_jjj.call(index, a1, a2, a3, a4).unwrap() @@ -541,7 +541,7 @@ pub fn invoke_jjj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i3 panic!("dyn_call_jjj is set to None"); } } -pub fn invoke_viiij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { +pub fn invoke_viiij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { debug!("emscripten::invoke_viiij"); if let Some(dyn_call_viiij) = &get_emscripten_data(ctx).dyn_call_viiij { dyn_call_viiij.call(index, a1, a2, a3, a4, a5).unwrap(); @@ -550,7 +550,7 @@ pub fn invoke_viiij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: } } pub fn invoke_viiijiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -572,7 +572,7 @@ pub fn invoke_viiijiiii( } } pub fn invoke_viiijiiiiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -595,7 +595,7 @@ pub fn invoke_viiijiiiiii( panic!("dyn_call_viiijiiiiii is set to None"); } } -pub fn invoke_viij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { +pub fn invoke_viij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { debug!("emscripten::invoke_viij"); if let Some(dyn_call_viij) = &get_emscripten_data(ctx).dyn_call_viij { dyn_call_viij.call(index, a1, a2, a3, a4).unwrap(); @@ -603,7 +603,7 @@ pub fn invoke_viij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i panic!("dyn_call_viij is set to None"); } } -pub fn invoke_viiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { +pub fn invoke_viiji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { debug!("emscripten::invoke_viiji"); if let Some(dyn_call_viiji) = &get_emscripten_data(ctx).dyn_call_viiji { dyn_call_viiji.call(index, a1, a2, a3, a4, a5).unwrap(); @@ -612,7 +612,7 @@ pub fn invoke_viiji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: } } pub fn invoke_viijiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -632,7 +632,7 @@ pub fn invoke_viijiii( } } pub fn invoke_viijj( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -648,7 +648,7 @@ pub fn invoke_viijj( panic!("dyn_call_viijj is set to None"); } } -pub fn invoke_vj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) { +pub fn invoke_vj(ctx: &EmEnv, index: i32, a1: i32, a2: i32) { debug!("emscripten::invoke_vj"); if let Some(dyn_call_vj) = &get_emscripten_data(ctx).dyn_call_vj { dyn_call_vj.call(index, a1, a2).unwrap(); @@ -656,11 +656,11 @@ pub fn invoke_vj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32) { panic!("dyn_call_vj is set to None"); } } -pub fn invoke_vjji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { +pub fn invoke_vjji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { debug!("emscripten::invoke_vjji"); invoke_no_return!(ctx, dyn_call_vjji, index, a1, a2, a3, a4, a5) } -pub fn invoke_vij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) { +pub fn invoke_vij(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32) { debug!("emscripten::invoke_vij"); if let Some(dyn_call_vij) = &get_emscripten_data(ctx).dyn_call_vij { dyn_call_vij.call(index, a1, a2, a3).unwrap(); @@ -668,7 +668,7 @@ pub fn invoke_vij(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32) { panic!("dyn_call_vij is set to None"); } } -pub fn invoke_viji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { +pub fn invoke_viji(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32) { debug!("emscripten::invoke_viji"); if let Some(dyn_call_viji) = &get_emscripten_data(ctx).dyn_call_viji { dyn_call_viji.call(index, a1, a2, a3, a4).unwrap() @@ -677,7 +677,7 @@ pub fn invoke_viji(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i } } pub fn invoke_vijiii( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, @@ -693,7 +693,7 @@ pub fn invoke_vijiii( panic!("dyn_call_vijiii is set to None"); } } -pub fn invoke_vijj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { +pub fn invoke_vijj(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) { debug!("emscripten::invoke_vijj"); if let Some(dyn_call_vijj) = &get_emscripten_data(ctx).dyn_call_vijj { dyn_call_vijj.call(index, a1, a2, a3, a4, a5).unwrap() @@ -701,20 +701,20 @@ pub fn invoke_vijj(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: i32, a4: i panic!("dyn_call_vijj is set to None"); } } -pub fn invoke_vidd(ctx: &mut EmEnv, index: i32, a1: i32, a2: f64, a3: f64) { +pub fn invoke_vidd(ctx: &EmEnv, index: i32, a1: i32, a2: f64, a3: f64) { debug!("emscripten::invoke_viid"); invoke_no_return!(ctx, dyn_call_vidd, index, a1, a2, a3); } -pub fn invoke_viid(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: f64) { +pub fn invoke_viid(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: f64) { debug!("emscripten::invoke_viid"); invoke_no_return!(ctx, dyn_call_viid, index, a1, a2, a3); } -pub fn invoke_viidii(ctx: &mut EmEnv, index: i32, a1: i32, a2: i32, a3: f64, a4: i32, a5: i32) { +pub fn invoke_viidii(ctx: &EmEnv, index: i32, a1: i32, a2: i32, a3: f64, a4: i32, a5: i32) { debug!("emscripten::invoke_viidii"); invoke_no_return!(ctx, dyn_call_viidii, index, a1, a2, a3, a4, a5); } pub fn invoke_viidddddddd( - ctx: &mut EmEnv, + ctx: &EmEnv, index: i32, a1: i32, a2: i32, diff --git a/lib/emscripten/src/env/mod.rs b/lib/emscripten/src/env/mod.rs index ad04d8dc729..b329c39a98e 100644 --- a/lib/emscripten/src/env/mod.rs +++ b/lib/emscripten/src/env/mod.rs @@ -23,7 +23,7 @@ use std::os::raw::c_int; use crate::EmEnv; use wasmer::ValueType; -pub fn call_malloc(ctx: &mut EmEnv, size: u32) -> u32 { +pub fn call_malloc(ctx: &EmEnv, size: u32) -> u32 { get_emscripten_data(ctx) .malloc .as_ref() @@ -33,11 +33,11 @@ pub fn call_malloc(ctx: &mut EmEnv, size: u32) -> u32 { } #[warn(dead_code)] -pub fn call_malloc_with_cast(ctx: &mut EmEnv, size: u32) -> WasmPtr { +pub fn call_malloc_with_cast(ctx: &EmEnv, size: u32) -> WasmPtr { WasmPtr::new(call_malloc(ctx, size)) } -pub fn call_memalign(ctx: &mut EmEnv, alignment: u32, size: u32) -> u32 { +pub fn call_memalign(ctx: &EmEnv, alignment: u32, size: u32) -> u32 { if let Some(memalign) = &get_emscripten_data(ctx).memalign { memalign.call(alignment, size).unwrap() } else { @@ -45,7 +45,7 @@ pub fn call_memalign(ctx: &mut EmEnv, alignment: u32, size: u32) -> u32 { } } -pub fn call_memset(ctx: &mut EmEnv, pointer: u32, value: u32, size: u32) -> u32 { +pub fn call_memset(ctx: &EmEnv, pointer: u32, value: u32, size: u32) -> u32 { get_emscripten_data(ctx) .memset .as_ref() @@ -54,16 +54,16 @@ pub fn call_memset(ctx: &mut EmEnv, pointer: u32, value: u32, size: u32) -> u32 .unwrap() } -pub(crate) fn get_emscripten_data<'a>(ctx: &'a mut EmEnv) -> &'a mut EmscriptenData<'static> { +pub(crate) fn get_emscripten_data<'a>(ctx: &'a EmEnv) -> &'a mut EmscriptenData<'static> { unsafe { &mut **ctx.data } } -pub fn _getpagesize(_ctx: &mut EmEnv) -> u32 { +pub fn _getpagesize(_ctx: &EmEnv) -> u32 { debug!("emscripten::_getpagesize"); 16384 } -pub fn _times(ctx: &mut EmEnv, buffer: u32) -> u32 { +pub fn _times(ctx: &EmEnv, buffer: u32) -> u32 { if buffer != 0 { call_memset(ctx, buffer, 0, 16); } @@ -71,7 +71,7 @@ pub fn _times(ctx: &mut EmEnv, buffer: u32) -> u32 { } #[allow(clippy::cast_ptr_alignment)] -pub fn ___build_environment(ctx: &mut EmEnv, environ: c_int) { +pub fn ___build_environment(ctx: &EmEnv, environ: c_int) { debug!("emscripten::___build_environment {}", environ); const MAX_ENV_VALUES: u32 = 64; const TOTAL_ENV_SIZE: u32 = 1024; @@ -123,13 +123,13 @@ pub fn ___build_environment(ctx: &mut EmEnv, environ: c_int) { } } -pub fn ___assert_fail(_ctx: &mut EmEnv, _a: c_int, _b: c_int, _c: c_int, _d: c_int) { +pub fn ___assert_fail(_ctx: &EmEnv, _a: c_int, _b: c_int, _c: c_int, _d: c_int) { debug!("emscripten::___assert_fail {} {} {} {}", _a, _b, _c, _d); // TODO: Implement like emscripten expects regarding memory/page size // TODO raise an error } -pub fn _pathconf(ctx: &mut EmEnv, path_addr: c_int, name: c_int) -> c_int { +pub fn _pathconf(ctx: &EmEnv, path_addr: c_int, name: c_int) -> c_int { debug!( "emscripten::_pathconf {} {} - UNIMPLEMENTED", path_addr, name @@ -150,7 +150,7 @@ pub fn _pathconf(ctx: &mut EmEnv, path_addr: c_int, name: c_int) -> c_int { } } -pub fn _fpathconf(_ctx: &mut EmEnv, _fildes: c_int, name: c_int) -> c_int { +pub fn _fpathconf(_ctx: &EmEnv, _fildes: c_int, name: c_int) -> c_int { debug!("emscripten::_fpathconf {} {}", _fildes, name); match name { 0 => 32000, diff --git a/lib/emscripten/src/env/unix/mod.rs b/lib/emscripten/src/env/unix/mod.rs index 775805d6779..16746e5e464 100644 --- a/lib/emscripten/src/env/unix/mod.rs +++ b/lib/emscripten/src/env/unix/mod.rs @@ -15,7 +15,7 @@ use crate::EmEnv; // #[no_mangle] /// emscripten: _getenv // (name: *const char) -> *const c_char; -pub fn _getenv(ctx: &mut EmEnv, name: i32) -> u32 { +pub fn _getenv(ctx: &EmEnv, name: i32) -> u32 { debug!("emscripten::_getenv"); let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; @@ -31,7 +31,7 @@ pub fn _getenv(ctx: &mut EmEnv, name: i32) -> u32 { } /// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int); -pub fn _setenv(ctx: &mut EmEnv, name: c_int, value: c_int, overwrite: c_int) -> c_int { +pub fn _setenv(ctx: &EmEnv, name: c_int, value: c_int, overwrite: c_int) -> c_int { debug!("emscripten::_setenv"); let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; @@ -44,7 +44,7 @@ pub fn _setenv(ctx: &mut EmEnv, name: c_int, value: c_int, overwrite: c_int) -> } /// emscripten: _putenv // (name: *const char); -pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int { +pub fn _putenv(ctx: &EmEnv, name: c_int) -> c_int { debug!("emscripten::_putenv"); let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; @@ -55,7 +55,7 @@ pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int { } /// emscripten: _unsetenv // (name: *const char); -pub fn _unsetenv(ctx: &mut EmEnv, name: c_int) -> c_int { +pub fn _unsetenv(ctx: &EmEnv, name: c_int) -> c_int { debug!("emscripten::_unsetenv"); let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; @@ -66,7 +66,7 @@ pub fn _unsetenv(ctx: &mut EmEnv, name: c_int) -> c_int { } #[allow(clippy::cast_ptr_alignment)] -pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { +pub fn _getpwnam(ctx: &EmEnv, name_ptr: c_int) -> c_int { debug!("emscripten::_getpwnam {}", name_ptr); #[cfg(feature = "debug")] let _ = name_ptr; @@ -106,7 +106,7 @@ pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { } #[allow(clippy::cast_ptr_alignment)] -pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { +pub fn _getgrnam(ctx: &EmEnv, name_ptr: c_int) -> c_int { debug!("emscripten::_getgrnam {}", name_ptr); #[repr(C)] @@ -137,14 +137,14 @@ pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { } } -pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> i32 { +pub fn _sysconf(_ctx: &EmEnv, name: c_int) -> i32 { debug!("emscripten::_sysconf {}", name); // TODO: Implement like emscripten expects regarding memory/page size unsafe { sysconf(name) as i32 } // TODO review i64 } // this may be a memory leak, probably not though because emscripten does the same thing -pub fn _gai_strerror(ctx: &mut EmEnv, ecode: i32) -> i32 { +pub fn _gai_strerror(ctx: &EmEnv, ecode: i32) -> i32 { debug!("emscripten::_gai_strerror({})", ecode); let cstr = unsafe { std::ffi::CStr::from_ptr(libc::gai_strerror(ecode)) }; @@ -164,7 +164,7 @@ pub fn _gai_strerror(ctx: &mut EmEnv, ecode: i32) -> i32 { } pub fn _getaddrinfo( - ctx: &mut EmEnv, + ctx: &EmEnv, node_ptr: WasmPtr, service_str_ptr: WasmPtr, hints_ptr: WasmPtr, diff --git a/lib/emscripten/src/env/windows/mod.rs b/lib/emscripten/src/env/windows/mod.rs index f7783bcf8ea..874d5e5e683 100644 --- a/lib/emscripten/src/env/windows/mod.rs +++ b/lib/emscripten/src/env/windows/mod.rs @@ -17,7 +17,7 @@ extern "C" { // #[no_mangle] /// emscripten: _getenv // (name: *const char) -> *const c_char; -pub fn _getenv(ctx: &mut EmEnv, name: u32) -> u32 { +pub fn _getenv(ctx: &EmEnv, name: u32) -> u32 { debug!("emscripten::_getenv"); let name_string = read_string_from_wasm(ctx.memory(0), name); debug!("=> name({:?})", name_string); @@ -29,7 +29,7 @@ pub fn _getenv(ctx: &mut EmEnv, name: u32) -> u32 { } /// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int); -pub fn _setenv(ctx: &mut EmEnv, name: u32, value: u32, _overwrite: u32) -> c_int { +pub fn _setenv(ctx: &EmEnv, name: u32, value: u32, _overwrite: u32) -> c_int { debug!("emscripten::_setenv"); // setenv does not exist on windows, so we hack it with _putenv let name = read_string_from_wasm(ctx.memory(0), name); @@ -43,7 +43,7 @@ pub fn _setenv(ctx: &mut EmEnv, name: u32, value: u32, _overwrite: u32) -> c_int } /// emscripten: _putenv // (name: *const char); -pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int { +pub fn _putenv(ctx: &EmEnv, name: c_int) -> c_int { debug!("emscripten::_putenv"); let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char; debug!("=> name({:?})", unsafe { @@ -53,7 +53,7 @@ pub fn _putenv(ctx: &mut EmEnv, name: c_int) -> c_int { } /// emscripten: _unsetenv // (name: *const char); -pub fn _unsetenv(ctx: &mut EmEnv, name: u32) -> c_int { +pub fn _unsetenv(ctx: &EmEnv, name: u32) -> c_int { debug!("emscripten::_unsetenv"); let name = read_string_from_wasm(ctx.memory(0), name); // no unsetenv on windows, so use putenv with an empty value @@ -65,7 +65,7 @@ pub fn _unsetenv(ctx: &mut EmEnv, name: u32) -> c_int { } #[allow(clippy::cast_ptr_alignment)] -pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { +pub fn _getpwnam(ctx: &EmEnv, name_ptr: c_int) -> c_int { debug!("emscripten::_getpwnam {}", name_ptr); #[cfg(not(feature = "debug"))] let _ = name_ptr; @@ -99,7 +99,7 @@ pub fn _getpwnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { } #[allow(clippy::cast_ptr_alignment)] -pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { +pub fn _getgrnam(ctx: &EmEnv, name_ptr: c_int) -> c_int { debug!("emscripten::_getgrnam {}", name_ptr); #[cfg(not(feature = "debug"))] let _ = name_ptr; @@ -125,7 +125,7 @@ pub fn _getgrnam(ctx: &mut EmEnv, name_ptr: c_int) -> c_int { } } -pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> c_long { +pub fn _sysconf(_ctx: &EmEnv, name: c_int) -> c_long { debug!("emscripten::_sysconf {}", name); #[cfg(not(feature = "debug"))] let _ = name; @@ -133,13 +133,13 @@ pub fn _sysconf(_ctx: &mut EmEnv, name: c_int) -> c_long { 0 } -pub fn _gai_strerror(_ctx: &mut EmEnv, _ecode: i32) -> i32 { +pub fn _gai_strerror(_ctx: &EmEnv, _ecode: i32) -> i32 { debug!("emscripten::_gai_strerror({}) - stub", _ecode); -1 } pub fn _getaddrinfo( - _ctx: &mut EmEnv, + _ctx: &EmEnv, _node_ptr: WasmPtr, _service_str_ptr: WasmPtr, _hints_ptr: WasmPtr, diff --git a/lib/emscripten/src/errno.rs b/lib/emscripten/src/errno.rs index c1e54170b4b..fcbbe22dfee 100644 --- a/lib/emscripten/src/errno.rs +++ b/lib/emscripten/src/errno.rs @@ -1,7 +1,7 @@ // use std::collections::HashMap; use crate::EmEnv; -pub fn ___seterrno(_ctx: &mut EmEnv, _value: i32) { +pub fn ___seterrno(_ctx: &EmEnv, _value: i32) { debug!("emscripten::___seterrno {}", _value); // TODO: Incomplete impl eprintln!("failed to set errno!"); diff --git a/lib/emscripten/src/exception.rs b/lib/emscripten/src/exception.rs index f968addc492..1f781dd652d 100644 --- a/lib/emscripten/src/exception.rs +++ b/lib/emscripten/src/exception.rs @@ -3,54 +3,54 @@ use super::process::_abort; use crate::EmEnv; /// emscripten: ___cxa_allocate_exception -pub fn ___cxa_allocate_exception(ctx: &mut EmEnv, size: u32) -> u32 { +pub fn ___cxa_allocate_exception(ctx: &EmEnv, size: u32) -> u32 { debug!("emscripten::___cxa_allocate_exception"); env::call_malloc(ctx, size as _) } -pub fn ___cxa_current_primary_exception(_ctx: &mut EmEnv) -> u32 { +pub fn ___cxa_current_primary_exception(_ctx: &EmEnv) -> u32 { debug!("emscripten::___cxa_current_primary_exception"); unimplemented!("emscripten::___cxa_current_primary_exception") } -pub fn ___cxa_decrement_exception_refcount(_ctx: &mut EmEnv, _a: u32) { +pub fn ___cxa_decrement_exception_refcount(_ctx: &EmEnv, _a: u32) { debug!("emscripten::___cxa_decrement_exception_refcount({})", _a); unimplemented!("emscripten::___cxa_decrement_exception_refcount({})", _a) } -pub fn ___cxa_increment_exception_refcount(_ctx: &mut EmEnv, _a: u32) { +pub fn ___cxa_increment_exception_refcount(_ctx: &EmEnv, _a: u32) { debug!("emscripten::___cxa_increment_exception_refcount({})", _a); unimplemented!("emscripten::___cxa_increment_exception_refcount({})", _a) } -pub fn ___cxa_rethrow_primary_exception(_ctx: &mut EmEnv, _a: u32) { +pub fn ___cxa_rethrow_primary_exception(_ctx: &EmEnv, _a: u32) { debug!("emscripten::___cxa_rethrow_primary_exception({})", _a); unimplemented!("emscripten::___cxa_rethrow_primary_exception({})", _a) } /// emscripten: ___cxa_throw /// TODO: We don't have support for exceptions yet -pub fn ___cxa_throw(ctx: &mut EmEnv, _ptr: u32, _ty: u32, _destructor: u32) { +pub fn ___cxa_throw(ctx: &EmEnv, _ptr: u32, _ty: u32, _destructor: u32) { debug!("emscripten::___cxa_throw"); eprintln!("Throwing exceptions not yet implemented: aborting!"); _abort(ctx); } -pub fn ___cxa_begin_catch(_ctx: &mut EmEnv, _exception_object_ptr: u32) -> i32 { +pub fn ___cxa_begin_catch(_ctx: &EmEnv, _exception_object_ptr: u32) -> i32 { debug!("emscripten::___cxa_begin_catch"); -1 } -pub fn ___cxa_end_catch(_ctx: &mut EmEnv) { +pub fn ___cxa_end_catch(_ctx: &EmEnv) { debug!("emscripten::___cxa_end_catch"); } -pub fn ___cxa_uncaught_exception(_ctx: &mut EmEnv) -> i32 { +pub fn ___cxa_uncaught_exception(_ctx: &EmEnv) -> i32 { debug!("emscripten::___cxa_uncaught_exception"); -1 } -pub fn ___cxa_pure_virtual(_ctx: &mut EmEnv) { +pub fn ___cxa_pure_virtual(_ctx: &EmEnv) { debug!("emscripten::___cxa_pure_virtual"); // ABORT = true panic!("Pure virtual function called!"); diff --git a/lib/emscripten/src/exec.rs b/lib/emscripten/src/exec.rs index 46a3331f266..529b9943fd5 100644 --- a/lib/emscripten/src/exec.rs +++ b/lib/emscripten/src/exec.rs @@ -4,7 +4,7 @@ use libc::execvp as libc_execvp; use std::cell::Cell; use std::ffi::CString; -pub fn execvp(ctx: &mut EmEnv, command_name_offset: u32, argv_offset: u32) -> i32 { +pub fn execvp(ctx: &EmEnv, command_name_offset: u32, argv_offset: u32) -> i32 { // a single reference to re-use let emscripten_memory = ctx.memory(0); @@ -41,13 +41,13 @@ pub fn execvp(ctx: &mut EmEnv, command_name_offset: u32, argv_offset: u32) -> i3 } /// execl -pub fn execl(_ctx: &mut EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 { +pub fn execl(_ctx: &EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 { debug!("emscripten::execl"); -1 } /// execle -pub fn execle(_ctx: &mut EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 { +pub fn execle(_ctx: &EmEnv, _path_ptr: i32, _arg0_ptr: i32, _varargs: VarArgs) -> i32 { debug!("emscripten::execle"); -1 } diff --git a/lib/emscripten/src/exit.rs b/lib/emscripten/src/exit.rs index b9b69a9dc28..9518d256712 100644 --- a/lib/emscripten/src/exit.rs +++ b/lib/emscripten/src/exit.rs @@ -1,7 +1,7 @@ use crate::EmEnv; // __exit -pub fn exit(_ctx: &mut EmEnv, value: i32) { +pub fn exit(_ctx: &EmEnv, value: i32) { debug!("emscripten::exit {}", value); ::std::process::exit(value); } diff --git a/lib/emscripten/src/inet.rs b/lib/emscripten/src/inet.rs index 79d2e946ea2..ff0267d88a7 100644 --- a/lib/emscripten/src/inet.rs +++ b/lib/emscripten/src/inet.rs @@ -1,6 +1,6 @@ use crate::EmEnv; -pub fn addr(_ctx: &mut EmEnv, _cp: i32) -> i32 { +pub fn addr(_ctx: &EmEnv, _cp: i32) -> i32 { debug!("inet::addr({})", _cp); 0 } diff --git a/lib/emscripten/src/io/mod.rs b/lib/emscripten/src/io/mod.rs index e783bf29b54..3c0a9d63b66 100644 --- a/lib/emscripten/src/io/mod.rs +++ b/lib/emscripten/src/io/mod.rs @@ -13,19 +13,19 @@ pub use self::windows::*; use crate::EmEnv; /// getprotobyname -pub fn getprotobyname(_ctx: &mut EmEnv, _name_ptr: i32) -> i32 { +pub fn getprotobyname(_ctx: &EmEnv, _name_ptr: i32) -> i32 { debug!("emscripten::getprotobyname"); unimplemented!("emscripten::getprotobyname") } /// getprotobynumber -pub fn getprotobynumber(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn getprotobynumber(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::getprotobynumber"); unimplemented!("emscripten::getprotobynumber") } /// sigdelset -pub fn sigdelset(ctx: &mut EmEnv, set: i32, signum: i32) -> i32 { +pub fn sigdelset(ctx: &EmEnv, set: i32, signum: i32) -> i32 { debug!("emscripten::sigdelset"); let memory = ctx.memory(0); #[allow(clippy::cast_ptr_alignment)] @@ -37,7 +37,7 @@ pub fn sigdelset(ctx: &mut EmEnv, set: i32, signum: i32) -> i32 { } /// sigfillset -pub fn sigfillset(ctx: &mut EmEnv, set: i32) -> i32 { +pub fn sigfillset(ctx: &EmEnv, set: i32) -> i32 { debug!("emscripten::sigfillset"); let memory = ctx.memory(0); #[allow(clippy::cast_ptr_alignment)] @@ -51,13 +51,13 @@ pub fn sigfillset(ctx: &mut EmEnv, set: i32) -> i32 { } /// tzset -pub fn tzset(_ctx: &mut EmEnv) { +pub fn tzset(_ctx: &EmEnv) { debug!("emscripten::tzset - stub"); //unimplemented!("emscripten::tzset - stub") } /// strptime -pub fn strptime(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { +pub fn strptime(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { debug!("emscripten::strptime"); unimplemented!("emscripten::strptime") } diff --git a/lib/emscripten/src/io/unix.rs b/lib/emscripten/src/io/unix.rs index 4591accd8e6..62190653fbf 100644 --- a/lib/emscripten/src/io/unix.rs +++ b/lib/emscripten/src/io/unix.rs @@ -6,12 +6,12 @@ use std::mem; use crate::EmEnv; /// putchar -pub fn putchar(_ctx: &mut EmEnv, chr: i32) { +pub fn putchar(_ctx: &EmEnv, chr: i32) { unsafe { libc::putchar(chr) }; } /// printf -pub fn printf(ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 { +pub fn printf(ctx: &EmEnv, memory_offset: i32, extra: i32) -> i32 { debug!("emscripten::printf {}, {}", memory_offset, extra); unsafe { let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _; @@ -20,7 +20,7 @@ pub fn printf(ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 { } /// chroot -pub fn chroot(ctx: &mut EmEnv, name_ptr: i32) -> i32 { +pub fn chroot(ctx: &EmEnv, name_ptr: i32) -> i32 { debug!("emscripten::chroot"); let name = emscripten_memory_pointer!(ctx.memory(0), name_ptr) as *const i8; unsafe { _chroot(name as *const _) } @@ -28,7 +28,7 @@ pub fn chroot(ctx: &mut EmEnv, name_ptr: i32) -> i32 { /// getpwuid #[allow(clippy::cast_ptr_alignment)] -pub fn getpwuid(ctx: &mut EmEnv, uid: i32) -> i32 { +pub fn getpwuid(ctx: &EmEnv, uid: i32) -> i32 { debug!("emscripten::getpwuid {}", uid); #[repr(C)] diff --git a/lib/emscripten/src/io/windows.rs b/lib/emscripten/src/io/windows.rs index a29677b9064..e0507ead876 100644 --- a/lib/emscripten/src/io/windows.rs +++ b/lib/emscripten/src/io/windows.rs @@ -14,12 +14,12 @@ use crate::EmEnv; //} /// putchar -pub fn putchar(_ctx: &mut EmEnv, chr: i32) { +pub fn putchar(_ctx: &EmEnv, chr: i32) { unsafe { libc::putchar(chr) }; } /// printf -pub fn printf(_ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 { +pub fn printf(_ctx: &EmEnv, memory_offset: i32, extra: i32) -> i32 { debug!("emscripten::printf {}, {}", memory_offset, extra); #[cfg(not(feature = "debug"))] { @@ -34,13 +34,13 @@ pub fn printf(_ctx: &mut EmEnv, memory_offset: i32, extra: i32) -> i32 { } /// chroot -pub fn chroot(_ctx: &mut EmEnv, _name_ptr: i32) -> i32 { +pub fn chroot(_ctx: &EmEnv, _name_ptr: i32) -> i32 { debug!("emscripten::chroot"); unimplemented!("emscripten::chroot") } /// getpwuid -pub fn getpwuid(_ctx: &mut EmEnv, _uid: i32) -> i32 { +pub fn getpwuid(_ctx: &EmEnv, _uid: i32) -> i32 { debug!("emscripten::getpwuid"); unimplemented!("emscripten::getpwuid") } diff --git a/lib/emscripten/src/jmp.rs b/lib/emscripten/src/jmp.rs index def2346d473..c3b6dcb586b 100644 --- a/lib/emscripten/src/jmp.rs +++ b/lib/emscripten/src/jmp.rs @@ -9,7 +9,7 @@ use std::fmt; use wasmer::RuntimeError; /// setjmp -pub fn __setjmp(ctx: &mut EmEnv, _env_addr: u32) -> c_int { +pub fn __setjmp(ctx: &EmEnv, _env_addr: u32) -> c_int { debug!("emscripten::__setjmp (setjmp)"); abort_with_message(ctx, "missing function: _setjmp"); unreachable!() @@ -32,7 +32,7 @@ pub fn __setjmp(ctx: &mut EmEnv, _env_addr: u32) -> c_int { /// longjmp #[allow(unreachable_code)] -pub fn __longjmp(ctx: &mut EmEnv, _env_addr: u32, _val: c_int) { +pub fn __longjmp(ctx: &EmEnv, _env_addr: u32, _val: c_int) { debug!("emscripten::__longjmp (longmp)"); abort_with_message(ctx, "missing function: _longjmp"); // unsafe { @@ -59,7 +59,7 @@ impl Error for LongJumpRet {} /// _longjmp // This function differs from the js implementation, it should return Result<(), &'static str> #[allow(unreachable_code)] -pub fn _longjmp(ctx: &mut EmEnv, env_addr: i32, val: c_int) { +pub fn _longjmp(ctx: &EmEnv, env_addr: i32, val: c_int) { let val = if val == 0 { 1 } else { val }; get_emscripten_data(ctx) .set_threw diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index a08c2532064..b40b8408126 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -426,7 +426,7 @@ pub fn set_up_emscripten(instance: &mut Instance) -> Result<(), RuntimeError> { /// If you don't want to set it up yourself, consider using [`run_emscripten_instance`]. pub fn emscripten_call_main( instance: &mut Instance, - env: &mut EmEnv, + env: &EmEnv, path: &str, args: &[&str], ) -> Result<(), RuntimeError> { @@ -503,7 +503,7 @@ pub fn run_emscripten_instance( Ok(()) } -fn store_module_arguments(ctx: &mut EmEnv, args: Vec<&str>) -> (u32, u32) { +fn store_module_arguments(ctx: &EmEnv, args: Vec<&str>) -> (u32, u32) { let argc = args.len() + 1; let mut args_slice = vec![0; argc]; @@ -652,7 +652,7 @@ impl EmscriptenGlobals { pub fn generate_emscripten_env( store: &Store, globals: &mut EmscriptenGlobals, - env: &mut EmEnv, + env: &EmEnv, ) -> ImportObject { let abort_on_cannot_grow_memory_export = if globals.data.use_old_abort_on_cannot_grow_memory { Function::new_native_with_env( @@ -1151,7 +1151,7 @@ pub fn generate_emscripten_env( import_object } -pub fn nullfunc(ctx: &mut EmEnv, _x: u32) { +pub fn nullfunc(ctx: &EmEnv, _x: u32) { use crate::process::abort_with_message; debug!("emscripten::nullfunc_i {}", _x); abort_with_message( diff --git a/lib/emscripten/src/libc.rs b/lib/emscripten/src/libc.rs index 1ba38213089..81d67971da2 100644 --- a/lib/emscripten/src/libc.rs +++ b/lib/emscripten/src/libc.rs @@ -49,14 +49,14 @@ pub fn killpg(_a: i32, _b: i32) -> i32 { } #[cfg(unix)] -pub fn pathconf(ctx: &mut EmEnv, path_ptr: i32, name: i32) -> i32 { +pub fn pathconf(ctx: &EmEnv, path_ptr: i32, name: i32) -> i32 { debug!("emscripten::pathconf"); let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8; unsafe { libc::pathconf(path as *const _, name).try_into().unwrap() } } #[cfg(not(unix))] -pub fn pathconf(_ctx: &mut EmEnv, _path_ptr: i32, _name: i32) -> i32 { +pub fn pathconf(_ctx: &EmEnv, _path_ptr: i32, _name: i32) -> i32 { debug!("emscripten::pathconf"); 0 } diff --git a/lib/emscripten/src/linking.rs b/lib/emscripten/src/linking.rs index 03ad29fc58b..5ca49e85e13 100644 --- a/lib/emscripten/src/linking.rs +++ b/lib/emscripten/src/linking.rs @@ -3,25 +3,25 @@ use crate::EmEnv; // TODO: Need to implement. /// emscripten: dlopen(filename: *const c_char, flag: c_int) -> *mut c_void -pub fn _dlopen(_ctx: &mut EmEnv, _filename: u32, _flag: u32) -> i32 { +pub fn _dlopen(_ctx: &EmEnv, _filename: u32, _flag: u32) -> i32 { debug!("emscripten::_dlopen"); -1 } /// emscripten: dlclose(handle: *mut c_void) -> c_int -pub fn _dlclose(_ctx: &mut EmEnv, _filename: u32) -> i32 { +pub fn _dlclose(_ctx: &EmEnv, _filename: u32) -> i32 { debug!("emscripten::_dlclose"); -1 } /// emscripten: dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void -pub fn _dlsym(_ctx: &mut EmEnv, _filepath: u32, _symbol: u32) -> i32 { +pub fn _dlsym(_ctx: &EmEnv, _filepath: u32, _symbol: u32) -> i32 { debug!("emscripten::_dlsym"); -1 } /// emscripten: dlerror() -> *mut c_char -pub fn _dlerror(_ctx: &mut EmEnv) -> i32 { +pub fn _dlerror(_ctx: &EmEnv) -> i32 { debug!("emscripten::_dlerror"); -1 } diff --git a/lib/emscripten/src/lock.rs b/lib/emscripten/src/lock.rs index 6058ac8e84d..f83b12e38bd 100644 --- a/lib/emscripten/src/lock.rs +++ b/lib/emscripten/src/lock.rs @@ -2,21 +2,21 @@ use crate::EmEnv; use libc::c_int; // NOTE: Not implemented by Emscripten -pub fn ___lock(_ctx: &mut EmEnv, _what: c_int) { +pub fn ___lock(_ctx: &EmEnv, _what: c_int) { debug!("emscripten::___lock {}", _what); } // NOTE: Not implemented by Emscripten -pub fn ___unlock(_ctx: &mut EmEnv, _what: c_int) { +pub fn ___unlock(_ctx: &EmEnv, _what: c_int) { debug!("emscripten::___unlock {}", _what); } // NOTE: Not implemented by Emscripten -pub fn ___wait(_ctx: &mut EmEnv, _which: u32, _varargs: u32, _three: u32, _four: u32) { +pub fn ___wait(_ctx: &EmEnv, _which: u32, _varargs: u32, _three: u32, _four: u32) { debug!("emscripten::___wait"); } -pub fn _flock(_ctx: &mut EmEnv, _fd: u32, _op: u32) -> u32 { +pub fn _flock(_ctx: &EmEnv, _fd: u32, _op: u32) -> u32 { debug!("emscripten::_flock"); 0 } diff --git a/lib/emscripten/src/math.rs b/lib/emscripten/src/math.rs index 05607571468..6328e1853be 100644 --- a/lib/emscripten/src/math.rs +++ b/lib/emscripten/src/math.rs @@ -62,7 +62,7 @@ pub fn _llvm_fma_f64(value: f64, a: f64, b: f64) -> f64 { value.mul_add(a, b) } -pub fn _emscripten_random(_ctx: &mut EmEnv) -> f64 { +pub fn _emscripten_random(_ctx: &EmEnv) -> f64 { debug!("emscripten::_emscripten_random"); -1.0 } diff --git a/lib/emscripten/src/memory.rs b/lib/emscripten/src/memory.rs index 066cb166965..028d136bcc6 100644 --- a/lib/emscripten/src/memory.rs +++ b/lib/emscripten/src/memory.rs @@ -6,7 +6,7 @@ use libc::{c_int, c_void, memcpy, size_t}; use wasmer::{Pages, WASM_MAX_PAGES, WASM_MIN_PAGES, WASM_PAGE_SIZE}; /// emscripten: _emscripten_memcpy_big -pub fn _emscripten_memcpy_big(ctx: &mut EmEnv, dest: u32, src: u32, len: u32) -> u32 { +pub fn _emscripten_memcpy_big(ctx: &EmEnv, dest: u32, src: u32, len: u32) -> u32 { debug!( "emscripten::_emscripten_memcpy_big {}, {}, {}", dest, src, len @@ -20,7 +20,7 @@ pub fn _emscripten_memcpy_big(ctx: &mut EmEnv, dest: u32, src: u32, len: u32) -> } /// emscripten: _emscripten_get_heap_size -pub fn _emscripten_get_heap_size(ctx: &mut EmEnv) -> u32 { +pub fn _emscripten_get_heap_size(ctx: &EmEnv) -> u32 { trace!("emscripten::_emscripten_get_heap_size"); let result = ctx.memory(0).size().bytes().0 as u32; trace!("=> {}", result); @@ -38,7 +38,7 @@ fn align_up(mut val: usize, multiple: usize) -> usize { /// emscripten: _emscripten_resize_heap /// Note: this function only allows growing the size of heap -pub fn _emscripten_resize_heap(ctx: &mut EmEnv, requested_size: u32) -> u32 { +pub fn _emscripten_resize_heap(ctx: &EmEnv, requested_size: u32) -> u32 { debug!("emscripten::_emscripten_resize_heap {}", requested_size); let current_memory_pages = ctx.memory(0).size(); let current_memory = current_memory_pages.bytes().0 as u32; @@ -69,7 +69,7 @@ pub fn _emscripten_resize_heap(ctx: &mut EmEnv, requested_size: u32) -> u32 { } /// emscripten: sbrk -pub fn sbrk(ctx: &mut EmEnv, increment: i32) -> i32 { +pub fn sbrk(ctx: &EmEnv, increment: i32) -> i32 { debug!("emscripten::sbrk"); // let old_dynamic_top = 0; // let new_dynamic_top = 0; @@ -97,7 +97,7 @@ pub fn sbrk(ctx: &mut EmEnv, increment: i32) -> i32 { } /// emscripten: getTotalMemory -pub fn get_total_memory(_ctx: &mut EmEnv) -> u32 { +pub fn get_total_memory(_ctx: &EmEnv) -> u32 { debug!("emscripten::get_total_memory"); // instance.memories[0].current_pages() // TODO: Fix implementation @@ -105,7 +105,7 @@ pub fn get_total_memory(_ctx: &mut EmEnv) -> u32 { } /// emscripten: enlargeMemory -pub fn enlarge_memory(_ctx: &mut EmEnv) -> u32 { +pub fn enlarge_memory(_ctx: &EmEnv) -> u32 { debug!("emscripten::enlarge_memory"); // instance.memories[0].grow(100); // TODO: Fix implementation @@ -113,7 +113,7 @@ pub fn enlarge_memory(_ctx: &mut EmEnv) -> u32 { } /// emscripten: abortOnCannotGrowMemory -pub fn abort_on_cannot_grow_memory(ctx: &mut EmEnv, _requested_size: u32) -> u32 { +pub fn abort_on_cannot_grow_memory(ctx: &EmEnv, _requested_size: u32) -> u32 { debug!( "emscripten::abort_on_cannot_grow_memory {}", _requested_size @@ -123,32 +123,32 @@ pub fn abort_on_cannot_grow_memory(ctx: &mut EmEnv, _requested_size: u32) -> u32 } /// emscripten: abortOnCannotGrowMemory -pub fn abort_on_cannot_grow_memory_old(ctx: &mut EmEnv) -> u32 { +pub fn abort_on_cannot_grow_memory_old(ctx: &EmEnv) -> u32 { debug!("emscripten::abort_on_cannot_grow_memory"); abort_with_message(ctx, "Cannot enlarge memory arrays!"); 0 } /// emscripten: segfault -pub fn segfault(ctx: &mut EmEnv) { +pub fn segfault(ctx: &EmEnv) { debug!("emscripten::segfault"); abort_with_message(ctx, "segmentation fault"); } /// emscripten: alignfault -pub fn alignfault(ctx: &mut EmEnv) { +pub fn alignfault(ctx: &EmEnv) { debug!("emscripten::alignfault"); abort_with_message(ctx, "alignment fault"); } /// emscripten: ftfault -pub fn ftfault(ctx: &mut EmEnv) { +pub fn ftfault(ctx: &EmEnv) { debug!("emscripten::ftfault"); abort_with_message(ctx, "Function table mask error"); } /// emscripten: ___map_file -pub fn ___map_file(_ctx: &mut EmEnv, _one: u32, _two: u32) -> c_int { +pub fn ___map_file(_ctx: &EmEnv, _one: u32, _two: u32) -> c_int { debug!("emscripten::___map_file"); // NOTE: TODO: Em returns -1 here as well. May need to implement properly -1 diff --git a/lib/emscripten/src/process.rs b/lib/emscripten/src/process.rs index 39b88d27384..f5fe4eb07d9 100644 --- a/lib/emscripten/src/process.rs +++ b/lib/emscripten/src/process.rs @@ -7,33 +7,33 @@ type PidT = c_int; use crate::EmEnv; -pub fn abort_with_message(ctx: &mut EmEnv, message: &str) { +pub fn abort_with_message(ctx: &EmEnv, message: &str) { debug!("emscripten::abort_with_message"); println!("{}", message); _abort(ctx); } /// The name of this call is `abort` but we want to avoid conflicts with libc::abort -pub fn em_abort(ctx: &mut EmEnv, arg: u32) { +pub fn em_abort(ctx: &EmEnv, arg: u32) { debug!("emscripten::abort"); eprintln!("Program aborted with value {}", arg); _abort(ctx); } -pub fn _abort(_ctx: &mut EmEnv) { +pub fn _abort(_ctx: &EmEnv) { debug!("emscripten::_abort"); unsafe { abort(); } } -pub fn _prctl(ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _prctl(ctx: &EmEnv, _a: i32, _b: i32) -> i32 { debug!("emscripten::_prctl"); abort_with_message(ctx, "missing function: prctl"); -1 } -pub fn _fork(_ctx: &mut EmEnv) -> PidT { +pub fn _fork(_ctx: &EmEnv) -> PidT { debug!("emscripten::_fork"); // unsafe { // fork() @@ -41,132 +41,132 @@ pub fn _fork(_ctx: &mut EmEnv) -> PidT { -1 } -pub fn _endgrent(_ctx: &mut EmEnv) { +pub fn _endgrent(_ctx: &EmEnv) { debug!("emscripten::_endgrent"); } -pub fn _execve(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { +pub fn _execve(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { debug!("emscripten::_execve"); -1 } #[allow(unreachable_code)] -pub fn _exit(_ctx: &mut EmEnv, status: c_int) { +pub fn _exit(_ctx: &EmEnv, status: c_int) { // -> ! debug!("emscripten::_exit {}", status); unsafe { exit(status) } } -pub fn _kill(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn _kill(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::_kill"); -1 } -pub fn _sched_yield(_ctx: &mut EmEnv) -> i32 { +pub fn _sched_yield(_ctx: &EmEnv) -> i32 { debug!("emscripten::_sched_yield"); -1 } -pub fn _llvm_stacksave(_ctx: &mut EmEnv) -> i32 { +pub fn _llvm_stacksave(_ctx: &EmEnv) -> i32 { debug!("emscripten::_llvm_stacksave"); -1 } -pub fn _llvm_stackrestore(_ctx: &mut EmEnv, _one: i32) { +pub fn _llvm_stackrestore(_ctx: &EmEnv, _one: i32) { debug!("emscripten::_llvm_stackrestore"); } -pub fn _raise(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _raise(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_raise"); -1 } -pub fn _sem_init(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { +pub fn _sem_init(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { debug!("emscripten::_sem_init: {}, {}, {}", _one, _two, _three); 0 } -pub fn _sem_destroy(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _sem_destroy(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_sem_destroy"); 0 } -pub fn _sem_post(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _sem_post(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_sem_post"); -1 } -pub fn _sem_wait(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _sem_wait(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_sem_post"); -1 } #[allow(clippy::cast_ptr_alignment)] -pub fn _getgrent(_ctx: &mut EmEnv) -> c_int { +pub fn _getgrent(_ctx: &EmEnv) -> c_int { debug!("emscripten::_getgrent"); -1 } -pub fn _setgrent(_ctx: &mut EmEnv) { +pub fn _setgrent(_ctx: &EmEnv) { debug!("emscripten::_setgrent"); } -pub fn _setgroups(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn _setgroups(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::_setgroups"); -1 } -pub fn _setitimer(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { +pub fn _setitimer(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { debug!("emscripten::_setitimer"); -1 } -pub fn _usleep(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _usleep(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_usleep"); -1 } -pub fn _nanosleep(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn _nanosleep(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::_nanosleep"); -1 } -pub fn _utime(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn _utime(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::_utime"); -1 } -pub fn _utimes(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn _utimes(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::_utimes"); -1 } -pub fn _wait(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _wait(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_wait"); -1 } -pub fn _wait3(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { +pub fn _wait3(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { debug!("emscripten::_wait3"); -1 } -pub fn _wait4(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 { +pub fn _wait4(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 { debug!("emscripten::_wait4"); -1 } -pub fn _waitid(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 { +pub fn _waitid(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32, _d: i32) -> i32 { debug!("emscripten::_waitid"); -1 } -pub fn _waitpid(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { +pub fn _waitpid(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { debug!("emscripten::_waitpid"); -1 } -pub fn abort_stack_overflow(ctx: &mut EmEnv, _what: c_int) { +pub fn abort_stack_overflow(ctx: &EmEnv, _what: c_int) { debug!("emscripten::abort_stack_overflow"); // TODO: Message incomplete. Need to finish em runtime data first abort_with_message( @@ -175,24 +175,24 @@ pub fn abort_stack_overflow(ctx: &mut EmEnv, _what: c_int) { ); } -pub fn _llvm_trap(ctx: &mut EmEnv) { +pub fn _llvm_trap(ctx: &EmEnv) { debug!("emscripten::_llvm_trap"); abort_with_message(ctx, "abort!"); } -pub fn _llvm_eh_typeid_for(_ctx: &mut EmEnv, _type_info_addr: u32) -> i32 { +pub fn _llvm_eh_typeid_for(_ctx: &EmEnv, _type_info_addr: u32) -> i32 { debug!("emscripten::_llvm_eh_typeid_for"); -1 } -pub fn _system(_ctx: &mut EmEnv, _one: i32) -> c_int { +pub fn _system(_ctx: &EmEnv, _one: i32) -> c_int { debug!("emscripten::_system"); // TODO: May need to change this Em impl to a working version eprintln!("Can't call external programs"); EAGAIN } -pub fn _popen(_ctx: &mut EmEnv, _one: i32, _two: i32) -> c_int { +pub fn _popen(_ctx: &EmEnv, _one: i32, _two: i32) -> c_int { debug!("emscripten::_popen"); // TODO: May need to change this Em impl to a working version eprintln!("Missing function: popen"); diff --git a/lib/emscripten/src/pthread.rs b/lib/emscripten/src/pthread.rs index 17c14f6effa..51eedd1f345 100644 --- a/lib/emscripten/src/pthread.rs +++ b/lib/emscripten/src/pthread.rs @@ -1,12 +1,12 @@ use crate::EmEnv; -pub fn _pthread_attr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_attr_destroy(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_attr_destroy"); 0 } pub fn _pthread_attr_getstack( - _ctx: &mut EmEnv, + _ctx: &EmEnv, _stackaddr: i32, _stacksize: i32, _other: i32, @@ -23,175 +23,175 @@ pub fn _pthread_attr_getstack( 0 } -pub fn _pthread_attr_init(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_attr_init(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_attr_init({})", _a); 0 } -pub fn _pthread_attr_setstacksize(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_attr_setstacksize(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_attr_setstacksize"); 0 } -pub fn _pthread_cleanup_pop(_ctx: &mut EmEnv, _a: i32) { +pub fn _pthread_cleanup_pop(_ctx: &EmEnv, _a: i32) { trace!("emscripten::_pthread_cleanup_pop"); } -pub fn _pthread_cleanup_push(_ctx: &mut EmEnv, _a: i32, _b: i32) { +pub fn _pthread_cleanup_push(_ctx: &EmEnv, _a: i32, _b: i32) { trace!("emscripten::_pthread_cleanup_push"); } -pub fn _pthread_cond_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_cond_destroy(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_cond_destroy"); 0 } -pub fn _pthread_cond_init(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_cond_init(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_cond_init"); 0 } -pub fn _pthread_cond_signal(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_cond_signal(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_cond_signal"); 0 } -pub fn _pthread_cond_timedwait(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32) -> i32 { +pub fn _pthread_cond_timedwait(_ctx: &EmEnv, _a: i32, _b: i32, _c: i32) -> i32 { trace!("emscripten::_pthread_cond_timedwait"); 0 } -pub fn _pthread_cond_wait(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_cond_wait(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_cond_wait"); 0 } -pub fn _pthread_condattr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_condattr_destroy(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_condattr_destroy"); 0 } -pub fn _pthread_condattr_init(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_condattr_init(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_condattr_init"); 0 } -pub fn _pthread_condattr_setclock(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_condattr_setclock(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_condattr_setclock"); 0 } -pub fn _pthread_create(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 { +pub fn _pthread_create(_ctx: &EmEnv, _a: i32, _b: i32, _c: i32, _d: i32) -> i32 { trace!("emscripten::_pthread_create"); // 11 seems to mean "no" 11 } -pub fn _pthread_detach(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_detach(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_detach"); 0 } -pub fn _pthread_equal(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_equal(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_equal"); 0 } -pub fn _pthread_exit(_ctx: &mut EmEnv, _a: i32) { +pub fn _pthread_exit(_ctx: &EmEnv, _a: i32) { trace!("emscripten::_pthread_exit"); } -pub fn _pthread_getattr_np(_ctx: &mut EmEnv, _thread: i32, _attr: i32) -> i32 { +pub fn _pthread_getattr_np(_ctx: &EmEnv, _thread: i32, _attr: i32) -> i32 { trace!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr); 0 } -pub fn _pthread_getspecific(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_getspecific(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_getspecific"); 0 } -pub fn _pthread_join(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_join(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_join"); 0 } -pub fn _pthread_self(_ctx: &mut EmEnv) -> i32 { +pub fn _pthread_self(_ctx: &EmEnv) -> i32 { trace!("emscripten::_pthread_self"); 0 } -pub fn _pthread_key_create(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_key_create(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_key_create"); 0 } -pub fn _pthread_mutex_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_mutex_destroy(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_mutex_destroy"); 0 } -pub fn _pthread_mutex_init(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_mutex_init(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_mutex_init"); 0 } -pub fn _pthread_mutexattr_destroy(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_mutexattr_destroy(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_mutexattr_destroy"); 0 } -pub fn _pthread_mutexattr_init(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_mutexattr_init(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_mutexattr_init"); 0 } -pub fn _pthread_mutexattr_settype(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_mutexattr_settype(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_mutexattr_settype"); 0 } -pub fn _pthread_once(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_once(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_once"); 0 } -pub fn _pthread_rwlock_destroy(_ctx: &mut EmEnv, _rwlock: i32) -> i32 { +pub fn _pthread_rwlock_destroy(_ctx: &EmEnv, _rwlock: i32) -> i32 { trace!("emscripten::_pthread_rwlock_destroy({})", _rwlock); 0 } -pub fn _pthread_rwlock_init(_ctx: &mut EmEnv, _rwlock: i32, _attr: i32) -> i32 { +pub fn _pthread_rwlock_init(_ctx: &EmEnv, _rwlock: i32, _attr: i32) -> i32 { trace!("emscripten::_pthread_rwlock_init({}, {})", _rwlock, _attr); 0 } -pub fn _pthread_rwlock_rdlock(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_rwlock_rdlock(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_rwlock_rdlock"); 0 } -pub fn _pthread_rwlock_unlock(_ctx: &mut EmEnv, _a: i32) -> i32 { +pub fn _pthread_rwlock_unlock(_ctx: &EmEnv, _a: i32) -> i32 { trace!("emscripten::_pthread_rwlock_unlock"); 0 } -pub fn _pthread_rwlock_wrlock(_ctx: &mut EmEnv, _rwlock: i32) -> i32 { +pub fn _pthread_rwlock_wrlock(_ctx: &EmEnv, _rwlock: i32) -> i32 { trace!("emscripten::_pthread_rwlock_wrlock({})", _rwlock); 0 } -pub fn _pthread_setcancelstate(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_setcancelstate(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_setcancelstate"); 0 } -pub fn _pthread_setspecific(_ctx: &mut EmEnv, _a: i32, _b: i32) -> i32 { +pub fn _pthread_setspecific(_ctx: &EmEnv, _a: i32, _b: i32) -> i32 { trace!("emscripten::_pthread_setspecific"); 0 } -pub fn _pthread_sigmask(_ctx: &mut EmEnv, _a: i32, _b: i32, _c: i32) -> i32 { +pub fn _pthread_sigmask(_ctx: &EmEnv, _a: i32, _b: i32, _c: i32) -> i32 { trace!("emscripten::_pthread_sigmask"); 0 } diff --git a/lib/emscripten/src/signal.rs b/lib/emscripten/src/signal.rs index 16d36586025..34fd22416b2 100644 --- a/lib/emscripten/src/signal.rs +++ b/lib/emscripten/src/signal.rs @@ -2,7 +2,7 @@ use crate::EmEnv; #[allow(clippy::cast_ptr_alignment)] -pub fn _sigemptyset(ctx: &mut EmEnv, set: u32) -> i32 { +pub fn _sigemptyset(ctx: &EmEnv, set: u32) -> i32 { debug!("emscripten::_sigemptyset"); let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32; unsafe { @@ -11,18 +11,18 @@ pub fn _sigemptyset(ctx: &mut EmEnv, set: u32) -> i32 { 0 } -pub fn _sigaction(_ctx: &mut EmEnv, _signum: u32, _act: u32, _oldact: u32) -> i32 { +pub fn _sigaction(_ctx: &EmEnv, _signum: u32, _act: u32, _oldact: u32) -> i32 { debug!("emscripten::_sigaction {}, {}, {}", _signum, _act, _oldact); 0 } -pub fn _siginterrupt(_ctx: &mut EmEnv, _a: u32, _b: u32) -> i32 { +pub fn _siginterrupt(_ctx: &EmEnv, _a: u32, _b: u32) -> i32 { debug!("emscripten::_siginterrupt {}, {}", _a, _b); 0 } #[allow(clippy::cast_ptr_alignment)] -pub fn _sigaddset(ctx: &mut EmEnv, set: u32, signum: u32) -> i32 { +pub fn _sigaddset(ctx: &EmEnv, set: u32, signum: u32) -> i32 { debug!("emscripten::_sigaddset {}, {}", set, signum); let set_addr = emscripten_memory_pointer!(ctx.memory(0), set) as *mut u32; unsafe { @@ -31,17 +31,17 @@ pub fn _sigaddset(ctx: &mut EmEnv, set: u32, signum: u32) -> i32 { 0 } -pub fn _sigsuspend(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _sigsuspend(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_sigsuspend"); -1 } -pub fn _sigprocmask(_ctx: &mut EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { +pub fn _sigprocmask(_ctx: &EmEnv, _one: i32, _two: i32, _three: i32) -> i32 { debug!("emscripten::_sigprocmask"); 0 } -pub fn _signal(_ctx: &mut EmEnv, _sig: u32, _two: i32) -> i32 { +pub fn _signal(_ctx: &EmEnv, _sig: u32, _two: i32) -> i32 { debug!("emscripten::_signal ({})", _sig); 0 } diff --git a/lib/emscripten/src/syscalls/mod.rs b/lib/emscripten/src/syscalls/mod.rs index dc1b4d2f37d..1922e249643 100644 --- a/lib/emscripten/src/syscalls/mod.rs +++ b/lib/emscripten/src/syscalls/mod.rs @@ -52,7 +52,7 @@ use std::io::Error; use std::slice; /// exit -pub fn ___syscall1(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) { +pub fn ___syscall1(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) { debug!("emscripten::___syscall1 (exit) {}", _which); let status: i32 = varargs.get(ctx); unsafe { @@ -61,7 +61,7 @@ pub fn ___syscall1(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) { } /// read -pub fn ___syscall3(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { +pub fn ___syscall3(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { // -> ssize_t debug!("emscripten::___syscall3 (read) {}", _which); let fd: i32 = varargs.get(ctx); @@ -75,7 +75,7 @@ pub fn ___syscall3(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { } /// write -pub fn ___syscall4(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall4(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall4 (write) {}", _which); let fd: i32 = varargs.get(ctx); let buf: i32 = varargs.get(ctx); @@ -86,7 +86,7 @@ pub fn ___syscall4(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in } /// close -pub fn ___syscall6(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall6(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall6 (close) {}", _which); let fd: i32 = varargs.get(ctx); debug!("fd: {}", fd); @@ -94,7 +94,7 @@ pub fn ___syscall6(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in } // chdir -pub fn ___syscall12(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall12(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall12 (chdir) {}", _which); let path_ptr = varargs.get_str(ctx); let real_path_owned = get_cstr_path(ctx, path_ptr as *const _); @@ -112,59 +112,59 @@ pub fn ___syscall12(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i ret } -pub fn ___syscall10(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall10(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall10"); -1 } -pub fn ___syscall14(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall14(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall14"); -1 } -pub fn ___syscall15(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall15(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall15"); -1 } // getpid -pub fn ___syscall20(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall20(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall20 (getpid)"); unsafe { getpid() } } -pub fn ___syscall21(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall21(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall21"); -1 } -pub fn ___syscall25(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall25(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall25"); -1 } -pub fn ___syscall29(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall29(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall29"); -1 } -pub fn ___syscall32(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall32(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall32"); -1 } -pub fn ___syscall33(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall33(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall33"); -1 } -pub fn ___syscall36(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall36(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall36"); -1 } // rename -pub fn ___syscall38(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { +pub fn ___syscall38(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { debug!("emscripten::___syscall38 (rename)"); let old_path = varargs.get_str(ctx); let new_path = varargs.get_str(ctx); @@ -191,7 +191,7 @@ pub fn ___syscall38(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 } // rmdir -pub fn ___syscall40(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall40(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall40 (rmdir)"); let pathname_addr = varargs.get_str(ctx); let real_path_owned = get_cstr_path(ctx, pathname_addr as *const _); @@ -204,7 +204,7 @@ pub fn ___syscall40(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i } // pipe -pub fn ___syscall42(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall42(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall42 (pipe)"); // offset to a file descriptor, which contains a read end and write end, 2 integers let fd_offset: u32 = varargs.get(ctx); @@ -232,28 +232,28 @@ pub fn ___syscall42(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i result } -pub fn ___syscall51(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall51(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall51"); -1 } -pub fn ___syscall52(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall52(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall52"); -1 } -pub fn ___syscall53(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall53(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall53"); -1 } -pub fn ___syscall60(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall60(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall60"); -1 } // dup2 -pub fn ___syscall63(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall63(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall63 (dup2) {}", _which); let src: i32 = varargs.get(ctx); @@ -263,93 +263,93 @@ pub fn ___syscall63(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i } // getppid -pub fn ___syscall64(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall64(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall64 (getppid)"); unsafe { getpid() } } -pub fn ___syscall66(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall66(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall66"); -1 } -pub fn ___syscall75(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall75(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall75"); -1 } -pub fn ___syscall91(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall91(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall91 - stub"); 0 } -pub fn ___syscall96(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall96(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall96"); -1 } -pub fn ___syscall97(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall97(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall97"); -1 } -pub fn ___syscall110(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall110(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall110"); -1 } -pub fn ___syscall121(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall121(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall121"); -1 } -pub fn ___syscall125(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall125(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall125"); -1 } -pub fn ___syscall133(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall133(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall133"); -1 } -pub fn ___syscall144(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall144(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall144"); -1 } -pub fn ___syscall147(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall147(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall147"); -1 } -pub fn ___syscall150(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall150(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall150"); -1 } -pub fn ___syscall151(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall151(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall151"); -1 } -pub fn ___syscall152(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall152(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall152"); -1 } -pub fn ___syscall153(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall153(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall153"); -1 } -pub fn ___syscall163(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall163(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall163"); -1 } // getcwd -pub fn ___syscall183(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { +pub fn ___syscall183(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { debug!("emscripten::___syscall183"); let buf_offset: WasmPtr = varargs.get(ctx); let _size: c_int = varargs.get(ctx); @@ -366,7 +366,7 @@ pub fn ___syscall183(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i3 } // mmap2 -pub fn ___syscall192(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall192(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall192 (mmap2) {}", _which); let _addr: i32 = varargs.get(ctx); let len: u32 = varargs.get(ctx); @@ -401,7 +401,7 @@ pub fn ___syscall192(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// lseek -pub fn ___syscall140(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { +pub fn ___syscall140(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { // -> c_int debug!("emscripten::___syscall140 (lseek) {}", _which); let fd: i32 = varargs.get(ctx); @@ -429,7 +429,7 @@ pub fn ___syscall140(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 /// readv #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall145(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { +pub fn ___syscall145(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { // -> ssize_t debug!("emscripten::___syscall145 (readv) {}", _which); @@ -466,7 +466,7 @@ pub fn ___syscall145(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i3 // writev #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall146(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { +pub fn ___syscall146(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { // -> ssize_t debug!("emscripten::___syscall146 (writev) {}", _which); let fd: i32 = varargs.get(ctx); @@ -507,7 +507,7 @@ pub fn ___syscall146(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 ret as _ } -pub fn ___syscall191(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { +pub fn ___syscall191(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { let _resource: i32 = varargs.get(ctx); debug!( "emscripten::___syscall191 - mostly stub, resource: {}", @@ -524,13 +524,13 @@ pub fn ___syscall191(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 0 } -pub fn ___syscall193(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall193(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall193"); -1 } // stat64 -pub fn ___syscall195(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall195(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall195 (stat64) {}", _which); let pathname_addr = varargs.get_str(ctx); let buf: u32 = varargs.get(ctx); @@ -561,7 +561,7 @@ pub fn ___syscall195(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } // fstat64 -pub fn ___syscall197(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall197(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall197 (fstat64) {}", _which); let fd: c_int = varargs.get(ctx); @@ -580,129 +580,129 @@ pub fn ___syscall197(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ 0 } -pub fn ___syscall209(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall209(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall209"); -1 } -pub fn ___syscall211(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall211(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall211"); -1 } -pub fn ___syscall218(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall218(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall218"); -1 } -pub fn ___syscall268(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall268(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall268"); -1 } -pub fn ___syscall269(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall269(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall269"); -1 } -pub fn ___syscall272(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall272(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall272"); -1 } -pub fn ___syscall295(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall295(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall295"); -1 } -pub fn ___syscall296(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall296(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall296"); -1 } -pub fn ___syscall297(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall297(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall297"); -1 } -pub fn ___syscall298(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall298(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall298"); -1 } -pub fn ___syscall300(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall300(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall300"); -1 } -pub fn ___syscall301(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall301(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall301"); -1 } -pub fn ___syscall302(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall302(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall302"); -1 } -pub fn ___syscall303(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall303(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall303"); -1 } -pub fn ___syscall304(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall304(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall304"); -1 } -pub fn ___syscall305(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall305(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall305"); -1 } -pub fn ___syscall306(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall306(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall306"); -1 } -pub fn ___syscall307(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall307(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall307"); -1 } -pub fn ___syscall308(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall308(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall308"); -1 } // utimensat -pub fn ___syscall320(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall320(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall320 (utimensat), {}", _which); 0 } -pub fn ___syscall331(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall331(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall331"); -1 } -pub fn ___syscall333(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall333(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall333"); -1 } -pub fn ___syscall334(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall334(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall334"); -1 } -pub fn ___syscall337(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall337(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall337"); -1 } // prlimit64 -pub fn ___syscall340(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall340(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall340 (prlimit64), {}", _which); // NOTE: Doesn't really matter. Wasm modules cannot exceed WASM_PAGE_SIZE anyway. let _pid: i32 = varargs.get(ctx); @@ -728,7 +728,7 @@ pub fn ___syscall340(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ 0 } -pub fn ___syscall345(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall345(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall345"); -1 } diff --git a/lib/emscripten/src/syscalls/unix.rs b/lib/emscripten/src/syscalls/unix.rs index fac1cb30af0..10fa10ec9d6 100644 --- a/lib/emscripten/src/syscalls/unix.rs +++ b/lib/emscripten/src/syscalls/unix.rs @@ -156,7 +156,7 @@ use libc::SO_NOSIGPIPE; const SO_NOSIGPIPE: c_int = 0; /// open -pub fn ___syscall5(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall5(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall5 (open) {}", _which); let pathname_addr = varargs.get_str(ctx); let flags: i32 = varargs.get(ctx); @@ -180,7 +180,7 @@ pub fn ___syscall5(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in } /// link -pub fn ___syscall9(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall9(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall9 (link) {}", _which); let oldname_ptr = varargs.get_str(ctx); @@ -196,7 +196,7 @@ pub fn ___syscall9(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_in } /// getrusage -pub fn ___syscall77(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall77(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall77 (getrusage) {}", _which); let resource: c_int = varargs.get(ctx); @@ -208,7 +208,7 @@ pub fn ___syscall77(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i } /// symlink -pub fn ___syscall83(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall83(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall83 (symlink) {}", _which); let path1 = varargs.get_str(ctx); @@ -236,7 +236,7 @@ pub fn ___syscall83(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i } /// readlink -pub fn ___syscall85(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { +pub fn ___syscall85(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 { debug!("emscripten::___syscall85 (readlink)"); let pathname_addr = varargs.get_str(ctx); let buf = varargs.get_str(ctx); @@ -265,7 +265,7 @@ pub fn ___syscall85(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> i32 } /// ftruncate64 -pub fn ___syscall194(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall194(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall194 (ftruncate64) {}", _which); let _fd: c_int = varargs.get(ctx); let _length: i64 = varargs.get(ctx); @@ -282,7 +282,7 @@ pub fn ___syscall194(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// lchown -pub fn ___syscall198(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall198(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall198 (lchown) {}", _which); let path_ptr = varargs.get_str(ctx); let real_path_owned = utils::get_cstr_path(ctx, path_ptr as *const _); @@ -305,7 +305,7 @@ pub fn ___syscall198(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// getgroups -pub fn ___syscall205(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall205(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall205 (getgroups) {}", _which); let ngroups_max: c_int = varargs.get(ctx); let groups: c_int = varargs.get(ctx); @@ -322,7 +322,7 @@ pub fn ___syscall205(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } // chown -pub fn ___syscall212(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall212(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall212 (chown) {}", _which); let pathname_addr = varargs.get_str(ctx); @@ -339,7 +339,7 @@ pub fn ___syscall212(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// madvise -pub fn ___syscall219(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall219(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall212 (chown) {}", _which); let addr_ptr: c_int = varargs.get(ctx); @@ -352,7 +352,7 @@ pub fn ___syscall219(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// access -pub fn ___syscall33(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall33(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall33 (access) {}", _which); let path = varargs.get_str(ctx); let real_path_owned = utils::get_cstr_path(ctx, path as *const _); @@ -373,14 +373,14 @@ pub fn ___syscall33(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i } /// nice -pub fn ___syscall34(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall34(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall34 (nice) {}", _which); let inc_r: c_int = varargs.get(ctx); unsafe { nice(inc_r) } } // mkdir -pub fn ___syscall39(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall39(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall39 (mkdir) {}", _which); let pathname_addr = varargs.get_str(ctx); let real_path_owned = utils::get_cstr_path(ctx, pathname_addr as *const _); @@ -394,20 +394,20 @@ pub fn ___syscall39(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i } /// dup -pub fn ___syscall41(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall41(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall41 (dup) {}", _which); let fd: c_int = varargs.get(ctx); unsafe { dup(fd) } } /// getgid32 -pub fn ___syscall200(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall200(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall200 (getgid32)"); unsafe { getgid() as i32 } } // geteuid32 -pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall201(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall201 (geteuid32)"); unsafe { // Maybe fix: Emscripten returns 0 always @@ -416,7 +416,7 @@ pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { } // getegid32 -pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall202(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { // gid_t debug!("emscripten::___syscall202 (getegid32)"); unsafe { @@ -426,7 +426,7 @@ pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { } /// fchown -pub fn ___syscall207(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall207(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall207 (fchown) {}", _which); let fd: c_int = varargs.get(ctx); let owner: uid_t = varargs.get(ctx); @@ -435,7 +435,7 @@ pub fn ___syscall207(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// dup3 -pub fn ___syscall330(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t { +pub fn ___syscall330(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t { // Implementation based on description at https://linux.die.net/man/2/dup3 debug!("emscripten::___syscall330 (dup3)"); let oldfd: c_int = varargs.get(ctx); @@ -469,7 +469,7 @@ pub fn ___syscall330(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pi } /// ioctl -pub fn ___syscall54(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall54(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall54 (ioctl) {}", _which); let fd: i32 = varargs.get(ctx); @@ -511,7 +511,7 @@ const SOCK_CLOEXC: i32 = 0x80000; // socketcall #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall102(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall102(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall102 (socketcall) {}", _which); let call: u32 = varargs.get(ctx); let mut socket_varargs: VarArgs = varargs.get(ctx); @@ -829,7 +829,7 @@ fn translate_socket_name_flag(name: i32) -> i32 { } /// getpgid -pub fn ___syscall132(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall132(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall132 (getpgid)"); let pid: pid_t = varargs.get(ctx); @@ -853,7 +853,7 @@ pub struct EmPollFd { unsafe impl wasmer::ValueType for EmPollFd {} /// poll -pub fn ___syscall168(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { +pub fn ___syscall168(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { debug!("emscripten::___syscall168(poll)"); let fds: WasmPtr = varargs.get(ctx); let nfds: u32 = varargs.get(ctx); @@ -873,7 +873,7 @@ pub fn ___syscall168(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 } // pread -pub fn ___syscall180(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall180(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall180 (pread) {}", _which); let fd: i32 = varargs.get(ctx); let buf: u32 = varargs.get(ctx); @@ -890,7 +890,7 @@ pub fn ___syscall180(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } // pwrite -pub fn ___syscall181(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall181(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall181 (pwrite) {}", _which); let fd: i32 = varargs.get(ctx); let buf: u32 = varargs.get(ctx); @@ -911,7 +911,7 @@ pub fn ___syscall181(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// fchmod -pub fn ___syscall94(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall94(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall118 (fchmod) {}", _which); let fd: c_int = varargs.get(ctx); let mode: mode_t = varargs.get(ctx); @@ -920,7 +920,7 @@ pub fn ___syscall94(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i /// wait4 #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall114(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t { +pub fn ___syscall114(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> pid_t { debug!("emscripten::___syscall114 (wait4)"); let pid: pid_t = varargs.get(ctx); let status: u32 = varargs.get(ctx); @@ -938,7 +938,7 @@ pub fn ___syscall114(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> pi } /// fsync -pub fn ___syscall118(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall118(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall118 (fsync) {}", _which); let fd: c_int = varargs.get(ctx); unsafe { fsync(fd) } @@ -946,7 +946,7 @@ pub fn ___syscall118(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ // select #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall142(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall142(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall142 (newselect) {}", _which); let nfds: i32 = varargs.get(ctx); @@ -968,7 +968,7 @@ pub fn ___syscall142(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// fdatasync -pub fn ___syscall148(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall148(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall148 (fdatasync) {}", _which); let fd: i32 = varargs.get(ctx); @@ -977,7 +977,7 @@ pub fn ___syscall148(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } // setpgid -pub fn ___syscall57(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall57(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall57 (setpgid) {}", _which); let pid: i32 = varargs.get(ctx); @@ -993,7 +993,7 @@ pub fn ___syscall57(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_i /// uname // NOTE: Wondering if we should return custom utsname, like Emscripten. -pub fn ___syscall122(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall122(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall122 (uname) {}", _which); let buf: u32 = varargs.get(ctx); debug!("=> buf: {}", buf); @@ -1002,7 +1002,7 @@ pub fn ___syscall122(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// lstat64 -pub fn ___syscall196(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { +pub fn ___syscall196(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { debug!("emscripten::___syscall196 (lstat64) {}", _which); let path = varargs.get_str(ctx); let real_path_owned = utils::get_cstr_path(ctx, path as *const _); @@ -1035,7 +1035,7 @@ pub fn ___syscall196(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 } // getuid -pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall199(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall199 (getuid)"); let uid = unsafe { getuid() as _ }; debug!(" => {}", uid); @@ -1045,7 +1045,7 @@ pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { // getdents // dirent structure is // i64, i64, u16 (280), i8, [i8; 256] -pub fn ___syscall220(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { +pub fn ___syscall220(ctx: &EmEnv, _which: i32, mut varargs: VarArgs) -> i32 { use super::super::env::get_emscripten_data; let fd: i32 = varargs.get(ctx); @@ -1109,7 +1109,7 @@ pub fn ___syscall220(ctx: &mut EmEnv, _which: i32, mut varargs: VarArgs) -> i32 } // fcntl64 -pub fn ___syscall221(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall221(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall221 (fcntl64) {}", _which); let fd: i32 = varargs.get(ctx); let cmd: i32 = varargs.get(ctx); @@ -1127,7 +1127,7 @@ pub fn ___syscall221(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_ } /// fallocate -pub fn ___syscall324(ctx: &mut EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall324(ctx: &EmEnv, _which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall324 (fallocate) {}", _which); let _fd: c_int = varargs.get(ctx); let _mode: c_int = varargs.get(ctx); diff --git a/lib/emscripten/src/syscalls/windows.rs b/lib/emscripten/src/syscalls/windows.rs index ca1acb4f367..abd2ad94aad 100644 --- a/lib/emscripten/src/syscalls/windows.rs +++ b/lib/emscripten/src/syscalls/windows.rs @@ -13,7 +13,7 @@ use std::os::raw::c_int; type pid_t = c_int; /// open -pub fn ___syscall5(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall5(ctx: &EmEnv, which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall5 (open) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -64,19 +64,19 @@ pub fn ___syscall5(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int } /// link -pub fn ___syscall9(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall9(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall9 (link) {}", _which); unimplemented!("emscripten::___syscall9 (link) {}", _which); } /// ftruncate64 -pub fn ___syscall194(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall194(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall194 - stub"); unimplemented!("emscripten::___syscall194 - stub") } // chown -pub fn ___syscall212(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall212(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall212 (chown) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -84,19 +84,19 @@ pub fn ___syscall212(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c } /// access -pub fn ___syscall33(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall33(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall33 (access) {}", _which); unimplemented!("emscripten::___syscall33 (access) {}", _which); } /// nice -pub fn ___syscall34(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall34(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall34 (nice) {}", _which); unimplemented!("emscripten::___syscall34 (nice) {}", _which); } // mkdir -pub fn ___syscall39(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_int { +pub fn ___syscall39(ctx: &EmEnv, which: c_int, mut varargs: VarArgs) -> c_int { debug!("emscripten::___syscall39 (mkdir) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -111,80 +111,80 @@ pub fn ___syscall39(ctx: &mut EmEnv, which: c_int, mut varargs: VarArgs) -> c_in } /// dup -pub fn ___syscall41(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall41(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall41 (dup) {}", _which); unimplemented!("emscripten::___syscall41 (dup) {}", _which); } /// getrusage -pub fn ___syscall77(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall77(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall77 (getrusage) {}", _which); unimplemented!("emscripten::___syscall77 (getrusage) {}", _which); } /// symlink -pub fn ___syscall83(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall83(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall83 (symlink) {}", _which); unimplemented!("emscripten::___syscall83 (symlink) {}", _which); } /// readlink -pub fn ___syscall85(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall85(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall85 (readlink) {}", _which); -1 } /// getpgid -pub fn ___syscall132(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall132(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall132 (getpgid)"); -1 } /// lchown -pub fn ___syscall198(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall198(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall198 (lchown) {}", _which); unimplemented!("emscripten::___syscall198 (lchown) {}", _which); } /// getgid32 -pub fn ___syscall200(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall200(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall200 (getgid32)"); unimplemented!("emscripten::___syscall200 (getgid32)"); } // geteuid32 -pub fn ___syscall201(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall201(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall201 (geteuid32)"); unimplemented!("emscripten::___syscall201 (geteuid32)"); } // getegid32 -pub fn ___syscall202(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall202(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { // gid_t debug!("emscripten::___syscall202 (getegid32)"); unimplemented!("emscripten::___syscall202 (getegid32)"); } /// getgroups -pub fn ___syscall205(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall205(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall205 (getgroups) {}", _which); unimplemented!("emscripten::___syscall205 (getgroups) {}", _which); } /// madvise -pub fn ___syscall219(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall219(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall212 (chown) {}", _which); unimplemented!("emscripten::___syscall212 (chown) {}", _which); } /// dup3 -pub fn ___syscall330(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t { +pub fn ___syscall330(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t { debug!("emscripten::___syscall330 (dup3)"); -1 } /// ioctl -pub fn ___syscall54(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall54(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall54 (ioctl) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -192,14 +192,14 @@ pub fn ___syscall54(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_ } /// fchmod -pub fn ___syscall94(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall94(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall118 (fchmod) {}", _which); unimplemented!("emscripten::___syscall118 (fchmod) {}", _which); } // socketcall #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall102(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall102(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall102 (socketcall) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -207,13 +207,13 @@ pub fn ___syscall102(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c } /// fsync -pub fn ___syscall118(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall118(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall118 (fsync) {}", _which); unimplemented!("emscripten::___syscall118 (fsync) {}", _which); } // pread -pub fn ___syscall180(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall180(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall180 (pread) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -221,7 +221,7 @@ pub fn ___syscall180(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c } // pwrite -pub fn ___syscall181(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall181(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall181 (pwrite) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -230,14 +230,14 @@ pub fn ___syscall181(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c /// wait4 #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall114(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t { +pub fn ___syscall114(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> pid_t { debug!("emscripten::___syscall114 (wait4)"); -1 } // select #[allow(clippy::cast_ptr_alignment)] -pub fn ___syscall142(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall142(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall142 (newselect) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -245,13 +245,13 @@ pub fn ___syscall142(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c } /// fdatasync -pub fn ___syscall148(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall148(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall148 (fdatasync) {}", _which); unimplemented!("emscripten::___syscall148 (fdatasync) {}", _which); } // setpgid -pub fn ___syscall57(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall57(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall57 (setpgid) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -260,7 +260,7 @@ pub fn ___syscall57(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_ /// uname // NOTE: Wondering if we should return custom utsname, like Emscripten. -pub fn ___syscall122(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall122(_ctx: &EmEnv, which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall122 (uname) {}", which); #[cfg(not(feature = "debug"))] let _ = which; @@ -268,43 +268,43 @@ pub fn ___syscall122(_ctx: &mut EmEnv, which: c_int, mut _varargs: VarArgs) -> c } /// poll -pub fn ___syscall168(_ctx: &mut EmEnv, _which: i32, _varargs: VarArgs) -> i32 { +pub fn ___syscall168(_ctx: &EmEnv, _which: i32, _varargs: VarArgs) -> i32 { debug!("emscripten::___syscall168(poll) - stub"); -1 } /// lstat64 -pub fn ___syscall196(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall196(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall196 (lstat64) - stub"); -1 } // getuid -pub fn ___syscall199(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall199(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall199 (getuid)"); -1 } // getdents -pub fn ___syscall220(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn ___syscall220(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::___syscall220"); -1 } // fcntl64 -pub fn ___syscall221(_ctx: &mut EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { +pub fn ___syscall221(_ctx: &EmEnv, _which: c_int, mut _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall221 (fcntl64) {}", _which); -1 } /// fchown -pub fn ___syscall207(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall207(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall207 (fchown) {}", _which); unimplemented!("emscripten::___syscall207 (fchown) {}", _which) } /// fallocate -pub fn ___syscall324(_ctx: &mut EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { +pub fn ___syscall324(_ctx: &EmEnv, _which: c_int, _varargs: VarArgs) -> c_int { debug!("emscripten::___syscall324 (fallocate) {}", _which); unimplemented!("emscripten::___syscall324 (fallocate) {}", _which) } diff --git a/lib/emscripten/src/time.rs b/lib/emscripten/src/time.rs index 50b1091df3f..e402162cd50 100644 --- a/lib/emscripten/src/time.rs +++ b/lib/emscripten/src/time.rs @@ -52,7 +52,7 @@ const CLOCK_MONOTONIC_COARSE: clockid_t = 6; /// emscripten: _gettimeofday #[allow(clippy::cast_ptr_alignment)] -pub fn _gettimeofday(ctx: &mut EmEnv, tp: c_int, tz: c_int) -> c_int { +pub fn _gettimeofday(ctx: &EmEnv, tp: c_int, tz: c_int) -> c_int { debug!("emscripten::_gettimeofday {} {}", tp, tz); #[repr(C)] struct GuestTimeVal { @@ -75,7 +75,7 @@ pub fn _gettimeofday(ctx: &mut EmEnv, tp: c_int, tz: c_int) -> c_int { 0 } -pub fn _clock_getres(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 { +pub fn _clock_getres(_ctx: &EmEnv, _clk_id: i32, _tp: i32) -> i32 { debug!("emscripten::_clock_getres"); // clock_getres(clk_id, tp) 0 @@ -83,7 +83,7 @@ pub fn _clock_getres(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 { /// emscripten: _clock_gettime #[allow(clippy::cast_ptr_alignment)] -pub fn _clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int { +pub fn _clock_gettime(ctx: &EmEnv, clk_id: clockid_t, tp: c_int) -> c_int { debug!("emscripten::_clock_gettime {} {}", clk_id, tp); // debug!("Memory {:?}", ctx.memory(0)[..]); #[repr(C)] @@ -115,41 +115,41 @@ pub fn _clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int { 0 } -pub fn _clock_settime(_ctx: &mut EmEnv, _clk_id: i32, _tp: i32) -> i32 { +pub fn _clock_settime(_ctx: &EmEnv, _clk_id: i32, _tp: i32) -> i32 { debug!("emscripten::_clock_settime"); // clock_settime(clk_id, tp) 0 } /// emscripten: ___clock_gettime -pub fn ___clock_gettime(ctx: &mut EmEnv, clk_id: clockid_t, tp: c_int) -> c_int { +pub fn ___clock_gettime(ctx: &EmEnv, clk_id: clockid_t, tp: c_int) -> c_int { debug!("emscripten::___clock_gettime {} {}", clk_id, tp); _clock_gettime(ctx, clk_id, tp) } /// emscripten: _clock -pub fn _clock(_ctx: &mut EmEnv) -> c_int { +pub fn _clock(_ctx: &EmEnv) -> c_int { debug!("emscripten::_clock"); 0 // TODO: unimplemented } /// emscripten: _difftime -pub fn _difftime(_ctx: &mut EmEnv, t0: u32, t1: u32) -> f64 { +pub fn _difftime(_ctx: &EmEnv, t0: u32, t1: u32) -> f64 { debug!("emscripten::_difftime"); (t0 - t1) as _ } -pub fn _gmtime_r(_ctx: &mut EmEnv, _one: i32, _two: i32) -> i32 { +pub fn _gmtime_r(_ctx: &EmEnv, _one: i32, _two: i32) -> i32 { debug!("emscripten::_gmtime_r"); -1 } -pub fn _mktime(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _mktime(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_mktime"); -1 } -pub fn _gmtime(_ctx: &mut EmEnv, _one: i32) -> i32 { +pub fn _gmtime(_ctx: &EmEnv, _one: i32) -> i32 { debug!("emscripten::_gmtime"); -1 } @@ -170,13 +170,13 @@ struct guest_tm { } /// emscripten: _tvset -pub fn _tvset(_ctx: &mut EmEnv) { +pub fn _tvset(_ctx: &EmEnv) { debug!("emscripten::_tvset UNIMPLEMENTED"); } /// formats time as a C string #[allow(clippy::cast_ptr_alignment)] -unsafe fn fmt_time(ctx: &mut EmEnv, time: u32) -> *const c_char { +unsafe fn fmt_time(ctx: &EmEnv, time: u32) -> *const c_char { let date = &*(emscripten_memory_pointer!(ctx.memory(0), time) as *mut guest_tm); let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; @@ -201,7 +201,7 @@ unsafe fn fmt_time(ctx: &mut EmEnv, time: u32) -> *const c_char { } /// emscripten: _asctime -pub fn _asctime(ctx: &mut EmEnv, time: u32) -> u32 { +pub fn _asctime(ctx: &EmEnv, time: u32) -> u32 { debug!("emscripten::_asctime {}", time); unsafe { @@ -215,7 +215,7 @@ pub fn _asctime(ctx: &mut EmEnv, time: u32) -> u32 { } /// emscripten: _asctime_r -pub fn _asctime_r(ctx: &mut EmEnv, time: u32, buf: u32) -> u32 { +pub fn _asctime_r(ctx: &EmEnv, time: u32, buf: u32) -> u32 { debug!("emscripten::_asctime_r {}, {}", time, buf); unsafe { @@ -234,7 +234,7 @@ pub fn _asctime_r(ctx: &mut EmEnv, time: u32, buf: u32) -> u32 { /// emscripten: _localtime #[allow(clippy::cast_ptr_alignment)] -pub fn _localtime(ctx: &mut EmEnv, time_p: u32) -> c_int { +pub fn _localtime(ctx: &EmEnv, time_p: u32) -> c_int { debug!("emscripten::_localtime {}", time_p); // NOTE: emscripten seems to want tzset() called in this function // https://stackoverflow.com/questions/19170721/real-time-awareness-of-timezone-change-in-localtime-vs-localtime-r @@ -272,7 +272,7 @@ pub fn _localtime(ctx: &mut EmEnv, time_p: u32) -> c_int { } /// emscripten: _localtime_r #[allow(clippy::cast_ptr_alignment)] -pub fn _localtime_r(ctx: &mut EmEnv, time_p: u32, result: u32) -> c_int { +pub fn _localtime_r(ctx: &EmEnv, time_p: u32, result: u32) -> c_int { debug!("emscripten::_localtime_r {}", time_p); // NOTE: emscripten seems to want tzset() called in this function @@ -309,7 +309,7 @@ pub fn _localtime_r(ctx: &mut EmEnv, time_p: u32, result: u32) -> c_int { /// emscripten: _time #[allow(clippy::cast_ptr_alignment)] -pub fn _time(ctx: &mut EmEnv, time_p: u32) -> i32 { +pub fn _time(ctx: &EmEnv, time_p: u32) -> i32 { debug!("emscripten::_time {}", time_p); unsafe { @@ -318,7 +318,7 @@ pub fn _time(ctx: &mut EmEnv, time_p: u32) -> i32 { } } -pub fn _ctime_r(ctx: &mut EmEnv, time_p: u32, buf: u32) -> u32 { +pub fn _ctime_r(ctx: &EmEnv, time_p: u32, buf: u32) -> u32 { debug!("emscripten::_ctime_r {} {}", time_p, buf); // var stack = stackSave(); @@ -329,7 +329,7 @@ pub fn _ctime_r(ctx: &mut EmEnv, time_p: u32, buf: u32) -> u32 { rv } -pub fn _ctime(ctx: &mut EmEnv, time_p: u32) -> u32 { +pub fn _ctime(ctx: &EmEnv, time_p: u32) -> u32 { debug!("emscripten::_ctime {}", time_p); let tm_current = 2414544; _ctime_r(ctx, time_p, tm_current) @@ -338,7 +338,7 @@ pub fn _ctime(ctx: &mut EmEnv, time_p: u32) -> u32 { /// emscripten: _timegm #[cfg(not(target_os = "windows"))] #[allow(clippy::cast_ptr_alignment)] -pub fn _timegm(ctx: &mut EmEnv, time_ptr: u32) -> i32 { +pub fn _timegm(ctx: &EmEnv, time_ptr: u32) -> i32 { debug!("emscripten::_timegm {}", time_ptr); unsafe { @@ -378,7 +378,7 @@ pub fn _timegm(ctx: &mut EmEnv, time_ptr: u32) -> i32 { } #[cfg(target_os = "windows")] -pub fn _timegm(_ctx: &mut EmEnv, _time_ptr: c_int) -> i32 { +pub fn _timegm(_ctx: &EmEnv, _time_ptr: c_int) -> i32 { debug!( "emscripten::_timegm - UNIMPLEMENTED IN WINDOWS {}", _time_ptr @@ -388,7 +388,7 @@ pub fn _timegm(_ctx: &mut EmEnv, _time_ptr: c_int) -> i32 { /// emscripten: _strftime pub fn _strftime( - ctx: &mut EmEnv, + ctx: &EmEnv, s_ptr: c_int, maxsize: u32, format_ptr: c_int, @@ -448,7 +448,7 @@ pub fn _strftime( /// emscripten: _strftime_l pub fn _strftime_l( - ctx: &mut EmEnv, + ctx: &EmEnv, s_ptr: c_int, maxsize: u32, format_ptr: c_int, diff --git a/lib/emscripten/src/ucontext.rs b/lib/emscripten/src/ucontext.rs index fcb11d25aa7..7fda8656ea0 100644 --- a/lib/emscripten/src/ucontext.rs +++ b/lib/emscripten/src/ucontext.rs @@ -1,20 +1,20 @@ use crate::EmEnv; -pub fn _getcontext(_ctx: &mut EmEnv, _ucp: i32) -> i32 { +pub fn _getcontext(_ctx: &EmEnv, _ucp: i32) -> i32 { debug!("emscripten::_getcontext({})", _ucp); 0 } -pub fn _makecontext(_ctx: &mut EmEnv, _ucp: i32, _func: i32, _argc: i32, _argv: i32) { +pub fn _makecontext(_ctx: &EmEnv, _ucp: i32, _func: i32, _argc: i32, _argv: i32) { debug!( "emscripten::_makecontext({}, {}, {}, {})", _ucp, _func, _argc, _argv ); } -pub fn _setcontext(_ctx: &mut EmEnv, _ucp: i32) -> i32 { +pub fn _setcontext(_ctx: &EmEnv, _ucp: i32) -> i32 { debug!("emscripten::_setcontext({})", _ucp); 0 } -pub fn _swapcontext(_ctx: &mut EmEnv, _oucp: i32, _ucp: i32) -> i32 { +pub fn _swapcontext(_ctx: &EmEnv, _oucp: i32, _ucp: i32) -> i32 { debug!("emscripten::_swapcontext({}, {})", _oucp, _ucp); 0 } diff --git a/lib/emscripten/src/unistd.rs b/lib/emscripten/src/unistd.rs index b0439fb1e99..ecb08a371f6 100644 --- a/lib/emscripten/src/unistd.rs +++ b/lib/emscripten/src/unistd.rs @@ -1,6 +1,6 @@ use crate::EmEnv; -pub fn confstr(_ctx: &mut EmEnv, _name: i32, _buf_pointer: i32, _len: i32) -> i32 { +pub fn confstr(_ctx: &EmEnv, _name: i32, _buf_pointer: i32, _len: i32) -> i32 { debug!("unistd::confstr({}, {}, {})", _name, _buf_pointer, _len); 0 } diff --git a/lib/emscripten/src/utils.rs b/lib/emscripten/src/utils.rs index c3d24f03940..a8d3efef795 100644 --- a/lib/emscripten/src/utils.rs +++ b/lib/emscripten/src/utils.rs @@ -93,7 +93,7 @@ pub fn get_emscripten_metadata(module: &Module) -> Result, St } } -pub unsafe fn write_to_buf(ctx: &mut EmEnv, string: *const c_char, buf: u32, max: u32) -> u32 { +pub unsafe fn write_to_buf(ctx: &EmEnv, string: *const c_char, buf: u32, max: u32) -> u32 { let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut c_char; for i in 0..max { @@ -104,7 +104,7 @@ pub unsafe fn write_to_buf(ctx: &mut EmEnv, string: *const c_char, buf: u32, max } /// This function expects nullbyte to be appended. -pub unsafe fn copy_cstr_into_wasm(ctx: &mut EmEnv, cstr: *const c_char) -> u32 { +pub unsafe fn copy_cstr_into_wasm(ctx: &EmEnv, cstr: *const c_char) -> u32 { let s = CStr::from_ptr(cstr).to_str().unwrap(); let cstr_len = s.len(); let space_offset = env::call_malloc(ctx, (cstr_len as u32) + 1); @@ -122,7 +122,7 @@ pub unsafe fn copy_cstr_into_wasm(ctx: &mut EmEnv, cstr: *const c_char) -> u32 { space_offset } -pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a mut EmEnv, count: u32) -> (u32, &'a mut [T]) { +pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a EmEnv, count: u32) -> (u32, &'a mut [T]) { let offset = get_emscripten_data(ctx) .stack_alloc .as_ref() @@ -136,7 +136,7 @@ pub unsafe fn allocate_on_stack<'a, T: Copy>(ctx: &'a mut EmEnv, count: u32) -> (offset, slice) } -pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut EmEnv, s: &str) -> (u32, &'a [u8]) { +pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a EmEnv, s: &str) -> (u32, &'a [u8]) { let (offset, slice) = allocate_on_stack(ctx, (s.len() + 1) as u32); use std::iter; @@ -148,7 +148,7 @@ pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut EmEnv, s: &str) -> (u32, & } #[cfg(not(target_os = "windows"))] -pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &mut EmEnv, cstrs: *mut *mut c_char) -> u32 { +pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &EmEnv, cstrs: *mut *mut c_char) -> u32 { let _total_num = { let mut ptr = cstrs; let mut counter = 0; @@ -186,7 +186,7 @@ pub struct GuestStat { } #[allow(clippy::cast_ptr_alignment)] -pub unsafe fn copy_stat_into_wasm(ctx: &mut EmEnv, buf: u32, stat: &stat) { +pub unsafe fn copy_stat_into_wasm(ctx: &EmEnv, buf: u32, stat: &stat) { let stat_ptr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut GuestStat; (*stat_ptr).st_dev = stat.st_dev as _; (*stat_ptr).__st_dev_padding = 0; @@ -225,7 +225,7 @@ pub fn read_string_from_wasm(memory: &Memory, offset: u32) -> String { /// This function trys to find an entry in mapdir /// translating paths into their correct value -pub fn get_cstr_path(ctx: &mut EmEnv, path: *const i8) -> Option { +pub fn get_cstr_path(ctx: &EmEnv, path: *const i8) -> Option { use std::collections::VecDeque; let path_str = @@ -261,7 +261,7 @@ pub fn get_cstr_path(ctx: &mut EmEnv, path: *const i8) -> Option Option { +pub fn get_current_directory(ctx: &EmEnv) -> Option { if let Some(val) = get_emscripten_data(ctx).mapped_dirs.get(".") { return Some(val.clone()); } diff --git a/lib/emscripten/src/varargs.rs b/lib/emscripten/src/varargs.rs index 09344fed226..4a9c886b046 100644 --- a/lib/emscripten/src/varargs.rs +++ b/lib/emscripten/src/varargs.rs @@ -11,14 +11,14 @@ pub struct VarArgs { } impl VarArgs { - pub fn get(&mut self, ctx: &mut EmEnv) -> T { + pub fn get(&mut self, ctx: &EmEnv) -> T { let ptr = emscripten_memory_pointer!(ctx.memory(0), self.pointer); self.pointer += mem::size_of::() as u32; unsafe { (ptr as *const T).read() } } // pub fn getStr<'a>(&mut self, ctx: &mut Ctx) -> &'a CStr { - pub fn get_str(&mut self, ctx: &mut EmEnv) -> *const c_char { + pub fn get_str(&mut self, ctx: &EmEnv) -> *const c_char { let ptr_addr: u32 = self.get(ctx); let ptr = emscripten_memory_pointer!(ctx.memory(0), ptr_addr) as *const c_char; ptr