diff options
author | Miguel Ojeda <ojeda@kernel.org> | 2021-07-03 17:02:21 +0200 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2022-09-28 08:57:01 +0200 |
commit | 057b8d2571071da05d06810ca70f26c6316f6ea7 (patch) | |
tree | 646cd717212e215a82d5ad1bb8c574962f4f8d9b /rust/alloc/lib.rs | |
parent | 753dece88d70a23b015e01674a662e683235c08f (diff) | |
download | lwn-057b8d2571071da05d06810ca70f26c6316f6ea7.tar.gz lwn-057b8d2571071da05d06810ca70f26c6316f6ea7.zip |
rust: adapt `alloc` crate to the kernel
This customizes the subset of the Rust standard library `alloc` that
was just imported as-is, mainly by:
- Adding SPDX license identifiers.
- Skipping modules (e.g. `rc` and `sync`) via new `cfg`s.
- Adding fallible (`try_*`) versions of existing infallible methods
(i.e. returning a `Result` instead of panicking).
Since the standard library requires stable/unstable attributes,
these additions are annotated with:
#[stable(feature = "kernel", since = "1.0.0")]
Using "kernel" as the feature allows to have the additions
clearly marked. The "1.0.0" version is just a placeholder.
(At the moment, only one is needed, but in the future more
fallible methods will be added).
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
Co-developed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Gary Guo <gary@garyguo.net>
Co-developed-by: Matthew Bakhtiari <dev@mtbk.me>
Signed-off-by: Matthew Bakhtiari <dev@mtbk.me>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/alloc/lib.rs')
-rw-r--r-- | rust/alloc/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rust/alloc/lib.rs b/rust/alloc/lib.rs index fd21b3671182..233bcd5e4654 100644 --- a/rust/alloc/lib.rs +++ b/rust/alloc/lib.rs @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT + //! # The Rust core allocation and collections library //! //! This library provides smart pointers and collections for managing @@ -192,6 +194,7 @@ extern crate std; extern crate test; // Module with internal macros used by other modules (needs to be included before other modules). +#[cfg(not(no_macros))] #[macro_use] mod macros; @@ -216,11 +219,16 @@ pub mod borrow; pub mod collections; #[cfg(not(no_global_oom_handling))] pub mod ffi; +#[cfg(not(no_fmt))] pub mod fmt; +#[cfg(not(no_rc))] pub mod rc; pub mod slice; +#[cfg(not(no_str))] pub mod str; +#[cfg(not(no_string))] pub mod string; +#[cfg(not(no_sync))] #[cfg(target_has_atomic = "ptr")] pub mod sync; #[cfg(all(not(no_global_oom_handling), target_has_atomic = "ptr"))] |