forked from AbleOS/ableos
Fixed smaller units
This commit is contained in:
parent
d6243fa99f
commit
57f30109c8
|
@ -45,6 +45,8 @@ impl Value {
|
|||
/// # Safety
|
||||
/// - N/A, not to be implemented manually
|
||||
pub unsafe trait ValueVariant: private::Sealed + Copy + Into<Value> {}
|
||||
impl private::Sealed for Value {}
|
||||
unsafe impl ValueVariant for Value {}
|
||||
|
||||
mod private {
|
||||
pub trait Sealed {}
|
||||
|
|
|
@ -543,9 +543,15 @@ where
|
|||
/// Write a register.
|
||||
/// Writing to register 0 is no-op.
|
||||
#[inline(always)]
|
||||
fn write_reg(&mut self, n: u8, value: impl Into<Value>) {
|
||||
fn write_reg<T: ValueVariant>(&mut self, n: u8, value: T) {
|
||||
if n != 0 {
|
||||
unsafe { *self.registers.get_unchecked_mut(n as usize) = value.into() };
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
(&value as *const T).cast::<u8>(),
|
||||
self.registers.as_mut_ptr().add(n.into()).cast::<u8>(),
|
||||
core::mem::size_of::<T>(),
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue