wasmer/entities/memory/
location.rs

1use crate::error::AtomicsError;
2
3/// Location in a WebAssembly memory.
4#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
5pub struct MemoryLocation {
6    // NOTE: must be expanded to an enum that also supports 64bit memory in
7    // the future
8    // That's why this is private.
9    pub(crate) address: u32,
10}
11
12impl MemoryLocation {
13    /// Create a new memory location for a 32bit memory.
14    pub fn new_32(address: u32) -> Self {
15        Self { address }
16    }
17}
18
19impl From<u32> for MemoryLocation {
20    fn from(value: u32) -> Self {
21        Self::new_32(value)
22    }
23}
24
25/// See [`crate::SharedMemory`].
26pub(crate) trait SharedMemoryOps {
27    /// See [`crate::SharedMemory::disable_atomics`].
28    fn disable_atomics(&self) -> Result<(), AtomicsError> {
29        Err(AtomicsError::Unimplemented)
30    }
31
32    /// See [`crate::SharedMemory::wake_all_atomic_waiters`].
33    fn wake_all_atomic_waiters(&self) -> Result<(), AtomicsError> {
34        Err(AtomicsError::Unimplemented)
35    }
36
37    /// See [`crate::SharedMemory::notify`].
38    fn notify(&self, _dst: MemoryLocation, _count: u32) -> Result<u32, AtomicsError> {
39        Err(AtomicsError::Unimplemented)
40    }
41
42    /// See [`crate::SharedMemory::wait`].
43    fn wait(
44        &self,
45        _dst: MemoryLocation,
46        _timeout: Option<std::time::Duration>,
47    ) -> Result<u32, AtomicsError> {
48        Err(AtomicsError::Unimplemented)
49    }
50}