diff options
| author | Alice Ryhl <[email protected]> | 2024-08-14 08:05:23 +0000 |
|---|---|---|
| committer | Miguel Ojeda <[email protected]> | 2024-08-23 04:26:57 +0000 |
| commit | 14176295fe56ce9506e650dce436d2bdadec93b5 (patch) | |
| tree | 0c09eb089153da4e421784e44087ff7179988181 /rust/helpers | |
| parent | rust: list: add tracking for ListArc (diff) | |
| download | kernel-14176295fe56ce9506e650dce436d2bdadec93b5.tar.gz kernel-14176295fe56ce9506e650dce436d2bdadec93b5.zip | |
rust: list: add struct with prev/next pointers
Define the ListLinks struct, which wraps the prev/next pointers that
will be used to insert values into a List in a future patch. Also
define the ListItem trait, which is implemented by structs that have a
ListLinks field.
The ListItem trait provides four different methods that are all
essentially container_of or the reverse of container_of. Two of them are
used before inserting/after removing an item from the list, and the two
others are used when looking at a value without changing whether it is
in a list. This distinction is introduced because it is needed for the
patch that adds support for heterogeneous lists, which are implemented
by adding a third pointer field with a fat pointer to the full struct.
When inserting into the heterogeneous list, the pointer-to-self is
updated to have the right vtable, and the container_of operation is
implemented by just returning that pointer instead of using the real
container_of operation.
Reviewed-by: Benno Lossin <[email protected]>
Signed-off-by: Alice Ryhl <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
Diffstat (limited to 'rust/helpers')
0 files changed, 0 insertions, 0 deletions
