Loading...
Searching...
No Matches
Simple doubly linked list implementation

## Files

file | linuxlist.h
| Simple doubly linked list implementation.

## Data Structures

struct | llist_head
| (double) linked list header structure More...
struct | hlist_head
| Double linked lists with a single pointer list head. More...
struct | hlist_node

## Macros

#define | inline __inline__
#define | container_of(ptr, type, member)
| Cast a member of a structure out to the containing structure.
#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)
#define | LLIST_HEAD_INIT(name) { &(name), &(name) }
| Define a new llist_head pointing to a given llist_head.
#define | LLIST_HEAD(name) struct llist_head name = LLIST_HEAD_INIT(name)
| Define a statically-initialized variable of type llist_head.
#define | INIT_LLIST_HEAD(ptr)
| Initialize a llist_head to point back to itself.
#define | llist_entry(ptr, type, member) container_of(ptr, type, member)
| Get the struct containing this list entry.
#define | llist_first_entry(ptr, type, member) llist_entry((ptr)->next, type, member)
| Get the first element from a linked list.
#define | llist_last_entry(ptr, type, member) llist_entry((ptr)->prev, type, member)
| Get the last element from a list.
#define | llist_last(head) (head)->prev
| Return the last element of the list.
#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.
#define | llist_for_each(pos, head)
| Iterate over a linked list.
#define | __llist_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next)
| Iterate over a linked list (no prefetch).
#define | llist_for_each_prev(pos, head)
| Iterate over a linked list backwards.
#define | llist_for_each_safe(pos, n, head)
| Iterate over a linked list, safe against removal of llist entry.
#define | llist_for_each_entry(pos, head, member)
| Iterate over a linked list of a given type.
#define | llist_for_each_entry_reverse(pos, head, member)
| Iterate backwards over a linked list of a given type.
#define | llist_for_each_entry_continue(pos, head, member)
| Iterate over a linked list of a given type, continuing after an existing point.
#define | llist_for_each_entry_safe(pos, n, head, member)
| Iterate over llist of given type, safe against removal of llist entry.
#define | llist_for_each_rcu(pos, head)
| Iterate over an rcu-protected llist.
#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.
#define | llist_for_each_entry_rcu(pos, head, member)
| Iterate over an rcu-protected llist of a given type.
#define | llist_for_each_continue_rcu(pos, head)
| Iterate over an rcu-protected llist, continuing after existing point.
#define | HLIST_HEAD_INIT { .first = NULL }
#define | HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
#define | INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
#define | READ_ONCE(x) x
#define | WRITE_ONCE(a, b) a = b
#define | hlist_entry(ptr, type, member) container_of(ptr,type,member)
#define | hlist_for_each(pos, head) for (pos = (head)->first; pos ; pos = pos->next)
#define | hlist_for_each_safe(pos, n, head)
#define | hlist_entry_safe(ptr, type, member)
#define | hlist_for_each_entry(pos, head, member)
| iterate over list of given type.
#define | hlist_for_each_entry_continue(pos, member)
| iterate over a hlist continuing after current point.
#define | hlist_for_each_entry_from(pos, member)
| iterate over a hlist continuing from current point.
#define | hlist_for_each_entry_safe(pos, n, head, member)
| hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry.

