libisdn
|
#include "common.h"
Go to the source code of this file.
Data Structures | |
struct | dlist_head |
Defines | |
#define | DLIST_HEAD(_name) struct dlist_head _name = { &(_name), NULL, NULL } |
#define | dlist_entry(ptr, type, member) container_of(ptr, type, member) |
Get current element. | |
#define | dlist_get_head(ptr) (ptr)->head |
Get head element of list. | |
#define | dlist_insert_head(list, enew) dlist_insert_after((list)->head, enew) |
Insert new element at first position. | |
#define | dlist_push_head(list, enew) dlist_insert_after((list)->head, enew) |
#define | dlist_push_tail(list, enew) dlist_insert_tail(list, enew) |
#define | dlist_for_each(head, p) |
Walk the list of elements in a for like loop. | |
#define | dlist_for_each_safe(head, n, p) |
Walk the list of elements in a for like loop. | |
#define | dlist_for_each_reverse(head, p) |
Reverse-walk the list of elements in a for like loop. | |
#define | dlist_is_empty(head) |
Check if the list has no elements. | |
#define | dlist_num_entries(head) |
Get the number of elements in the list. | |
Functions | |
void | dlist_init_head (struct dlist_head *h) |
Initialize linked list. | |
void | dlist_init (struct dlist_head *e) |
void | dlist_insert_after (struct dlist_head *elem, struct dlist_head *enew) |
Insert new element after given one. | |
void | dlist_insert_before (struct dlist_head *elem, struct dlist_head *enew) |
Insert new element before given one. | |
void | dlist_insert_tail (struct dlist_head *list, struct dlist_head *enew) |
Insert new element at the end of the list. | |
void | dlist_remove (struct dlist_head *elem) |
Remove element from the list. | |
struct dlist_head * | dlist_first (const struct dlist_head *elem) |
Get first element in the list. | |
struct dlist_head * | dlist_last (const struct dlist_head *elem) |
Get last element in the list. | |
struct dlist_head * | dlist_next (const struct dlist_head *elem) |
Get next element after given one. | |
struct dlist_head * | dlist_prev (const struct dlist_head *elem) |
Get element before given one. | |
int | dlist_is_head (const struct dlist_head *elem) |
Check if the element passed is the list head. | |
int | dlist_is_first (const struct dlist_head *elem) |
Check if the element passed is the first one. | |
int | dlist_is_last (const struct dlist_head *elem) |
Check if the element passed is the last one. | |
void | dlist_replace (struct dlist_head *old, struct dlist_head *enew) |
Replace an element in the list with a new one. | |
struct dlist_head * | dlist_pop_head (const struct dlist_head *elem) |
struct dlist_head * | dlist_pop_tail (const struct dlist_head *elem) |
#define dlist_entry | ( | ptr, | |
type, | |||
member | |||
) | container_of(ptr, type, member) |
Get current element.
dlist_entry
Definition at line 40 of file dlist.h.
Referenced by msgb_fifo_dequeue().
#define dlist_for_each | ( | head, | |
p | |||
) |
for (p = (typeof(*p) *)(head)->next; \
p != (typeof(*p) *)(head) && p; \
p = (typeof(*p) *)(p)->next)
Walk the list of elements in a for like loop.
dlist_for_each
[in] | head | The list |
[in] | p | Pointer to store the current element |
#define dlist_for_each_reverse | ( | head, | |
p | |||
) |
for (p = (typeof(*p) *)(head)->prev; \
p != (typeof(*p) *)(head) && p; \
p = (typeof(*p) *)(p)->prev)
Reverse-walk the list of elements in a for like loop.
dlist_for_each_reverse
[in] | head | The list |
[in] | p | Pointer to store the current element |
#define dlist_for_each_safe | ( | head, | |
n, | |||
p | |||
) |
for (p = (typeof(*p) *)(head)->next, n = (typeof(*p) *)(p)->next; \
p != (typeof(*p) *)(head) && p; \
p = (typeof(*p) *)(n), n = (typeof(*p) *)(p)->next)
Walk the list of elements in a for like loop.
dlist_for_each_safe
[in] | head | The list |
[in] | n | Temporary storage |
[in] | p | Pointer to store the current element |
#define dlist_get_head | ( | ptr | ) | (ptr)->head |
#define DLIST_HEAD | ( | _name | ) | struct dlist_head _name = { &(_name), NULL, NULL } |
#define dlist_insert_head | ( | list, | |
enew | |||
) | dlist_insert_after((list)->head, enew) |
#define dlist_is_empty | ( | head | ) |
#define dlist_num_entries | ( | head | ) |
({ \ struct dlist_head *p = (head); \ int _x = 0; \ for (; p && p->next && p->next != (head); _x++) \ p = p->next; \ _x; \ })
Get the number of elements in the list.
dlist_num_entries
[in] | head | The list |
#define dlist_push_head | ( | list, | |
enew | |||
) | dlist_insert_after((list)->head, enew) |
#define dlist_push_tail | ( | list, | |
enew | |||
) | dlist_insert_tail(list, enew) |
struct dlist_head* dlist_first | ( | const struct dlist_head * | elem | ) | [read] |
Get first element in the list.
dlist_first
[in] | elem | Any list element |
Definition at line 96 of file dlist.c.
References dlist_head::head, and dlist_head::next.
Referenced by dlist_pop_head().
void dlist_init | ( | struct dlist_head * | e | ) |
Definition at line 22 of file dlist.c.
References dlist_head::head, dlist_head::next, and dlist_head::prev.
void dlist_init_head | ( | struct dlist_head * | h | ) |
Initialize linked list.
dlist_init_head
[in] | h | pointer to linked list head |
Definition at line 15 of file dlist.c.
References dlist_head::head, dlist_head::next, and dlist_head::prev.
Referenced by msgb_fifo_init().
void dlist_insert_after | ( | struct dlist_head * | elem, |
struct dlist_head * | enew | ||
) |
Insert new element after given one.
dlist_insert_after
[in] | elem | Element to insert after |
[in] | new | New element |
Definition at line 29 of file dlist.c.
References dlist_head::head, dlist_head::next, and dlist_head::prev.
Referenced by dlist_insert_tail().
void dlist_insert_before | ( | struct dlist_head * | elem, |
struct dlist_head * | enew | ||
) |
Insert new element before given one.
dlist_insert_before
[in] | elem | Element to insert before |
[in] | new | New element |
Definition at line 46 of file dlist.c.
References dlist_head::head, dlist_head::next, and dlist_head::prev.
void dlist_insert_tail | ( | struct dlist_head * | list, |
struct dlist_head * | enew | ||
) |
Insert new element at the end of the list.
dlist_insert_tail
[in] | list | The list |
[in] | new | New element |
Definition at line 61 of file dlist.c.
References dlist_insert_after(), dlist_head::head, dlist_head::next, and dlist_head::prev.
Referenced by msgb_fifo_enqueue().
int dlist_is_first | ( | const struct dlist_head * | elem | ) |
Check if the element passed is the first one.
dlist_is_first
[in] | elem | Any list element |
Definition at line 148 of file dlist.c.
References dlist_head::head, and dlist_head::prev.
int dlist_is_head | ( | const struct dlist_head * | elem | ) |
Check if the element passed is the list head.
dlist_is_head
[in] | elem | Any list element |
Definition at line 142 of file dlist.c.
References dlist_head::head.
int dlist_is_last | ( | const struct dlist_head * | elem | ) |
Check if the element passed is the last one.
dlist_is_last
[in] | elem | Any list element |
Definition at line 154 of file dlist.c.
References dlist_head::head, and dlist_head::next.
struct dlist_head* dlist_last | ( | const struct dlist_head * | elem | ) | [read] |
Get last element in the list.
dlist_last
[in] | elem | Any list element |
Definition at line 104 of file dlist.c.
References dlist_head::head, and dlist_head::prev.
Referenced by dlist_pop_tail().
struct dlist_head* dlist_next | ( | const struct dlist_head * | elem | ) | [read] |
Get next element after given one.
dlist_next
[in] | elem | Any list element |
Definition at line 112 of file dlist.c.
References dlist_head::head, and dlist_head::next.
struct dlist_head* dlist_pop_head | ( | const struct dlist_head * | elem | ) | [read] |
Remove and return first element of list
[in] | elem | List |
Definition at line 128 of file dlist.c.
References dlist_first(), and dlist_remove().
Referenced by msgb_fifo_dequeue().
struct dlist_head* dlist_pop_tail | ( | const struct dlist_head * | elem | ) | [read] |
Remove and return last element of list
[in] | elem | List |
Definition at line 135 of file dlist.c.
References dlist_last(), and dlist_remove().
struct dlist_head* dlist_prev | ( | const struct dlist_head * | elem | ) | [read] |
Get element before given one.
dlist_prev
[in] | elem | Any list element |
Definition at line 120 of file dlist.c.
References dlist_head::head, and dlist_head::prev.
void dlist_remove | ( | struct dlist_head * | elem | ) |
Remove element from the list.
dlist_remove
[in] | elem | Element to remove |
Definition at line 79 of file dlist.c.
References dlist_head::head, dlist_head::next, and dlist_head::prev.
Referenced by dlist_pop_head(), and dlist_pop_tail().
void dlist_replace | ( | struct dlist_head * | old, |
struct dlist_head * | enew | ||
) |
Replace an element in the list with a new one.
dlist_replace
[in] | old | Element to replace |
[in] | new | Replacement |
Definition at line 159 of file dlist.c.
References dlist_head::head, dlist_head::next, and dlist_head::prev.