Module to declare the doubly linked list API.
More...
Module to declare the doubly linked list API.
#define INIT_LIST_HEAD |
( |
|
ptr | ) |
|
Value:do \
{ \
(ptr)->prev = (ptr); \
(ptr)->next = (ptr); \
} while (0)
Initializes a list by pointer.
- Parameters
-
[in,out] | ptr | Pointer to a list. |
Checks if a list is empty.
- Parameters
-
- Returns
- 0 if not empty, non-zero otherwise.
Defines and initializes a new list.
A call to this macro creates a new variable with the given name and initializes it as a list "head".
- Parameters
-
[in,out] | name | The "head" struct name. |
#define LIST_HEAD_INIT |
( |
|
name | ) |
{ &(name), &(name) } |
Initializes a list by variable name.
- Warning
- this macro assumes that a list "head" (sys_list_head_t) variable with name name is already created.
- Parameters
-
[in,out] | name | The "head" struct name. |
#define SYS_LIST_ENTRY |
( |
|
ll_ret_var, |
|
|
|
ll_ptr, |
|
|
|
ll_type, |
|
|
|
ll_member |
|
) |
| |
Value:do \
{ \
size_t p = (size_t) ll_ptr; \
size_t off = offsetof(ll_type, ll_member); \
ll_ret_var = (ll_type *) (p - off); \
} while (0)
Sets a pointer to a variable to the parent structure pointer using a pointer to a field in this structure.
- Note
- This is a version of GET_PARENT_BY_FIELD() extended by setting to a variable.
- Parameters
-
[out] | ll_ret_var | Variable pointer name to return. |
[in] | ll_ptr | Pointer to the structure field. |
[in] | ll_type | Name of the parent structure. |
[in] | ll_member | Name of the structure field. |
#define SYS_LIST_FOR_EACH |
( |
|
pos, |
|
|
|
head |
|
) |
| |
Value:for (pos = ((head)->next); \
((pos) != (head)); \
pos = (pos)->next)
Iterates through the list.
- Note
- Use SYS_LIST_FOR_EACH_SAFE() for thread-safe cases.
- Parameters
-
[out] | pos | Iterator variable. |
[in] | head | Pointer to the list head. |
#define SYS_LIST_FOR_EACH_SAFE |
( |
|
ll_pos, |
|
|
|
ll_pos_n, |
|
|
|
ll_head |
|
) |
| |
Value:for (ll_pos = (ll_head)->next, ll_pos_n = (ll_head)->next->next; \
(ll_pos) != (ll_head); \
ll_pos = ll_pos_n, ll_pos_n = ll_pos->next)
Thread-safe version of SYS_LIST_FOR_EACH().
- Parameters
-
[out] | ll_pos | Iterator variable. |
[out] | ll_pos_n | Temporary iterator variable (next entry). |
[in] | ll_head | Pointer to the list head. |
Function for adding a new item to the head of the list.
- Parameters
-
[in] | new | Pointer to a new element. |
[in] | head | Pointer to the list head. |
Function for adding a new item to the tail of the list.
- Parameters
-
[in] | new | Pointer to a new element. |
[in] | head | Pointer to the list head. |
Function for deleting an entry from list.
- Parameters
-
[in] | entry | The element to delete from the list. |
Function for deleting an entry from the list and reinitializing it.
- Parameters
-
[in] | entry | The element to delete from the list. |
Function for testing if a list is empty.
- Parameters
-
[in] | head | The list to test. |
- Returns
- 0 if not empty, non-zero otherwise.
Adds a new item to the list between l_prev and l_next elements.
- Warning
- This routine assumes that l_next is next to l_prev in the list.
- Note
- This is an internal helper routine which is not intended to be used by the user.
- Parameters
-
[in] | l_prev | Pointer to the previous element. |
[in] | l_next | Pointer to the next element. |
[in] | l_new | Pointer to a new element. |
Deletes an element between l_prev and l_next elements.
- Warning
- This macro assumes that l_next is next to l_prev in the list.
- Note
- This is an internal helper routine which is not intended to be used by the user.
- Parameters
-
[in] | l_prev | Pointer to the previous element. |
[in] | l_next | Pointer to the next element. |