Module base::volatile_memory
source · Expand description
Types for volatile access to memory.
Two of the core rules for safe rust is no data races and no aliased mutable references.
VolatileSlice
, along with types that produce it 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§
- A slice of raw memory that supports volatile access. Like
std::io::IoSliceMut
, this type is guaranteed to be ABI-compatible withlibc::iovec
but unlikeIoSliceMut
, it doesn’t automatically deref to&mut [u8]
.
Enums§
Traits§
- Trait for types that support raw volatile access to their data.
Functions§
- Check whether every byte is zero.
Type Aliases§
- Result 🔒