## 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).
static void | llist_add_tail (struct llist_head *_new, struct llist_head *head)
| Add a new entry into a linked list (at tail).
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.
static void | llist_del_init (struct llist_head *entry)
| Delete a single entry from a linked list and reinitialize it.
static void | llist_move (struct llist_head *llist, struct llist_head *head)
| Delete from one llist and add as another's head.
static void | llist_move_tail (struct llist_head *llist, struct llist_head *head)
| Delete from one llist and add as another's tail.
static int | llist_empty (const struct llist_head *head)
| Test whether a linked list is empty.
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.
static void | llist_splice_init (struct llist_head *llist, struct llist_head *head)
| Join two llists and reinitialise the emptied llist.
static unsigned int | llist_count (const struct llist_head *head)
| Count number of llist items by iterating.
static void | INIT_HLIST_NODE (struct hlist_node *h)
static int | hlist_unhashed (const struct hlist_node *h)
| Has node been removed from list and reinitialized?.
static int | hlist_unhashed_lockless (const struct hlist_node *h)
| Version of hlist_unhashed for lockless use.
static int | hlist_empty (const struct hlist_head *h)
| Is the specified hlist_head structure an empty hlist?.
static void | __hlist_del (struct hlist_node *n)
static void | hlist_del (struct hlist_node *n)
| Delete the specified hlist_node from its list.
static void | hlist_del_init (struct hlist_node *n)
| Delete the specified hlist_node from its list and initialize.
static void | hlist_add_head (struct hlist_node *n, struct hlist_head *h)
| add a new entry at the beginning of the hlist.
static void | hlist_add_before (struct hlist_node *n, struct hlist_node *next)
| add a new entry before the one specified.
static void | hlist_add_behind (struct hlist_node *n, struct hlist_node *prev)
| add a new entry after the one specified
static void | hlist_add_fake (struct hlist_node *n)
| create a fake hlist consisting of a single headless node.
static bool | hlist_fake (struct hlist_node *h)
| Is this node a fake hlist?.
static bool | hlist_is_singular_node (struct hlist_node *n, struct hlist_head *h)
| is node the only element of the specified hlist?.
static void | hlist_move_list (struct hlist_head *old, struct hlist_head *_new)
| Move an hlist.

## Detailed Description

## Macro Definition Documentation

## __llist_for_each

#define __llist_for_each | ( |  | pos,
|  |  | head
| ) |  | for (pos = (head)->next; pos != (head); pos = pos->next)

Iterate over a linked list (no prefetch).

Parameters

  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.

## __llist_for_each_rcu

#define __llist_for_each_rcu | ( |  | pos,
|  |  | head
| ) |  |

Value:
for (pos = (head)->next; pos != (head); \
pos = pos->next, ({ smp_read_barrier_depends(); 0;}))
subsys
char subsys[16]
logging sub-system
Definition gsmtap.h:9

## container_of

#define container_of | ( |  | ptr,
|  |  | type,
|  |  | member
| ) |  |

Value:
({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type, member) );})
type
uint8_t type

Cast a member of a structure out to the containing structure.

Parameters

  [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.

## hlist_entry

#define hlist_entry | ( |  | ptr,
|  |  | type,
|  |  | member
| ) |  | container_of(ptr,type,member)

## hlist_entry_safe

#define hlist_entry_safe | ( |  | ptr,
|  |  | type,
|  |  | member
| ) |  |

Value:
({ typeof(ptr) ____ptr = (ptr); \
____ptr ? hlist_entry(____ptr, type, member) : NULL; \
})
hlist_entry
#define hlist_entry(ptr, type, member)
Definition linuxlist.h:595

## hlist_for_each

#define hlist_for_each | ( |  | pos,
|  |  | head
| ) |  | for (pos = (head)->first; pos ; pos = pos->next)

## hlist_for_each_entry

#define hlist_for_each_entry | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
pos; \
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
hlist_entry_safe
#define hlist_entry_safe(ptr, type, member)
Definition linuxlist.h:604

iterate over list of given type.

Parameters

  [out] | pos | the type * to use as a loop cursor.
  [in] | head | the head for your list.
  [in] | member | the name of the hlist_node within the struct.

## hlist_for_each_entry_continue

#define hlist_for_each_entry_continue | ( |  | pos,
|  |  | member
| ) |  |

Value:
for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member);\
pos; \
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))

iterate over a hlist continuing after current point.

Parameters

  [out] | pos | the type * to use as a loop cursor.
  [in] | member | the name of the hlist_node within the struct.

## hlist_for_each_entry_from

#define hlist_for_each_entry_from | ( |  | pos,
|  |  | member
| ) |  |

Value:
for (; pos; \
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))

iterate over a hlist continuing from current point.

Parameters

  [out] | pos | the type * to use as a loop cursor.
  [in] | member | the name of the hlist_node within the struct.

## hlist_for_each_entry_safe

#define hlist_for_each_entry_safe | ( |  | pos,
|  |  | n,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\
pos && ({ n = pos->member.next; 1; }); \
pos = hlist_entry_safe(n, typeof(*pos), member))
n
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup write Write running configuration to or terminal n Write to terminal n

hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry.

Parameters

  [out] | pos | the type * to use as a loop cursor.
  [out] | n | a &struct hlist_node to use as temporary storage
  [in] | head | the head for your list.
  [in] | member | the name of the hlist_node within the struct

## hlist_for_each_safe

#define hlist_for_each_safe | ( |  | pos,
|  |  | n,
|  |  | head
| ) |  |

Value:
for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
pos = n)

## HLIST_HEAD

#define HLIST_HEAD | ( |  | name | ) | struct hlist_head name = { .first = NULL }

## HLIST_HEAD_INIT

#define HLIST_HEAD_INIT { .first = NULL }

## INIT_HLIST_HEAD

#define INIT_HLIST_HEAD | ( |  | ptr | ) | ((ptr)->first = NULL)

## INIT_LLIST_HEAD

#define INIT_LLIST_HEAD | ( |  | ptr | ) |

Value:
do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)

Initialize a llist_head to point back to itself.

Parameters

  [in] | ptr | llist_head to be initialized.

## inline

#define inline __inline__

## llist_entry

#define llist_entry | ( |  | ptr,
|  |  | type,
|  |  | member
| ) |  | container_of(ptr, type, member)

Get the struct containing this list entry.

Parameters

  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.

## llist_first_entry

#define llist_first_entry | ( |  | ptr,
|  |  | type,
|  |  | member
| ) |  | llist_entry((ptr)->next, type, member)

Get the first element from a linked list.

Parameters

  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.

## llist_first_entry_or_null

#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.

Parameters

  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.

## llist_for_each

#define llist_for_each | ( |  | pos,
|  |  | head
| ) |  |

Value:
for (pos = (head)->next, prefetch(pos->next); pos != (head); \
pos = pos->next, prefetch(pos->next))
prefetch
static void prefetch(const void *x)
Definition linuxlist.h:25

Iterate over a linked list.

Parameters

  pos | the llist_head to use as a loop counter.
  head | the head of the list over which to iterate.

## llist_for_each_continue_rcu

#define llist_for_each_continue_rcu | ( |  | pos,
|  |  | head
| ) |  |

Value:
for ((pos) = (pos)->next, prefetch((pos)->next); (pos) != (head); \
(pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}), prefetch((pos)->next))

Iterate over an rcu-protected llist, continuing after existing point.

Parameters

  pos | the llist_head to use as a loop counter.
  head | the head of the list over which to iterate.

## llist_for_each_entry

#define llist_for_each_entry | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = llist_entry((head)->next, typeof(*pos), member), \
prefetch(pos->member.next); \
&pos->member != (head); \
pos = llist_entry(pos->member.next, typeof(*pos), member), \
prefetch(pos->member.next))
llist_entry
#define llist_entry(ptr, type, member)
Get the struct containing this list entry.
Definition linuxlist.h:218

Iterate over a linked list of a given type.

Parameters

  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.

## llist_for_each_entry_continue

#define llist_for_each_entry_continue | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = llist_entry(pos->member.next, typeof(*pos), member), \
prefetch(pos->member.next); \
&pos->member != (head); \
pos = llist_entry(pos->member.next, typeof(*pos), member), \
prefetch(pos->member.next))

Iterate over a linked list of a given type, continuing after an existing point.

Parameters

  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.

## llist_for_each_entry_rcu

#define llist_for_each_entry_rcu | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = llist_entry((head)->next, typeof(*pos), member), \
prefetch(pos->member.next); \
&pos->member != (head); \
pos = llist_entry(pos->member.next, typeof(*pos), member), \
({ smp_read_barrier_depends(); 0;}), \
prefetch(pos->member.next))

Iterate over an rcu-protected llist of a given type.

Parameters

  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.

## llist_for_each_entry_reverse

#define llist_for_each_entry_reverse | ( |  | pos,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = llist_entry((head)->prev, typeof(*pos), member), \
prefetch(pos->member.prev); \
&pos->member != (head); \
pos = llist_entry(pos->member.prev, typeof(*pos), member), \
prefetch(pos->member.prev))

Iterate backwards over a linked list of a given type.

Parameters

  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.

## llist_for_each_entry_safe

