libosmocore
0.9.6-9.20170220git32ee5af8.fc30
Osmocom core library
|
Files | |
file | linuxlist.h |
Simple doubly linked list implementation. | |
Data Structures | |
struct | llist_head |
(double) linked list header structure More... | |
Macros | |
#define | inline __inline__ |
#define | container_of(ptr, type, member) |
cast a member of a structure out to the containing structure More... | |
#define | LLIST_POISON1 ((void *) 0x00100100) |
#define | LLIST_POISON2 ((void *) 0x00200200) |
#define | LLIST_HEAD_INIT(name) { &(name), &(name) } |
#define | LLIST_HEAD(name) struct llist_head name = LLIST_HEAD_INIT(name) |
define a statically-initialized llist_head More... | |
#define | INIT_LLIST_HEAD(ptr) |
initialize a llist_head to point back to self More... | |
#define | llist_entry(ptr, type, member) container_of(ptr, type, member) |
Get the struct containing this list entry. More... | |
#define | llist_for_each(pos, head) |
Iterate over a linked list. More... | |
#define | __llist_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next) |
Iterate over a llist (no prefetch) More... | |
#define | llist_for_each_prev(pos, head) |
Iterate over a llist backwards. More... | |
#define | llist_for_each_safe(pos, n, head) |
Iterate over a list; safe against removal of llist entry. More... | |
#define | llist_for_each_entry(pos, head, member) |
Iterate over llist of given type. More... | |
#define | llist_for_each_entry_reverse(pos, head, member) |
Iterate backwards over llist of given type. More... | |
#define | llist_for_each_entry_continue(pos, head, member) |
iterate over llist of given type continuing after existing point More... | |
#define | llist_for_each_entry_safe(pos, n, head, member) |
iterate over llist of given type, safe against removal of non-consecutive(!) llist entries More... | |
#define | llist_for_each_rcu(pos, head) |
#define | __llist_for_each_rcu(pos, head) |
#define | llist_for_each_safe_rcu(pos, n, head) |
#define | llist_for_each_entry_rcu(pos, head, member) |
#define | llist_for_each_continue_rcu(pos, head) |
Functions | |
static void | prefetch (const void *x) |
static void | __llist_add (struct llist_head *_new, struct llist_head *prev, struct llist_head *next) |
Insert a new entry between two known consecutive entries. More... | |
static void | llist_add (struct llist_head *_new, struct llist_head *head) |
add a new entry into a linked list (at head) More... | |
static void | llist_add_tail (struct llist_head *_new, struct llist_head *head) |
add a new entry into a linked list (at tail) More... | |
static void | __llist_del (struct llist_head *prev, struct llist_head *next) |
static void | llist_del (struct llist_head *entry) |
Delete entry from linked list. More... | |
static void | llist_del_init (struct llist_head *entry) |
Delete entry from linked list and reinitialize it. More... | |
static void | llist_move (struct llist_head *llist, struct llist_head *head) |
Delete from one llist and add as another's head. More... | |
static void | llist_move_tail (struct llist_head *llist, struct llist_head *head) |
Delete from one llist and add as another's tail. More... | |
static int | llist_empty (const struct llist_head *head) |
Test whether a linked list is empty. More... | |
static void | __llist_splice (struct llist_head *llist, struct llist_head *head) |
static void | llist_splice (struct llist_head *llist, struct llist_head *head) |
Join two llists. More... | |
static void | llist_splice_init (struct llist_head *llist, struct llist_head *head) |
join two llists and reinitialise the emptied llist. More... | |
static unsigned int | llist_count (struct llist_head *head) |
count nr of llist items by iterating. More... | |
Variables | |
struct llist_head * | llist_head::next |
Pointer to next and previous item. | |
struct llist_head * | llist_head::prev |
#define __llist_for_each | ( | pos, | |
head | |||
) | for (pos = (head)->next; pos != (head); pos = pos->next) |
Iterate over a llist (no prefetch)
pos | The llist_head to use as a loop counter |
head | The head of the list over which to iterate |
This variant differs from llist_for_each() in that it's the simplest possible llist iteration code, no prefetching is done. Use this for code that knows the llist to be very short (empty or 1 entry) most of the time.
#define __llist_for_each_rcu | ( | pos, | |
head | |||
) |
#define container_of | ( | ptr, | |
type, | |||
member | |||
) |
cast a member of a structure out to the containing structure
[in] | ptr | the pointer to the member. |
[in] | type | the type of the container struct this is embedded in. |
[in] | member | the name of the member within the struct. |
#define INIT_LLIST_HEAD | ( | ptr | ) |
initialize a llist_head to point back to self
#define llist_entry | ( | ptr, | |
type, | |||
member | |||
) | container_of(ptr, type, member) |
Get the struct containing this list entry.
ptr | The llist_head pointer |
type | The type of the struct this is embedded in |
#define llist_for_each | ( | pos, | |
head | |||
) |
Iterate over a linked list.
pos | The llist_head to use as a loop counter |
head | The head of the list over which to iterate |
#define llist_for_each_continue_rcu | ( | pos, | |
head | |||
) |
llist_for_each_continue_rcu - iterate over an rcu-protected llist continuing after existing point. @pos: the &struct llist_head to use as a loop counter. @head: the head for your llist.
#define llist_for_each_entry | ( | pos, | |
head, | |||
member | |||
) |
Iterate over llist of given type.
pos | The 'type *' to use as a loop counter |
head | The head of the list over which to iterate |
member | The name of the llist_head within struct pos |
#define llist_for_each_entry_continue | ( | pos, | |
head, | |||
member | |||
) |
iterate over llist of given type continuing after existing point
pos | The 'type *' to use as a loop counter |
head | The head of the list over which to iterate |
member | The name of the llist_head within struct pos |
#define llist_for_each_entry_rcu | ( | pos, | |
head, | |||
member | |||
) |
llist_for_each_entry_rcu - iterate over rcu llist of given type @pos: the type * to use as a loop counter. @head: the head for your llist. @member: the name of the llist_struct within the struct.
#define llist_for_each_entry_reverse | ( | pos, | |
head, | |||
member | |||
) |
Iterate backwards over llist of given type.
pos | The 'type *' to use as a loop counter |
head | The head of the list over which to iterate |
member | The name of the llist_head within struct pos |
#define llist_for_each_entry_safe | ( | pos, | |
n, | |||
head, | |||
member | |||
) |
iterate over llist of given type, safe against removal of non-consecutive(!) llist entries
pos | The 'type *' to use as a loop counter |
n | Another type * to use as temporary storage |
head | The head of the list over which to iterate |
member | The name of the llist_head within struct pos |
#define llist_for_each_prev | ( | pos, | |
head | |||
) |
Iterate over a llist backwards.
pos | The llist_head to use as a loop counter |
head | The head of the list over which to iterate |
#define llist_for_each_rcu | ( | pos, | |
head | |||
) |
llist_for_each_rcu - iterate over an rcu-protected llist @pos: the &struct llist_head to use as a loop counter. @head: the head for your llist.
#define llist_for_each_safe | ( | pos, | |
n, | |||
head | |||
) |
Iterate over a list; safe against removal of llist entry.
pos | The llist_head to use as a loop counter |
n | Another llist_head to use as temporary storage |
head | The head of the list over which to iterate |
#define llist_for_each_safe_rcu | ( | pos, | |
n, | |||
head | |||
) |
llist_for_each_safe_rcu - iterate over an rcu-protected llist safe against removal of llist entry @pos: the &struct llist_head to use as a loop counter.
: another &struct llist_head to use as temporary storage @head: the head for your llist.
#define LLIST_HEAD | ( | name | ) | struct llist_head name = LLIST_HEAD_INIT(name) |
define a statically-initialized llist_head
[in] | name | Variable name |
This is a helper macro that will define a named variable of type llist_head and initialize it
#define LLIST_POISON1 ((void *) 0x00100100) |
These are non-NULL pointers that will result in page faults under normal circumstances, used to verify that nobody uses non-initialized llist entries.
|
inlinestatic |
Insert a new entry between two known consecutive entries.
This is only for internal llist manipulation where we know the prev/next entries already!
References llist_head::next.
Referenced by llist_add(), and llist_add_tail().
|
inlinestatic |
add a new entry into a linked list (at head)
_new | New entry to be added |
head | llist_head to add it after |
Insert a new entry after the specified head. This is good for implementing stacks.
References __llist_add(), and llist_head::next.
|
inlinestatic |
add a new entry into a linked list (at tail)
_new | New entry to be added |
head | Head of linked list to whose tail we shall add _new |
Insert a new entry before the specified head. This is useful for implementing queues.
References __llist_add().
Referenced by log_add_target(), msgb_enqueue(), and osmo_counter_alloc().
|
inlinestatic |
count nr of llist items by iterating.
head | The llist head to count items of. |
This function is not efficient, mostly useful for small lists and non time critical cases like unit tests.
References llist_for_each.
|
inlinestatic |
Delete entry from linked list.
entry | The element to delete from the llist |
Note: llist_empty on entry does not return true after this, the entry is in an undefined state.
Referenced by log_del_target(), msgb_dequeue(), osmo_counter_free(), osmo_fsm_unregister(), osmo_signal_unregister_handler(), osmo_stat_item_group_free(), and rate_ctr_group_free().
|
inlinestatic |
Delete entry from linked list and reinitialize it.
entry | The element to delete from the list |
|
inlinestatic |
Test whether a linked list is empty.
[in] | head | The llist to test. |
References llist_head::next.
Referenced by _osmo_fsm_inst_term_children(), llist_splice(), llist_splice_init(), msgb_dequeue(), osmo_wqueue_bfd_cb(), and osmo_wqueue_clear().
|
inlinestatic |
Delete from one llist and add as another's head.
llist | The entry to move |
head | The head that will precede our entry |
|
inlinestatic |
Delete from one llist and add as another's tail.
llist | The entry to move |
head | The head that will follow our entry |
|
inlinestatic |
Join two llists.
llist | The new linked list to add |
head | The place to add llist in the other list |
References llist_empty().
|
inlinestatic |
join two llists and reinitialise the emptied llist.
llist | The new linked list to add. |
head | The place to add it in the first llist. |
The llist at @llist is reinitialised
References llist_empty().