Wedson Almeida Filho
2c1092853f
rust: kernel: remove usage of allocator_api unstable feature
...
With the adoption of `BoxExt` and `VecExt`, we don't need the functions
provided by this feature (namely the methods prefixed with `try_` and
different allocator per collection instance).
We do need `AllocError`, but we define our own as it is a trivial empty
struct.
Reviewed-by: Benno Lossin <benno.lossin@proton.me >
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com >
Link: https://lore.kernel.org/r/20240328013603.206764-11-wedsonaf@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org >
2024-04-16 22:50:04 +02:00
Wedson Almeida Filho
5ab560ce12
rust: alloc: update VecExt to take allocation flags
...
We also rename the methods by removing the `try_` prefix since the names
are available due to our usage of the `no_global_oom_handling` config
when building the `alloc` crate.
Reviewed-by: Boqun Feng <boqun.feng@gmail.com >
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com >
Reviewed-by: Benno Lossin <benno.lossin@proton.me >
Link: https://lore.kernel.org/r/20240328013603.206764-8-wedsonaf@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org >
2024-04-16 22:50:04 +02:00
Wedson Almeida Filho
08d3f54928
rust: alloc: introduce the BoxExt trait
...
Make fallible versions of `new` and `new_uninit` methods available in
`Box` even though it doesn't implement them because we build `alloc`
with the `no_global_oom_handling` config.
They also have an extra `flags` parameter that allows callers to pass
flags to the allocator.
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com >
Reviewed-by: Boqun Feng <boqun.feng@gmail.com >
Reviewed-by: Benno Lossin <benno.lossin@proton.me >
Link: https://lore.kernel.org/r/20240328013603.206764-7-wedsonaf@gmail.com
[ Used `Box::write()` to avoid one `unsafe` block as suggested by Boqun. ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org >
2024-04-16 22:47:20 +02:00
Wedson Almeida Filho
b6a006e21b
rust: alloc: introduce allocation flags
...
We'll use them when allocating `Box`, `Arc`, and `UniqueArc` instances,
as well as when allocating memory for `Vec` elements. These changes will
come in subsequent patches.
Reviewed-by: Benno Lossin <benno.lossin@proton.me >
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com >
Link: https://lore.kernel.org/r/20240328013603.206764-6-wedsonaf@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org >
2024-04-16 22:05:06 +02:00
Wedson Almeida Filho
03989773a9
rust: alloc: introduce the VecExt trait
...
Make `try_with_capacity`, `try_push`, and `try_extend_from_slice`
methods available in `Vec` even though it doesn't implement them. It is
implemented with `try_reserve` and `push_within_capacity`.
This is in preparation for switching to the upstream `alloc` crate.
Reviewed-by: Benno Lossin <benno.lossin@proton.me >
Suggested-by: Gary Guo <gary@garyguo.net >
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com >
Link: https://lore.kernel.org/r/20240328013603.206764-3-wedsonaf@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org >
2024-04-16 22:03:14 +02:00
Wedson Almeida Filho
31d94d8f58
rust: kernel: move allocator module under alloc
...
We will add more to the `alloc` module in subsequent patches (e.g.,
allocation flags and extension traits).
Reviewed-by: Benno Lossin <benno.lossin@proton.me >
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com >
Link: https://lore.kernel.org/r/20240328013603.206764-2-wedsonaf@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org >
2024-04-16 22:03:14 +02:00