#define llist_for_each_entry_safe | ( |  | pos,
|  |  | n,
|  |  | head,
|  |  | member
| ) |  |

Value:
for (pos = llist_entry((head)->next, typeof(*pos), member), \
n = llist_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = llist_entry(n->member.next, typeof(*n), member))

Iterate over llist of given type, safe against removal of llist entry.

Parameters

  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.

## llist_for_each_prev

#define llist_for_each_prev | ( |  | pos,
|  |  | head
| ) |  |

Value:
for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \
pos = pos->prev, prefetch(pos->prev))

Iterate over a linked list backwards.

Parameters

  pos | the llist_head to use as a loop counter.
  head | the head of the list over which to iterate.

## llist_for_each_rcu

#define llist_for_each_rcu | ( |  | pos,
|  |  | head
| ) |  |

Value:
for (pos = (head)->next, prefetch(pos->next); pos != (head); \
pos = pos->next, ({ smp_read_barrier_depends(); 0;}), prefetch(pos->next))

Iterate over an rcu-protected llist.

Parameters

  pos | the llist_head to use as a loop counter.
  head | the head of the list over which to iterate.

## llist_for_each_safe

#define llist_for_each_safe | ( |  | pos,
|  |  | n,
|  |  | head
| ) |  |

Value:
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)

Iterate over a linked list, safe against removal of llist entry.

Parameters

  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.

## llist_for_each_safe_rcu

#define llist_for_each_safe_rcu | ( |  | pos,
|  |  | n,
|  |  | head
| ) |  |

Value:
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, ({ smp_read_barrier_depends(); 0;}), n = pos->next)

Iterate over an rcu-protected llist, safe against removal of llist entry.

Parameters

  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.

## LLIST_HEAD

#define LLIST_HEAD | ( |  | name | ) | struct llist_head name = LLIST_HEAD_INIT(name)

Define a statically-initialized variable of type llist_head.

Parameters

  [in] | name | variable (symbol) name.

## LLIST_HEAD_INIT

#define LLIST_HEAD_INIT | ( |  | name | ) | { &(name), &(name) }

Define a new llist_head pointing to a given llist_head.

Parameters

  [in] | name | another llist_head to be pointed.

## llist_last

#define llist_last | ( |  | head | ) | (head)->prev

Return the last element of the list.

Parameters

  head | the llist head of the list.

Returns
  last element of the list, head if the list is empty.

## llist_last_entry

#define llist_last_entry | ( |  | ptr,
|  |  | type,
|  |  | member
| ) |  | llist_entry((ptr)->prev, type, member)

Get the last element from a list.

Parameters

  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.

## LLIST_POISON1

#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.

## LLIST_POISON2

#define LLIST_POISON2 ((void *) 0x00200200)

## READ_ONCE

#define READ_ONCE | ( |  | x | ) | x

## WRITE_ONCE

#define WRITE_ONCE | ( |  | a,
|  |  | b
| ) |  | a = b

## Function Documentation

## __hlist_del()

static void __hlist_del | ( | struct hlist_node * | n | ) |

inline static

References n, hlist_node::next, hlist_node::pprev, and WRITE_ONCE.

Referenced by hlist_del(), and hlist_del_init().

## __llist_add()

static void __llist_add | ( | struct llist_head * | _new,
|  | struct llist_head * | prev,
|  | struct llist_head * | next
| ) |  |

inline static

References llist_head::next, and llist_head::prev.

Referenced by llist_add(), and llist_add_tail().

## __llist_del()

static void __llist_del | ( | struct llist_head * | prev,
|  | struct llist_head * | next
| ) |  |

inline static

References llist_head::next, and llist_head::prev.

Referenced by llist_del(), llist_del_init(), llist_move(), and llist_move_tail().

## __llist_splice()

static void __llist_splice | ( | struct llist_head * | llist,
|  | struct llist_head * | head
| ) |  |

inline static

References llist_head::next, and llist_head::prev.

Referenced by llist_splice(), and llist_splice_init().

## hlist_add_before()

static void hlist_add_before | ( | struct hlist_node * | n,
|  | struct hlist_node * | next
| ) |  |

inline static

add a new entry before the one specified.

: new entry to be added @next: hlist node to add it before, which must be non-NULL

