]> xenbits.xensource.com Git - people/aperard/qemu-dm.git/commitdiff
rust/qdev: add the macro to define bit property
authorZhao Liu <zhao1.liu@intel.com>
Mon, 10 Feb 2025 03:00:43 +0000 (11:00 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 13 Feb 2025 11:51:34 +0000 (12:51 +0100)
HPET device (Rust device) needs to define the bit type property.

Add a variant of define_property macro to define bit type property.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250210030051.2562726-3-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/qemu-api/src/qdev.rs

index 73343e10b9641f95046591c9fde6b22acc63f873..c44a22876b9d7517ffb1b5654f9e7ddbe2f98641 100644 (file)
@@ -168,6 +168,18 @@ where
 
 #[macro_export]
 macro_rules! define_property {
+    ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, bit = $bitnr:expr, default = $defval:expr$(,)*) => {
+        $crate::bindings::Property {
+            // use associated function syntax for type checking
+            name: ::std::ffi::CStr::as_ptr($name),
+            info: $prop,
+            offset: $crate::offset_of!($state, $field) as isize,
+            bitnr: $bitnr,
+            set_default: true,
+            defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval as u64 },
+            ..$crate::zeroable::Zeroable::ZERO
+        }
+    };
     ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, default = $defval:expr$(,)*) => {
         $crate::bindings::Property {
             // use associated function syntax for type checking