[−][src]Module data_model::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:
- No references or slices to volatile memory (
&
or&mut
). - 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
VolatileRef | A memory location that supports volatile access of a |
VolatileSlice | A slice of raw memory that supports volatile access. |
Enums
VolatileMemoryError |
Traits
VolatileMemory | Trait for types that support raw volatile access to their data. |
Functions
calc_offset | Convenience function for computing |
Type Definitions
VolatileMemoryResult |