Lines Matching +full:entry +full:- +full:name
1 /* SPDX-License-Identifier: GPL-2.0 */
20 * using the generic single-entry routines.
23 #define LIST_HEAD_INIT(name) { &(name), &(name) } argument
25 #define LIST_HEAD(name) \ argument
26 struct list_head name = LIST_HEAD_INIT(name)
29 * INIT_LIST_HEAD - Initialize a list_head structure
37 WRITE_ONCE(list->next, list); in INIT_LIST_HEAD()
38 WRITE_ONCE(list->prev, list); in INIT_LIST_HEAD()
45 extern bool __list_del_entry_valid(struct list_head *entry);
53 static inline bool __list_del_entry_valid(struct list_head *entry) in __list_del_entry_valid() argument
60 * Insert a new entry between two known consecutive entries.
72 next->prev = new; in __list_add()
73 new->next = next; in __list_add()
74 new->prev = prev; in __list_add()
75 WRITE_ONCE(prev->next, new); in __list_add()
79 * list_add - add a new entry
80 * @new: new entry to be added
83 * Insert a new entry after the specified head.
88 __list_add(new, head, head->next); in list_add()
93 * list_add_tail - add a new entry
94 * @new: new entry to be added
97 * Insert a new entry before the specified head.
102 __list_add(new, head->prev, head); in list_add_tail()
106 * Delete a list entry by making the prev/next entries
114 next->prev = prev; in __list_del()
115 WRITE_ONCE(prev->next, next); in __list_del()
119 * Delete a list entry and clear the 'prev' pointer.
121 * This is a special-purpose list clearing method used in the networking code
122 * for lists allocated as per-cpu, where we don't want to incur the extra
126 static inline void __list_del_clearprev(struct list_head *entry) in __list_del_clearprev() argument
128 __list_del(entry->prev, entry->next); in __list_del_clearprev()
129 entry->prev = NULL; in __list_del_clearprev()
132 static inline void __list_del_entry(struct list_head *entry) in __list_del_entry() argument
134 if (!__list_del_entry_valid(entry)) in __list_del_entry()
137 __list_del(entry->prev, entry->next); in __list_del_entry()
141 * list_del - deletes entry from list.
142 * @entry: the element to delete from the list.
143 * Note: list_empty() on entry does not return true after this, the entry is
146 static inline void list_del(struct list_head *entry) in list_del() argument
148 __list_del_entry(entry); in list_del()
149 entry->next = LIST_POISON1; in list_del()
150 entry->prev = LIST_POISON2; in list_del()
154 * list_replace - replace old entry by new one
163 new->next = old->next; in list_replace()
164 new->next->prev = new; in list_replace()
165 new->prev = old->prev; in list_replace()
166 new->prev->next = new; in list_replace()
170 * list_replace_init - replace old entry by new one and initialize the old one
184 * list_swap - replace entry1 with entry2 and re-add entry1 at entry2's position
191 struct list_head *pos = entry2->prev; in list_swap()
201 * list_del_init - deletes entry from list and reinitialize it.
202 * @entry: the element to delete from the list.
204 static inline void list_del_init(struct list_head *entry) in list_del_init() argument
206 __list_del_entry(entry); in list_del_init()
207 INIT_LIST_HEAD(entry); in list_del_init()
211 * list_move - delete from one list and add as another's head
212 * @list: the entry to move
213 * @head: the head that will precede our entry
222 * list_move_tail - delete from one list and add as another's tail
223 * @list: the entry to move
224 * @head: the head that will follow our entry
234 * list_bulk_move_tail - move a subsection of a list to its tail
235 * @head: the head that will follow our entry
236 * @first: first entry to move
237 * @last: last entry to move, can be the same as first
246 first->prev->next = last->next; in list_bulk_move_tail()
247 last->next->prev = first->prev; in list_bulk_move_tail()
249 head->prev->next = first; in list_bulk_move_tail()
250 first->prev = head->prev; in list_bulk_move_tail()
252 last->next = head; in list_bulk_move_tail()
253 head->prev = last; in list_bulk_move_tail()
257 * list_is_first -- tests whether @list is the first entry in list @head
258 * @list: the entry to test
263 return list->prev == head; in list_is_first()
267 * list_is_last - tests whether @list is the last entry in list @head
268 * @list: the entry to test
273 return list->next == head; in list_is_last()
277 * list_is_head - tests whether @list is the list @head
278 * @list: the entry to test
287 * list_empty - tests whether a list is empty
292 return READ_ONCE(head->next) == head; in list_empty()
296 * list_del_init_careful - deletes entry from list and reinitialize it.
297 * @entry: the element to delete from the list.
306 static inline void list_del_init_careful(struct list_head *entry) in list_del_init_careful() argument
308 __list_del_entry(entry); in list_del_init_careful()
309 WRITE_ONCE(entry->prev, entry); in list_del_init_careful()
310 smp_store_release(&entry->next, entry); in list_del_init_careful()
314 * list_empty_careful - tests whether a list is empty and not being modified
323 * to the list entry is list_del_init(). Eg. it cannot be used
324 * if another CPU could re-list_add() it.
328 struct list_head *next = smp_load_acquire(&head->next); in list_empty_careful()
329 return list_is_head(next, head) && (next == READ_ONCE(head->prev)); in list_empty_careful()
333 * list_rotate_left - rotate the list to the left
341 first = head->next; in list_rotate_left()
347 * list_rotate_to_front() - Rotate list to specific item.
365 * list_is_singular - tests whether a list has just one entry.
370 return !list_empty(head) && (head->next == head->prev); in list_is_singular()
374 struct list_head *head, struct list_head *entry) in __list_cut_position() argument
376 struct list_head *new_first = entry->next; in __list_cut_position()
377 list->next = head->next; in __list_cut_position()
378 list->next->prev = list; in __list_cut_position()
379 list->prev = entry; in __list_cut_position()
380 entry->next = list; in __list_cut_position()
381 head->next = new_first; in __list_cut_position()
382 new_first->prev = head; in __list_cut_position()
386 * list_cut_position - cut a list into two
389 * @entry: an entry within head, could be the head itself
393 * including @entry, from @head to @list. You should
394 * pass on @entry an element you know is on @head. @list
400 struct list_head *head, struct list_head *entry) in list_cut_position() argument
404 if (list_is_singular(head) && !list_is_head(entry, head) && (entry != head->next)) in list_cut_position()
406 if (list_is_head(entry, head)) in list_cut_position()
409 __list_cut_position(list, head, entry); in list_cut_position()
413 * list_cut_before - cut a list into two, before given entry
416 * @entry: an entry within head, could be the head itself
419 * excluding @entry, from @head to @list. You should pass
420 * in @entry an element you know is on @head. @list should
423 * If @entry == @head, all entries on @head are moved to
428 struct list_head *entry) in list_cut_before() argument
430 if (head->next == entry) { in list_cut_before()
434 list->next = head->next; in list_cut_before()
435 list->next->prev = list; in list_cut_before()
436 list->prev = entry->prev; in list_cut_before()
437 list->prev->next = list; in list_cut_before()
438 head->next = entry; in list_cut_before()
439 entry->prev = head; in list_cut_before()
446 struct list_head *first = list->next; in __list_splice()
447 struct list_head *last = list->prev; in __list_splice()
449 first->prev = prev; in __list_splice()
450 prev->next = first; in __list_splice()
452 last->next = next; in __list_splice()
453 next->prev = last; in __list_splice()
457 * list_splice - join two lists, this is designed for stacks
465 __list_splice(list, head, head->next); in list_splice()
469 * list_splice_tail - join two lists, each list being a queue
477 __list_splice(list, head->prev, head); in list_splice_tail()
481 * list_splice_init - join two lists and reinitialise the emptied list.
491 __list_splice(list, head, head->next); in list_splice_init()
497 * list_splice_tail_init - join two lists and reinitialise the emptied list
508 __list_splice(list, head->prev, head); in list_splice_tail_init()
514 * list_entry - get the struct for this entry
517 * @member: the name of the list_head within the struct.
523 * list_first_entry - get the first element from a list
526 * @member: the name of the list_head within the struct.
531 list_entry((ptr)->next, type, member)
534 * list_last_entry - get the last element from a list
537 * @member: the name of the list_head within the struct.
542 list_entry((ptr)->prev, type, member)
545 * list_first_entry_or_null - get the first element from a list
548 * @member: the name of the list_head within the struct.
554 struct list_head *pos__ = READ_ONCE(head__->next); \
559 * list_next_entry - get the next element in list
561 * @member: the name of the list_head within the struct.
564 list_entry((pos)->member.next, typeof(*(pos)), member)
567 * list_next_entry_circular - get the next element in list
570 * @member: the name of the list_head within the struct.
576 (list_is_last(&(pos)->member, head) ? \
580 * list_prev_entry - get the prev element in list
582 * @member: the name of the list_head within the struct.
585 list_entry((pos)->member.prev, typeof(*(pos)), member)
588 * list_prev_entry_circular - get the prev element in list
591 * @member: the name of the list_head within the struct.
597 (list_is_first(&(pos)->member, head) ? \
601 * list_for_each - iterate over a list
606 for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next)
609 * list_for_each_rcu - Iterate over a list in an RCU-safe fashion
614 for (pos = rcu_dereference((head)->next); \
616 pos = rcu_dereference(pos->next))
619 * list_for_each_continue - continue iteration over a list
626 for (pos = pos->next; !list_is_head(pos, (head)); pos = pos->next)
629 * list_for_each_prev - iterate over a list backwards
634 for (pos = (head)->prev; !list_is_head(pos, (head)); pos = pos->prev)
637 * list_for_each_safe - iterate over a list safe against removal of list entry
643 for (pos = (head)->next, n = pos->next; \
645 pos = n, n = pos->next)
648 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
654 for (pos = (head)->prev, n = pos->prev; \
656 pos = n, n = pos->prev)
659 * list_entry_is_head - test if the entry points to the head of the list
662 * @member: the name of the list_head within the struct.
665 (&pos->member == (head))
668 * list_for_each_entry - iterate over list of given type
671 * @member: the name of the list_head within the struct.
679 * list_for_each_entry_reverse - iterate backwards over list of given type.
682 * @member: the name of the list_head within the struct.
690 * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
693 * @member: the name of the list_head within the struct.
695 * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
701 * list_for_each_entry_continue - continue iteration over list of given type
704 * @member: the name of the list_head within the struct.
715 * list_for_each_entry_continue_reverse - iterate backwards from the given point
718 * @member: the name of the list_head within the struct.
729 * list_for_each_entry_from - iterate over list of given type from the current point
732 * @member: the name of the list_head within the struct.
741 * list_for_each_entry_from_reverse - iterate backwards over list of given type
745 * @member: the name of the list_head within the struct.
754 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
758 * @member: the name of the list_head within the struct.
767 * list_for_each_entry_safe_continue - continue list iteration safe against removal
771 * @member: the name of the list_head within the struct.
774 * safe against removal of list entry.
783 * list_for_each_entry_safe_from - iterate over list from current point safe against removal
787 * @member: the name of the list_head within the struct.
790 * removal of list entry.
798 * list_for_each_entry_safe_reverse - iterate backwards over list safe against removal
802 * @member: the name of the list_head within the struct.
805 * of list entry.
814 * list_safe_reset_next - reset a stale list_for_each_entry_safe loop
817 * @member: the name of the list_head within the struct.
822 * and list_safe_reset_next is called after re-taking the lock and before
836 #define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } argument
837 #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
840 h->next = NULL; in INIT_HLIST_NODE()
841 h->pprev = NULL; in INIT_HLIST_NODE()
845 * hlist_unhashed - Has node been removed from list and reinitialized?
854 return !h->pprev; in hlist_unhashed()
858 * hlist_unhashed_lockless - Version of hlist_unhashed for lockless use
862 * to avoid potential load-tearing. The READ_ONCE() is paired with the
867 return !READ_ONCE(h->pprev); in hlist_unhashed_lockless()
871 * hlist_empty - Is the specified hlist_head structure an empty hlist?
876 return !READ_ONCE(h->first); in hlist_empty()
881 struct hlist_node *next = n->next; in __hlist_del()
882 struct hlist_node **pprev = n->pprev; in __hlist_del()
886 WRITE_ONCE(next->pprev, pprev); in __hlist_del()
890 * hlist_del - Delete the specified hlist_node from its list
899 n->next = LIST_POISON1; in hlist_del()
900 n->pprev = LIST_POISON2; in hlist_del()
904 * hlist_del_init - Delete the specified hlist_node from its list and initialize
918 * hlist_add_head - add a new entry at the beginning of the hlist
919 * @n: new entry to be added
922 * Insert a new entry after the specified head.
927 struct hlist_node *first = h->first; in hlist_add_head()
928 WRITE_ONCE(n->next, first); in hlist_add_head()
930 WRITE_ONCE(first->pprev, &n->next); in hlist_add_head()
931 WRITE_ONCE(h->first, n); in hlist_add_head()
932 WRITE_ONCE(n->pprev, &h->first); in hlist_add_head()
936 * hlist_add_before - add a new entry before the one specified
937 * @n: new entry to be added
938 * @next: hlist node to add it before, which must be non-NULL
943 WRITE_ONCE(n->pprev, next->pprev); in hlist_add_before()
944 WRITE_ONCE(n->next, next); in hlist_add_before()
945 WRITE_ONCE(next->pprev, &n->next); in hlist_add_before()
946 WRITE_ONCE(*(n->pprev), n); in hlist_add_before()
950 * hlist_add_behind - add a new entry after the one specified
951 * @n: new entry to be added
952 * @prev: hlist node to add it after, which must be non-NULL
957 WRITE_ONCE(n->next, prev->next); in hlist_add_behind()
958 WRITE_ONCE(prev->next, n); in hlist_add_behind()
959 WRITE_ONCE(n->pprev, &prev->next); in hlist_add_behind()
961 if (n->next) in hlist_add_behind()
962 WRITE_ONCE(n->next->pprev, &n->next); in hlist_add_behind()
966 * hlist_add_fake - create a fake hlist consisting of a single headless node
975 n->pprev = &n->next; in hlist_add_fake()
980 * @h: Node to check for being a self-referential fake hlist.
984 return h->pprev == &h->next; in hlist_fake()
988 * hlist_is_singular_node - is node the only element of the specified hlist?
998 return !n->next && n->pprev == &h->first; in hlist_is_singular_node()
1002 * hlist_move_list - Move an hlist
1007 * reference of the first entry if it exists.
1012 new->first = old->first; in hlist_move_list()
1013 if (new->first) in hlist_move_list()
1014 new->first->pprev = &new->first; in hlist_move_list()
1015 old->first = NULL; in hlist_move_list()
1021 for (pos = (head)->first; pos ; pos = pos->next)
1024 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
1033 * hlist_for_each_entry - iterate over list of given type
1036 * @member: the name of the hlist_node within the struct.
1039 for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
1041 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
1044 * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
1046 * @member: the name of the hlist_node within the struct.
1049 for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member);\
1051 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
1054 * hlist_for_each_entry_from - iterate over a hlist continuing from current point
1056 * @member: the name of the hlist_node within the struct.
1060 pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
1063 * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
1067 * @member: the name of the hlist_node within the struct.
1070 for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\
1071 pos && ({ n = pos->member.next; 1; }); \