rust: alloc: introduce the `BoxExt` trait
authorWedson Almeida Filho <walmeida@microsoft.com>
Thu, 28 Mar 2024 01:35:59 +0000 (22:35 -0300)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 16 Apr 2024 20:47:20 +0000 (22:47 +0200)
commit08d3f54928796557fc832467ad54f04908fc14e4
tree6b69b62459f71aaeac0021e2e81ff61ca9a1c991
parentb6a006e21b822d1dd262fa249ff71a2991e7b319
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>
rust/kernel/alloc.rs
rust/kernel/alloc/allocator.rs
rust/kernel/alloc/box_ext.rs [new file with mode: 0644]
rust/kernel/init.rs
rust/kernel/prelude.rs
rust/kernel/sync/arc.rs