mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-21 04:53:46 -04:00
rust: pin-init: move impl Zeroable for Opaque and Option<KBox<T>> into the kernel crate
In order to make pin-init a standalone crate, move kernel-specific code directly into the kernel crate. Since `Opaque<T>` and `KBox<T>` are part of the kernel, move their `Zeroable` implementation into the kernel crate. Signed-off-by: Benno Lossin <benno.lossin@proton.me> Tested-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Fiona Behrens <me@kloenk.dev> Link: https://lore.kernel.org/r/20250308110339.2997091-10-benno.lossin@proton.me Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
committed by
Miguel Ojeda
parent
114ca41fe7
commit
9d29c682f0
@@ -2,7 +2,7 @@
|
||||
|
||||
//! Kernel types.
|
||||
|
||||
use crate::init::{self, PinInit};
|
||||
use crate::init::{self, PinInit, Zeroable};
|
||||
use core::{
|
||||
cell::UnsafeCell,
|
||||
marker::{PhantomData, PhantomPinned},
|
||||
@@ -309,6 +309,9 @@ pub struct Opaque<T> {
|
||||
_pin: PhantomPinned,
|
||||
}
|
||||
|
||||
// SAFETY: `Opaque<T>` allows the inner value to be any bit pattern, including all zeros.
|
||||
unsafe impl<T> Zeroable for Opaque<T> {}
|
||||
|
||||
impl<T> Opaque<T> {
|
||||
/// Creates a new opaque value.
|
||||
pub const fn new(value: T) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user