Function read_volatile
pub unsafe fn read_volatile<T, O>(src: BitPtr<Const, T, O>) -> boolExpand description
§Single-Bit Volatile Read
This reads the bit out of src directly, using a volatile I/O intrinsic to
prevent compiler reördering or removal.
You should not use bitvec to perform any volatile I/O operations. You should
instead do volatile I/O work on integer values directly, or use a crate like
voladdress to perform I/O transactions, and use bitvec only on stack
locals that have no additional memory semantics.
§Original
§Safety
Because this performs a dereference of memory, it inherits the original
ptr::read_volatile’s requirements:
srcmust be valid to read.srcmust be properly aligned. This is an invariant of theBitPtrtype as well as of the memory access.srcmust point to an initialized value ofT.
Remember that volatile accesses are ordinary loads that the compiler cannot remove or reörder! They are not an atomic synchronizer.
§Examples
use bitvec::prelude::*;
use bitvec::ptr as bv_ptr;
let data = 128u8;
let ptr = BitPtr::<_, _, Msb0>::from_ref(&data);
assert!(unsafe { bv_ptr::read_volatile(ptr) });