[][src]Module vm_memory::volatile_memory

Types for volatile access to memory.

Two of the core rules for safe rust is no data races and no aliased mutable references. VolatileRef and VolatileSlice, along with types that produce those which implement VolatileMemory, allow us to sidestep that rule by wrapping pointers that absolutely have to be accessed volatile. Some systems really do need to operate on shared memory and can't have the compiler reordering or eliding access because it has no visibility into what other systems are doing with that hunk of memory.

For the purposes of maintaining safety, volatile memory has some rules of its own:

  1. No references or slices to volatile memory (& or &mut).
  2. Access should always been done with a volatile read or write. The First rule is because having references of any kind to memory considered volatile would violate pointer aliasing. The second is because unvolatile accesses are inherently undefined if done concurrently without synchronization. With volatile access we know that the compiler has not reordered or elided the access.

Structs

VolatileArrayRef

A memory location that supports volatile access to an array of elements of type T.

VolatileRef

A memory location that supports volatile access to an instance of T.

VolatileSlice

A slice of raw memory that supports volatile access.

Enums

Error

VolatileMemory related errors.

Traits

AtomicValued

Types that can be read safely from a VolatileSlice.

VolatileMemory

Types that support raw volatile access to their data.

Functions

compute_offset

Convenience function for computing base + offset.

Type Definitions

Result

Result of volatile memory operations.