References n, hlist_node::next, hlist_node::pprev, and WRITE_ONCE.

## hlist_add_behind()

static void hlist_add_behind | ( | struct hlist_node * | n,
|  | struct hlist_node * | prev
| ) |  |

inline static

add a new entry after the one specified

Parameters

  [in] | n | new entry to be added
  [in] | prev | hlist node to add it after, which must be non-NULL

References n, hlist_node::next, and WRITE_ONCE.

## hlist_add_fake()

static void hlist_add_fake | ( | struct hlist_node * | n | ) |

inline static

create a fake hlist consisting of a single headless node.

Parameters

  [in] | n | Node to make a fake list out of

This makes
appear to be its own predecessor on a headless hlist. The point of this is to allow things like hlist_del() to work correctly in cases where there is no list.

References n.

## hlist_add_head()

static void hlist_add_head | ( | struct hlist_node * | n,
|  | struct hlist_head * | h
| ) |  |

inline static

add a new entry at the beginning of the hlist.

Parameters

  [in] | n | new entry to be added
  [in] | h | hlist head to add it after

Insert a new entry after the specified head. This is good for implementing stacks.

References h, n, hlist_node::pprev, and WRITE_ONCE.

## hlist_del()

static void hlist_del | ( | struct hlist_node * | n | ) |

inline static

Delete the specified hlist_node from its list.

Parameters

  [in] | n | Node to delete.

Note that this function leaves the node in hashed state. Use hlist_del_init() or similar instead to unhash
.

References __hlist_del(), LLIST_POISON1, LLIST_POISON2, and n.

## hlist_del_init()

static void hlist_del_init | ( | struct hlist_node * | n | ) |

inline static

Delete the specified hlist_node from its list and initialize.

Parameters

  [in] | n | Node to delete.

Note that this function leaves the node in unhashed state.

References __hlist_del(), hlist_unhashed(), INIT_HLIST_NODE(), and n.

Referenced by hash_del().

## hlist_empty()

static int hlist_empty | ( | const struct hlist_head * | h | ) |

inline static

Is the specified hlist_head structure an empty hlist?.

Parameters

  [in] | h | Structure to check.

Returns
  1 if hlist is empty; 0 if not

References h, and READ_ONCE.

Referenced by __hash_empty().

## hlist_fake()

static bool hlist_fake | ( | struct hlist_node * | h | ) |

inline static

Is this node a fake hlist?.

Parameters

  [in] | h | Node to check for being a self-referential fake hlist.

References h.

## hlist_is_singular_node()

static bool hlist_is_singular_node | ( | struct hlist_node * | n,
|  | struct hlist_head * | h
| ) |  |

inline static

is node the only element of the specified hlist?.

Parameters

  [in] | n | Node to check for singularity.
  [in] | h | Header for potentially singular list.

Check whether the node is the only node of the head without accessing head, thus avoiding unnecessary cache misses.

References h, and n.

## hlist_move_list()

static void hlist_move_list | ( | struct hlist_head * | old,
|  | struct hlist_head * | _new
| ) |  |

inline static

Move an hlist.

Parameters

  [in] | old | hlist_head for old list.
  [in] | new | hlist_head for new list.

Move a list from one list head to another. Fixup the pprev reference of the first entry if it exists.

References hlist_head::first, and hlist_node::pprev.

## hlist_unhashed()

static int hlist_unhashed | ( | const struct hlist_node * | h | ) |

inline static

Has node been removed from list and reinitialized?.

Parameters

  [in] | h | Node to be checked

Returns
  1 if node is unhashed; 0 if not

Not that not all removal functions will leave a node in unhashed state. For example, hlist_nulls_del_init_rcu() does leave the node in unhashed state, but hlist_nulls_del() does not.

References h.

Referenced by hash_hashed(), and hlist_del_init().

## hlist_unhashed_lockless()

static int hlist_unhashed_lockless | ( | const struct hlist_node * | h | ) |

inline static

Version of hlist_unhashed for lockless use.

Parameters

  [in] | n | Node to be checked

Returns
  1 if node is unhashed; 0 if not

