Skip to content
Snippets Groups Projects

mmio: Replace repr packed with transparent

Closed Tim Crawford requested to merge tcrawford/hwio:repr into master
1 file
+ 3
5
Compare changes
  • Side-by-side
  • Inline
+ 3
5
@@ -6,7 +6,7 @@ use core::ptr;
use super::io::Io;
#[repr(packed)]
#[repr(transparent)]
pub struct Mmio<T> {
value: T,
}
@@ -27,12 +27,10 @@ impl<T> Io for Mmio<T> where T: Copy + PartialEq + BitAnd<Output = T> + BitOr<Ou
type Value = T;
fn read(&self) -> T {
let raw = ptr::addr_of!(self.value);
unsafe { raw.read_volatile() }
unsafe { ptr::read_volatile(&self.value) }
}
fn write(&mut self, value: T) {
let raw = ptr::addr_of_mut!(self.value);
unsafe { raw.write_volatile(value) };
unsafe { ptr::write_volatile(&mut self.value, value) };
}
}
Loading