From 227f7fd4873b17680957c75604cf4a5a674f5792 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sun, 8 Sep 2024 20:46:07 +0200 Subject: [PATCH] Convert repr(packed) to repr(C, packed). This is required by crates like bytemuck. --- src/arch/aarch64.rs | 4 ++-- src/arch/riscv64.rs | 2 +- src/arch/x86.rs | 4 ++-- src/arch/x86_64.rs | 4 ++-- src/io/mmio.rs | 7 +------ 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/arch/aarch64.rs b/src/arch/aarch64.rs index 9a2de5b48d..8045d60d1b 100644 --- a/src/arch/aarch64.rs +++ b/src/arch/aarch64.rs @@ -111,7 +111,7 @@ impl DerefMut for IntRegisters { } #[derive(Clone, Copy, Debug, Default)] -#[repr(packed)] +#[repr(C, packed)] pub struct FloatRegisters { pub fp_simd_regs: [u128; 32], pub fpsr: u32, @@ -142,7 +142,7 @@ impl DerefMut for FloatRegisters { } #[derive(Clone, Copy, Debug, Default)] -#[repr(packed)] +#[repr(C, packed)] pub struct EnvRegisters { pub tpidr_el0: usize, pub tpidrro_el0: usize, diff --git a/src/arch/riscv64.rs b/src/arch/riscv64.rs index 199f91c9bf..7885d2c3b6 100644 --- a/src/arch/riscv64.rs +++ b/src/arch/riscv64.rs @@ -79,7 +79,7 @@ impl DerefMut for IntRegisters { } #[derive(Clone, Copy, Debug, Default)] -#[repr(packed)] +#[repr(C, packed)] pub struct FloatRegisters { //TODO } diff --git a/src/arch/x86.rs b/src/arch/x86.rs index d43021511d..a1cf93fa8d 100644 --- a/src/arch/x86.rs +++ b/src/arch/x86.rs @@ -139,7 +139,7 @@ impl DerefMut for IntRegisters { } #[derive(Clone, Copy, Debug, Default)] -#[repr(packed)] +#[repr(C, packed)] pub struct FloatRegisters { pub fcw: u16, pub fsw: u16, @@ -179,7 +179,7 @@ impl DerefMut for FloatRegisters { } #[derive(Clone, Copy, Debug, Default)] -#[repr(packed)] +#[repr(C, packed)] pub struct EnvRegisters { pub fsbase: u32, pub gsbase: u32, diff --git a/src/arch/x86_64.rs b/src/arch/x86_64.rs index 6aaca56066..360715c5be 100644 --- a/src/arch/x86_64.rs +++ b/src/arch/x86_64.rs @@ -90,7 +90,7 @@ impl DerefMut for IntRegisters { } #[derive(Clone, Copy, Debug, Default)] -#[repr(packed)] +#[repr(C, packed)] pub struct FloatRegisters { pub fcw: u16, pub fsw: u16, @@ -129,7 +129,7 @@ impl DerefMut for FloatRegisters { } } #[derive(Clone, Copy, Debug, Default)] -#[repr(packed)] +#[repr(C, packed)] pub struct EnvRegisters { pub fsbase: u64, pub gsbase: u64, diff --git a/src/io/mmio.rs b/src/io/mmio.rs index 1af643fa13..1a846f2122 100644 --- a/src/io/mmio.rs +++ b/src/io/mmio.rs @@ -4,17 +4,12 @@ use core::{mem::MaybeUninit, ptr}; use super::io::Io; -#[repr(packed)] +#[repr(transparent)] pub struct Mmio { value: MaybeUninit, } impl Mmio { - /// Create a new Mmio without initializing - #[deprecated = "unsound because it's possible to read even though it's uninitialized"] - pub fn new() -> Self { - unsafe { Self::uninit() } - } pub unsafe fn zeroed() -> Self { Self { value: MaybeUninit::zeroed(),