This variant of hlist_unhashed() must be used in lockless contexts to avoid potential load-tearing. The READ_ONCE() is paired with the various WRITE_ONCE() in hlist helpers that are defined below.

References h, and READ_ONCE.

## INIT_HLIST_NODE()

static void INIT_HLIST_NODE | ( | struct hlist_node * | h | ) |

inline static

References h.

Referenced by hlist_del_init().

## llist_add()

static void llist_add | ( | struct llist_head * | _new,
|  | struct llist_head * | head
| ) |  |

inline static

Add a new entry into a linked list (at head).

Parameters

  _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 iofd_txqueue_enqueue_front(), llist_move(), osmo_fsm_inst_alloc(), osmo_fsm_inst_change_parent(), osmo_stat_item_group_alloc(), osmo_timers_update(), osmo_wqueue_bfd_cb(), and rate_ctr_group_alloc().

## llist_add_tail()

static void llist_add_tail | ( | struct llist_head * | _new,
|  | struct llist_head * | head
| ) |  |

inline static

Add a new entry into a linked list (at tail).

Parameters

  _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(), iofd_txqueue_enqueue(), llist_move_tail(), log_add_target(), msgb_enqueue(), netdev_netns_ctx_alloc(), osmo_counter_alloc(), osmo_fsm_register(), osmo_netdev_alloc(), osmo_signal_register_handler(), osmo_stats_reporter_alloc(), osmo_stats_tcp_osmo_fd_register(), osmo_use_count_create(), and osmo_use_count_make_static_entries().

## llist_count()

static unsigned int llist_count | ( | const struct llist_head * | head | ) |

inline static

Count number of llist items by iterating.

Parameters

  head | the llist head to count items of.

Returns
  Number of items.

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(), osmo_stats_tcp_osmo_fd_unregister(), and stats_tcp_poll_timer_cb().

## llist_del()

static void llist_del | ( | struct llist_head * | entry | ) |

inline static

Delete a single entry from a linked list.

Parameters

  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(), iofd_txqueue_dequeue(), log_del_target(), msgb_dequeue(), netdev_netns_ctx_free(), osmo_counter_free(), osmo_fsm_inst_free(), osmo_fsm_inst_unlink_parent(), osmo_fsm_unregister(), osmo_netdev_free(), osmo_signal_unregister_handler(), osmo_stat_item_group_free(), osmo_stats_reporter_free(), osmo_stats_tcp_osmo_fd_unregister(), osmo_use_count_free(), and rate_ctr_group_free().

## llist_del_init()

static void llist_del_init | ( | struct llist_head * | entry | ) |

inline static

Delete a single entry from a linked list and reinitialize it.

Parameters

  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().

## llist_empty()

static int llist_empty | ( | const struct llist_head * | head | ) |

inline static

Test whether a linked list is empty.

Parameters

  [in] | head | the llist to test.

Returns
  1 if the list is empty, 0 otherwise.

References llist_head::next.

Referenced by _osmo_fsm_inst_term_children(), llist_splice(), llist_splice_init(), log_target_file_switch_to_stream(), msgb_dequeue(), next_stats_tcp_entry(), osmo_stats_timer_cb(), osmo_timer_del(), osmo_wqueue_bfd_cb(), osmo_wqueue_clear(), and rate_ctr_group_free().

## llist_move()

static void llist_move | ( | struct llist_head * | llist,
|  | struct llist_head * | head
| ) |  |

inline static

Delete from one llist and add as another's head.

Parameters

  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.

## llist_move_tail()

static void llist_move_tail | ( | struct llist_head * | llist,
|  | struct llist_head * | head
| ) |  |

inline static

Delete from one llist and add as another's tail.

Parameters

  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.

## llist_splice()

static void llist_splice | ( | struct llist_head * | llist,
|  | struct llist_head * | head
| ) |  |

inline static

Join two linked lists.

Parameters

  llist | the new linked list to add.
  head | the place to add llist within the other list.

References __llist_splice(), and llist_empty().

## llist_splice_init()

static void llist_splice_init | ( | struct llist_head * | llist,
|  | struct llist_head * | head
| ) |  |

inline static

Join two llists and reinitialise the emptied llist.

Parameters

  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().

## prefetch()

static void prefetch | ( | const void * | x | ) |

inline static