rust/irq: Add a helper to convert [InterruptSource] to pointer
This is useful when taking an InterruptSource slice and passing it to C function. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-4-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
7f2d4181a3
commit
e6f1195f55
@ -83,6 +83,12 @@ where
|
|||||||
pub(crate) const fn as_ptr(&self) -> *mut *mut IRQState {
|
pub(crate) const fn as_ptr(&self) -> *mut *mut IRQState {
|
||||||
self.cell.as_ptr()
|
self.cell.as_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) const fn slice_as_ptr(slice: &[Self]) -> *mut *mut IRQState {
|
||||||
|
assert!(!slice.is_empty());
|
||||||
|
slice[0].as_ptr()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for InterruptSource {
|
impl Default for InterruptSource {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user