2022-02-11 19:25:34 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
//! The `kernel` prelude.
|
|
|
|
//!
|
|
|
|
//! These are the most common items used by Rust code in the kernel,
|
|
|
|
//! intended to be imported by all Rust code, for convenience.
|
|
|
|
//!
|
|
|
|
//! # Examples
|
|
|
|
//!
|
|
|
|
//! ```
|
|
|
|
//! use kernel::prelude::*;
|
|
|
|
//! ```
|
|
|
|
|
2022-12-14 09:34:51 +00:00
|
|
|
#[doc(no_inline)]
|
2022-02-11 19:25:34 +00:00
|
|
|
pub use core::pin::Pin;
|
2022-11-10 16:41:13 +00:00
|
|
|
|
rust: alloc: implement kernel `Vec` type
`Vec` provides a contiguous growable array type with contents allocated
with the kernel's allocators (e.g. `Kmalloc`, `Vmalloc` or `KVmalloc`).
In contrast to Rust's stdlib `Vec` type, the kernel `Vec` type considers
the kernel's GFP flags for all appropriate functions, always reports
allocation failures through `Result<_, AllocError>` and remains
independent from unstable features.
[ This patch starts using a new unstable feature, `inline_const`, but
it was stabilized in Rust 1.79.0, i.e. the next version after the
minimum one, thus it will not be an issue. - Miguel ]
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20241004154149.93856-17-dakr@kernel.org
[ Cleaned `rustdoc` unescaped backtick warning, added a couple more
backticks elsewhere, fixed typos, sorted `feature`s, rewrapped
documentation lines. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-10-04 15:41:20 +00:00
|
|
|
pub use crate::alloc::{flags::*, vec_ext::VecExt, Box, KBox, KVBox, KVVec, KVec, VBox, VVec};
|
2024-03-28 01:35:55 +00:00
|
|
|
|
2022-12-14 09:34:51 +00:00
|
|
|
#[doc(no_inline)]
|
2024-10-04 15:41:17 +00:00
|
|
|
pub use alloc::vec::Vec;
|
2022-11-10 16:41:13 +00:00
|
|
|
|
2022-12-14 09:34:51 +00:00
|
|
|
#[doc(no_inline)]
|
2023-08-14 08:46:41 +00:00
|
|
|
pub use macros::{module, pin_data, pinned_drop, vtable, Zeroable};
|
2022-11-10 16:41:13 +00:00
|
|
|
|
2022-11-10 16:41:38 +00:00
|
|
|
pub use super::build_assert;
|
|
|
|
|
2022-12-14 09:34:51 +00:00
|
|
|
// `super::std_vendor` is hidden, which makes the macro inline for some reason.
|
|
|
|
#[doc(no_inline)]
|
|
|
|
pub use super::dbg;
|
|
|
|
pub use super::{pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr_notice, pr_warn};
|
2022-11-10 16:41:13 +00:00
|
|
|
|
2023-04-08 12:26:17 +00:00
|
|
|
pub use super::{init, pin_init, try_init, try_pin_init};
|
|
|
|
|
2022-11-10 16:41:36 +00:00
|
|
|
pub use super::static_assert;
|
|
|
|
|
2022-11-10 16:41:23 +00:00
|
|
|
pub use super::error::{code::*, Error, Result};
|
2022-11-10 16:41:13 +00:00
|
|
|
|
2022-11-10 16:41:28 +00:00
|
|
|
pub use super::{str::CStr, ThisModule};
|
2023-04-08 12:26:17 +00:00
|
|
|
|
2024-08-19 11:24:39 +00:00
|
|
|
pub use super::init::{InPlaceInit, InPlaceWrite, Init, PinInit};
|
2023-04-11 05:45:40 +00:00
|
|
|
|
|
|
|
pub use super::current;
|