summaryrefslogtreecommitdiffstats
path: root/rust/kernel/alloc.rs
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2024-10-04 17:41:20 +0200
committerMiguel Ojeda <ojeda@kernel.org>2024-10-15 23:10:32 +0200
commit2aac4cd7dae3d7bb0e0ddec2561b2ee4cbe6c8f6 (patch)
treeef2c672bf53b999be23b3500fed3298737e100f9 /rust/kernel/alloc.rs
parent9e7bbfa182767f638ba61dba3518ff78da9f31ff (diff)
downloadlinux-2aac4cd7dae3d7bb0e0ddec2561b2ee4cbe6c8f6.tar.gz
linux-2aac4cd7dae3d7bb0e0ddec2561b2ee4cbe6c8f6.tar.bz2
linux-2aac4cd7dae3d7bb0e0ddec2561b2ee4cbe6c8f6.zip
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>
Diffstat (limited to 'rust/kernel/alloc.rs')
-rw-r--r--rust/kernel/alloc.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs
index c679d93b0523..7f654b214ec2 100644
--- a/rust/kernel/alloc.rs
+++ b/rust/kernel/alloc.rs
@@ -5,6 +5,7 @@
#[cfg(not(any(test, testlib)))]
pub mod allocator;
pub mod kbox;
+pub mod kvec;
pub mod layout;
pub mod vec_ext;
@@ -19,6 +20,11 @@ pub use self::kbox::KBox;
pub use self::kbox::KVBox;
pub use self::kbox::VBox;
+pub use self::kvec::KVVec;
+pub use self::kvec::KVec;
+pub use self::kvec::VVec;
+pub use self::kvec::Vec;
+
/// Indicates an allocation error.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct AllocError;