mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
rust: make pin-init its own crate
Rename relative paths inside of the crate to still refer to the same
items, also rename paths inside of the kernel crate and adjust the build
system to build the crate.
[ Remove the `expect` (and thus the `lint_reasons` feature) since
the tree now uses `quote!` from `rust/macros/export.rs`. Remove the
`TokenStream` import removal, since it is now used as well.
In addition, temporarily (i.e. just for this commit) use an `--extern
force:alloc` to prevent an unknown `new_uninit` error in the `rustdoc`
target. For context, please see a similar case in:
https://lore.kernel.org/lkml/20240422090644.525520-1-ojeda@kernel.org/
And adjusted the message above. - Miguel ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://lore.kernel.org/r/20250308110339.2997091-16-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
committed by
Miguel Ojeda
parent
d7659acca7
commit
dbd5058ba6
@@ -19,8 +19,7 @@
|
||||
use crate::{
|
||||
alloc::{AllocError, Flags, KBox},
|
||||
bindings,
|
||||
init::{self, InPlaceWrite, Init, PinInit},
|
||||
init_ext::InPlaceInit,
|
||||
init::InPlaceInit,
|
||||
try_init,
|
||||
types::{ForeignOwnable, Opaque},
|
||||
};
|
||||
@@ -33,7 +32,7 @@
|
||||
pin::Pin,
|
||||
ptr::NonNull,
|
||||
};
|
||||
use macros::pin_data;
|
||||
use pin_init::{self, pin_data, InPlaceWrite, Init, PinInit};
|
||||
|
||||
mod std_vendor;
|
||||
|
||||
@@ -738,7 +737,7 @@ pub fn new_uninit(flags: Flags) -> Result<UniqueArc<MaybeUninit<T>>, AllocError>
|
||||
try_init!(ArcInner {
|
||||
// SAFETY: There are no safety requirements for this FFI call.
|
||||
refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }),
|
||||
data <- init::uninit::<T, AllocError>(),
|
||||
data <- pin_init::uninit::<T, AllocError>(),
|
||||
}? AllocError),
|
||||
flags,
|
||||
)?;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
use super::{lock::Backend, lock::Guard, LockClassKey};
|
||||
use crate::{
|
||||
ffi::{c_int, c_long},
|
||||
init::PinInit,
|
||||
pin_init,
|
||||
str::CStr,
|
||||
task::{MAX_SCHEDULE_TIMEOUT, TASK_INTERRUPTIBLE, TASK_NORMAL, TASK_UNINTERRUPTIBLE},
|
||||
time::Jiffies,
|
||||
@@ -17,7 +15,7 @@
|
||||
};
|
||||
use core::marker::PhantomPinned;
|
||||
use core::ptr;
|
||||
use macros::pin_data;
|
||||
use pin_init::{pin_data, pin_init, PinInit};
|
||||
|
||||
/// Creates a [`CondVar`] initialiser with the given name and a newly-created lock class.
|
||||
#[macro_export]
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
|
||||
use super::LockClassKey;
|
||||
use crate::{
|
||||
init::PinInit,
|
||||
pin_init,
|
||||
str::CStr,
|
||||
types::{NotThreadSafe, Opaque, ScopeGuard},
|
||||
};
|
||||
use core::{cell::UnsafeCell, marker::PhantomPinned};
|
||||
use macros::pin_data;
|
||||
use pin_init::{pin_data, pin_init, PinInit};
|
||||
|
||||
pub mod mutex;
|
||||
pub mod spinlock;
|
||||
|
||||
@@ -26,7 +26,7 @@ macro_rules! new_mutex {
|
||||
/// Since it may block, [`Mutex`] needs to be used with care in atomic contexts.
|
||||
///
|
||||
/// Instances of [`Mutex`] need a lock class and to be pinned. The recommended way to create such
|
||||
/// instances is with the [`pin_init`](crate::pin_init) and [`new_mutex`] macros.
|
||||
/// instances is with the [`pin_init`](pin_init::pin_init) and [`new_mutex`] macros.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
||||
@@ -24,7 +24,7 @@ macro_rules! new_spinlock {
|
||||
/// unlocked, at which point another CPU will be allowed to make progress.
|
||||
///
|
||||
/// Instances of [`SpinLock`] need a lock class and to be pinned. The recommended way to create such
|
||||
/// instances is with the [`pin_init`](crate::pin_init) and [`new_spinlock`] macros.
|
||||
/// instances is with the [`pin_init`](pin_init::pin_init) and [`new_spinlock`] macros.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user