cell::{bql_locked, Opaque},
chardev::Chardev,
error::{Error, Result},
+ impl_vmstate_c_struct,
irq::InterruptSource,
prelude::*,
qom::{ObjectClass, ObjectImpl, Owned, ParentInit},
unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_CLOCK) };
}
qom_isa!(Clock: Object);
+
+impl_vmstate_c_struct!(Clock, bindings::vmstate_clock);
callbacks::FnCall,
errno::{into_neg_errno, Errno},
prelude::*,
- qdev,
qom::Owned,
zeroable::Zeroable,
};
impl_vmstate_scalar!(vmstate_info_uint64, u64);
impl_vmstate_scalar!(vmstate_info_timer, crate::timer::Timer);
+#[macro_export]
macro_rules! impl_vmstate_c_struct {
($type:ty, $vmsd:expr) => {
unsafe impl VMState for $type {
- const BASE: VMStateField = $crate::bindings::VMStateField {
- vmsd: addr_of!($vmsd),
- size: mem::size_of::<$type>(),
- flags: VMStateFlags::VMS_STRUCT,
- ..Zeroable::ZERO
+ const BASE: $crate::bindings::VMStateField = $crate::bindings::VMStateField {
+ vmsd: ::std::ptr::addr_of!($vmsd),
+ size: ::std::mem::size_of::<$type>(),
+ flags: $crate::bindings::VMStateFlags::VMS_STRUCT,
+ ..$crate::zeroable::Zeroable::ZERO
};
}
};
}
-impl_vmstate_c_struct!(qdev::Clock, bindings::vmstate_clock);
-
// Pointer types using the underlying type's VMState plus VMS_POINTER
// Note that references are not supported, though references to cells
// could be allowed.