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>
Showing
- rust/kernel/alloc.rs 1 addition, 0 deletionsrust/kernel/alloc.rs
- rust/kernel/alloc/allocator.rs 1 addition, 1 deletionrust/kernel/alloc/allocator.rs
- rust/kernel/alloc/box_ext.rs 58 additions, 0 deletionsrust/kernel/alloc/box_ext.rs
- rust/kernel/init.rs 7 additions, 6 deletionsrust/kernel/init.rs
- rust/kernel/prelude.rs 1 addition, 1 deletionrust/kernel/prelude.rs
- rust/kernel/sync/arc.rs 2 additions, 1 deletionrust/kernel/sync/arc.rs
Loading
Please register or sign in to comment