Skip to main content

clist_create

Macro clist_create 

Source
macro_rules! clist_create {
    ($head:expr, $rust_type:ty, $c_type:ty, $($field:tt).+) => { ... };
}
Expand description

Create a C doubly-circular linked list interface CList from a raw list_head pointer.

This macro creates a CList<T, OFFSET> that can iterate over items of type $rust_type linked via the $field field in the underlying C struct $c_type.

§Arguments

  • $head: Raw pointer to the sentinel list_head object (*mut bindings::list_head).
  • $rust_type: Each item’s Rust wrapper type.
  • $c_type: Each item’s C struct type that contains the embedded list_head.
  • $field: The name of the list_head field within the C struct.

§Safety

The caller must ensure:

  • $head is a valid, initialized sentinel list_head (e.g. via INIT_LIST_HEAD()) pointing to a list that is not concurrently modified for the lifetime of the CList.
  • The list contains items of type $c_type linked via an embedded $field.
  • $rust_type is #[repr(transparent)] over $c_type or has compatible layout.

§Examples

Refer to the examples in the crate::interop::list module documentation.