Skip to content

Commit a0d13aa

Browse files
wedsonafojeda
authored andcommitted
rust: rbtree: add red-black tree implementation backed by the C version
The rust rbtree exposes a map-like interface over keys and values, backed by the kernel red-black tree implementation. Values can be inserted, deleted, and retrieved from a `RBTree` by key. This base abstraction is used by binder to store key/value pairs and perform lookups, for example the patch "[PATCH RFC 03/20] rust_binder: add threading support" in the binder RFC [1]. Link: https://lore.kernel.org/rust-for-linux/[email protected]/ [1] Signed-off-by: Wedson Almeida Filho <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Tested-by: Alice Ryhl <[email protected]> Reviewed-by: Boqun Feng <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Signed-off-by: Matt Gilbride <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Updated link to docs.kernel.org. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 6e6efc5 commit a0d13aa

File tree

4 files changed

+443
-0
lines changed

4 files changed

+443
-0
lines changed

rust/helpers/helpers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "kunit.c"
1616
#include "mutex.c"
1717
#include "page.c"
18+
#include "rbtree.c"
1819
#include "refcount.c"
1920
#include "signal.c"
2021
#include "slab.c"

rust/helpers/rbtree.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/rbtree.h>
4+
5+
void rust_helper_rb_link_node(struct rb_node *node, struct rb_node *parent,
6+
struct rb_node **rb_link)
7+
{
8+
rb_link_node(node, parent, rb_link);
9+
}

rust/kernel/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub mod net;
4444
pub mod page;
4545
pub mod prelude;
4646
pub mod print;
47+
pub mod rbtree;
4748
mod static_assert;
4849
#[doc(hidden)]
4950
pub mod std_vendor;

0 commit comments

Comments
 (0)