libosmocore
1.4.0
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) |
These are non-NULL pointers that will result in page faults under normal circumstances, used to verify that nobody uses non-initialized llist entries. More... | |
#define | LLIST_POISON2 ((void *) 0x00200200) |
#define | LLIST_HEAD_INIT(name) { &(name), &(name) } |
Define a new llist_head pointing to a given llist_head. More... | |
#define | LLIST_HEAD(name) struct llist_head name = LLIST_HEAD_INIT(name) |
Define a statically-initialized variable of type llist_head. More... | |
#define | INIT_LLIST_HEAD(ptr) |
Initialize a llist_head to point back to itself. More... | |
#define | llist_entry(ptr, type, member) container_of(ptr, type, member) |
Get the struct containing this list entry. More... | |
#define | llist_first_entry(ptr, type, member) llist_entry((ptr)->next, type, member) |
Get the first element from a linked list. More... | |
#define | llist_last_entry(ptr, type, member) llist_entry((ptr)->prev, type, member) |
Get the last element from a list. More... | |
#define | llist_first_entry_or_null(ptr, type, member) (!llist_empty(ptr) ? llist_first_entry(ptr, type, member) : NULL) |
Get the first element from a list, or NULL. 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 linked list (no prefetch). More... | |
#define | llist_for_each_prev(pos, head) |
Iterate over a linked list backwards. More... | |
#define | llist_for_each_safe(pos, n, head) |
Iterate over a linked list, safe against removal of llist entry. More... | |
#define | llist_for_each_entry(pos, head, member) |
Iterate over a linked list of a given type. More... | |
#define | llist_for_each_entry_reverse(pos, head, member) |
Iterate backwards over a linked list of a given type. More... | |
#define | llist_for_each_entry_continue(pos, head, member) |
Iterate over a linked list of a given type, continuing after an 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) |
Iterate over an rcu-protected llist. More... | |
#define | __llist_for_each_rcu(pos, head) |
#define | llist_for_each_safe_rcu(pos, n, head) |
Iterate over an rcu-protected llist, safe against removal of llist entry. More... | |
#define | llist_for_each_entry_rcu(pos, head, member) |
Iterate over an rcu-protected llist of a given type. More... | |
#define | llist_for_each_continue_rcu(pos, head) |
Iterate over an rcu-protected llist, continuing after existing point. More... | |
Functions | |
static void | prefetch (const void *x) |
static void | __llist_add (struct llist_head *_new, struct llist_head *prev, struct llist_head *next) |
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 a single entry from a linked list. More... | |
static void | llist_del_init (struct llist_head *entry) |
Delete a single entry from a 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 linked lists. 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 (const struct llist_head *head) |
Count number of llist items by iterating. More... | |
#define __llist_for_each | ( | pos, | |
head | |||
) | for (pos = (head)->next; pos != (head); pos = pos->next) |
Iterate over a linked list (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 itself.
[in] | ptr | llist_head to be initialized. |
#define inline __inline__ |
#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. |
member | the name of the llist_head within the struct. |
#define llist_first_entry | ( | ptr, | |
type, | |||
member | |||
) | llist_entry((ptr)->next, type, member) |
Get the first element from a linked list.
ptr | the list head to take the element from. |
type | the type of the struct this is embedded in. |
member | the name of the list_head within the struct. |
Note, that list is expected to be not empty.
#define llist_first_entry_or_null | ( | ptr, | |
type, | |||
member | |||
) | (!llist_empty(ptr) ? llist_first_entry(ptr, type, member) : NULL) |
Get the first element from a list, or NULL.
ptr | the list head to take the element from. |
type | the type of the struct this is embedded in. |
member | the name of the list_head within the struct. |
Note that if the list is empty, it returns NULL.
#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 | |||
) |
Iterate over an rcu-protected llist, continuing after existing point.
pos | the llist_head to use as a loop counter. |
head | the head of the list over which to iterate. |
#define llist_for_each_entry | ( | pos, | |
head, | |||
member | |||
) |
Iterate over a linked list of a 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 the struct pos. |
#define llist_for_each_entry_continue | ( | pos, | |
head, | |||
member | |||
) |
Iterate over a linked list of a given type, continuing after an 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 the struct pos. |
#define llist_for_each_entry_rcu | ( | pos, | |
head, | |||
member | |||
) |
Iterate over an rcu-protected llist of a 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_struct within the struct. |
#define llist_for_each_entry_reverse | ( | pos, | |
head, | |||
member | |||
) |
Iterate backwards over a linked list of a 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 the 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 the struct pos. |
#define llist_for_each_prev | ( | pos, | |
head | |||
) |
Iterate over a linked list 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 | |||
) |
Iterate over an rcu-protected llist.
pos | the llist_head to use as a loop counter. |
head | the head of the list over which to iterate. |
#define llist_for_each_safe | ( | pos, | |
n, | |||
head | |||
) |
Iterate over a linked 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 | |||
) |
Iterate over an rcu-protected llist, 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_HEAD | ( | name | ) | struct llist_head name = LLIST_HEAD_INIT(name) |
Define a statically-initialized variable of type llist_head.
[in] | name | variable (symbol) name. |
Define a new llist_head pointing to a given llist_head.
[in] | name | another llist_head to be pointed. |
#define llist_last_entry | ( | ptr, | |
type, | |||
member | |||
) | llist_entry((ptr)->prev, type, member) |
Get the last element from a list.
ptr | the list head to take the element from. |
type | the type of the struct this is embedded in. |
member | the name of the llist_head within the struct. |
Note, that list is expected to be not empty.
#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.
#define LLIST_POISON2 ((void *) 0x00200200) |
|
inlinestatic |
References llist_head::next, and llist_head::prev.
Referenced by llist_add(), and llist_add_tail().
|
inlinestatic |
References llist_head::next, and llist_head::prev.
Referenced by llist_del(), llist_del_init(), llist_move(), and llist_move_tail().
|
inlinestatic |
References llist_head::next, and llist_head::prev.
Referenced by llist_splice(), and llist_splice_init().
|
inlinestatic |
Add a new entry into a linked list (at head).
_new | the entry to be added. |
head | llist_head to prepend the element to. |
Insert a new entry after the specified head. This is good for implementing stacks.
References __llist_add(), and llist_head::next.
Referenced by llist_move(), osmo_fsm_inst_alloc(), osmo_fsm_inst_change_parent(), osmo_stat_item_group_alloc(), osmo_stats_reporter_alloc(), osmo_timers_update(), and rate_ctr_group_alloc().
|
inlinestatic |
Add a new entry into a linked list (at tail).
_new | the entry to be added. |
head | llist_head to append the element to. |
Insert a new entry before the specified head. This is useful for implementing queues.
References __llist_add(), and llist_head::prev.
Referenced by _osmo_use_count_get_put(), alloc_entry(), llist_move_tail(), log_add_target(), msgb_enqueue(), osmo_counter_alloc(), osmo_fd_register(), osmo_fsm_register(), osmo_signal_register_handler(), osmo_use_count_create(), and osmo_use_count_make_static_entries().
|
inlinestatic |
Count number 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.
Referenced by osmo_counters_count().
|
inlinestatic |
Delete a single entry from a linked list.
entry | the element to delete. |
Note: llist_empty on entry does not return true after this, the entry is in an undefined state.
References __llist_del(), LLIST_POISON1, LLIST_POISON2, llist_head::next, and llist_head::prev.
Referenced by _osmo_fsm_inst_term(), _osmo_use_count_get_put(), log_del_target(), msgb_dequeue(), osmo_counter_free(), osmo_fd_unregister(), osmo_fsm_inst_free(), osmo_fsm_inst_unlink_parent(), osmo_fsm_unregister(), osmo_signal_unregister_handler(), osmo_stat_item_group_free(), osmo_stats_reporter_free(), osmo_use_count_free(), and rate_ctr_group_free().
|
inlinestatic |
Delete a single entry from a linked list and reinitialize it.
entry | the element to delete and reinitialize. |
References __llist_del(), INIT_LLIST_HEAD, llist_head::next, and llist_head::prev.
Referenced by osmo_timer_del().
|
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_stats_timer_cb(), osmo_timer_del(), osmo_wqueue_bfd_cb(), osmo_wqueue_clear(), and rate_ctr_group_free().
|
inlinestatic |
Delete from one llist and add as another's head.
llist | the entry to move. |
head | the head that will precede our entry. |
References __llist_del(), llist_add(), llist_head::next, and llist_head::prev.
|
inlinestatic |
Delete from one llist and add as another's tail.
llist | the entry to move. |
head | the head that will follow our entry. |
References __llist_del(), llist_add_tail(), llist_head::next, and llist_head::prev.
|
inlinestatic |
Join two linked lists.
llist | the new linked list to add. |
head | the place to add llist within the other list. |
References __llist_splice(), and llist_empty().
|
inlinestatic |
Join two llists and reinitialise the emptied llist.
llist | the new linked list to add. |
head | the place to add it within the first llist. |
The llist is reinitialised.
References __llist_splice(), INIT_LLIST_HEAD, and llist_empty().
|
inlinestatic |