aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/list.h')
-rw-r--r--include/linux/list.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 8392884a2977..d167b5d7c0ac 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -1,6 +1,7 @@
1#ifndef _LINUX_LIST_H 1#ifndef _LINUX_LIST_H
2#define _LINUX_LIST_H 2#define _LINUX_LIST_H
3 3
4#include <linux/types.h>
4#include <linux/stddef.h> 5#include <linux/stddef.h>
5#include <linux/poison.h> 6#include <linux/poison.h>
6#include <linux/prefetch.h> 7#include <linux/prefetch.h>
@@ -16,10 +17,6 @@
16 * using the generic single-entry routines. 17 * using the generic single-entry routines.
17 */ 18 */
18 19
19struct list_head {
20 struct list_head *next, *prev;
21};
22
23#define LIST_HEAD_INIT(name) { &(name), &(name) } 20#define LIST_HEAD_INIT(name) { &(name), &(name) }
24 21
25#define LIST_HEAD(name) \ 22#define LIST_HEAD(name) \
@@ -544,6 +541,21 @@ static inline void list_splice_tail_init(struct list_head *list,
544 &pos->member != (head); \ 541 &pos->member != (head); \
545 pos = n, n = list_entry(n->member.prev, typeof(*n), member)) 542 pos = n, n = list_entry(n->member.prev, typeof(*n), member))
546 543
544/**
545 * list_safe_reset_next - reset a stale list_for_each_entry_safe loop
546 * @pos: the loop cursor used in the list_for_each_entry_safe loop
547 * @n: temporary storage used in list_for_each_entry_safe
548 * @member: the name of the list_struct within the struct.
549 *
550 * list_safe_reset_next is not safe to use in general if the list may be
551 * modified concurrently (eg. the lock is dropped in the loop body). An
552 * exception to this is if the cursor element (pos) is pinned in the list,
553 * and list_safe_reset_next is called after re-taking the lock and before
554 * completing the current iteration of the loop body.
555 */
556#define list_safe_reset_next(pos, n, member) \
557 n = list_entry(pos->member.next, typeof(*pos), member)
558
547/* 559/*
548 * Double linked lists with a single pointer list head. 560 * Double linked lists with a single pointer list head.
549 * Mostly useful for hash tables where the two pointer list head is 561 * Mostly useful for hash tables where the two pointer list head is
@@ -551,14 +563,6 @@ static inline void list_splice_tail_init(struct list_head *list,
551 * You lose the ability to access the tail in O(1). 563 * You lose the ability to access the tail in O(1).
552 */ 564 */
553 565
554struct hlist_head {
555 struct hlist_node *first;
556};
557
558struct hlist_node {
559 struct hlist_node *next, **pprev;
560};
561
562#define HLIST_HEAD_INIT { .first = NULL } 566#define HLIST_HEAD_INIT { .first = NULL }
563#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } 567#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
564#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) 568#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)