summary refs log tree commit diff stats
path: root/rust/qemu-api/src/zeroable.rs
diff options
context:
space:
mode:
authorZhao Liu <zhao1.liu@intel.com>2025-02-10 11:00:48 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2025-02-13 12:51:34 +0100
commit0534248a6b515cb4dea29a6fd6c256dc77f2a953 (patch)
tree58220c8a0536afd3d2370da287a9f55356b087c0 /rust/qemu-api/src/zeroable.rs
parenteadb83f9a3722045e291b6a73994004007dc4657 (diff)
downloadfocaccia-qemu-0534248a6b515cb4dea29a6fd6c256dc77f2a953.tar.gz
focaccia-qemu-0534248a6b515cb4dea29a6fd6c256dc77f2a953.zip
rust/timer/hpet: define hpet_fw_cfg
Define HPETFwEntry structure with the same memory layout as
hpet_fw_entry in C.

Further, define the global hpet_cfg variable in Rust which is the
same as the C version. This hpet_cfg variable in Rust will replace
the C version one and allows both Rust code and C code to access it.

The Rust version of hpet_cfg is self-contained, avoiding unsafe
access to C code.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250210030051.2562726-8-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api/src/zeroable.rs')
-rw-r--r--rust/qemu-api/src/zeroable.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/rust/qemu-api/src/zeroable.rs b/rust/qemu-api/src/zeroable.rs
index 9f009606b1..cd424e6ea0 100644
--- a/rust/qemu-api/src/zeroable.rs
+++ b/rust/qemu-api/src/zeroable.rs
@@ -56,6 +56,7 @@ pub unsafe trait Zeroable: Default {
 /// ## Differences with `core::mem::zeroed`
 ///
 /// `const_zero` zeroes padding bits, while `core::mem::zeroed` doesn't
+#[macro_export]
 macro_rules! const_zero {
     // This macro to produce a type-generic zero constant is taken from the
     // const_zero crate (v0.1.1):
@@ -77,10 +78,11 @@ macro_rules! const_zero {
 }
 
 /// A wrapper to implement the `Zeroable` trait through the `const_zero` macro.
+#[macro_export]
 macro_rules! impl_zeroable {
     ($type:ty) => {
-        unsafe impl Zeroable for $type {
-            const ZERO: Self = unsafe { const_zero!($type) };
+        unsafe impl $crate::zeroable::Zeroable for $type {
+            const ZERO: Self = unsafe { $crate::const_zero!($type) };
         }
     };
 }