[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 08/13] rust/qdev: add the macro to define bit property
From: |
Zhao Liu |
Subject: |
[RFC 08/13] rust/qdev: add the macro to define bit property |
Date: |
Thu, 5 Dec 2024 14:07:09 +0800 |
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>
---
rust/qemu-api/src/qdev.rs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/rust/qemu-api/src/qdev.rs b/rust/qemu-api/src/qdev.rs
index 5e6580b6f261..66810803ec9d 100644
--- a/rust/qemu-api/src/qdev.rs
+++ b/rust/qemu-api/src/qdev.rs
@@ -103,6 +103,18 @@ fn class_init(dc: &mut DeviceClass) {
#[macro_export]
macro_rules! define_property {
+ ($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr, 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:expr, default =
$defval:expr$(,)*) => {
$crate::bindings::Property {
// use associated function syntax for type checking
--
2.34.1
[RFC 07/13] rust: add bindings for timer, Zhao Liu, 2024/12/05
[RFC 08/13] rust/qdev: add the macro to define bit property,
Zhao Liu <=
[RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Zhao Liu, 2024/12/05
- Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Philippe Mathieu-Daudé, 2024/12/05
- Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Zhao Liu, 2024/12/05
- Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Philippe Mathieu-Daudé, 2024/12/05
- Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Paolo Bonzini, 2024/12/05
- Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Philippe Mathieu-Daudé, 2024/12/07
- Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Zhao Liu, 2024/12/07
Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c, Paolo Bonzini, 2024/12/05
[RFC 10/13] rust/timer/hpet: define hpet_fw_cfg, Zhao Liu, 2024/12/05