Lines 1-8
Link Here
|
1 |
#ifndef _LINUX_LIST_H |
1 |
#ifndef _LINUX_LIST_H |
2 |
#define _LINUX_LIST_H |
2 |
#define _LINUX_LIST_H |
3 |
|
3 |
|
4 |
#ifdef __KERNEL__ |
|
|
5 |
|
6 |
#include <linux/stddef.h> |
4 |
#include <linux/stddef.h> |
7 |
#include <linux/prefetch.h> |
5 |
#include <linux/prefetch.h> |
8 |
#include <asm/system.h> |
6 |
#include <asm/system.h> |
Lines 38-57
Link Here
|
38 |
(ptr)->next = (ptr); (ptr)->prev = (ptr); \ |
36 |
(ptr)->next = (ptr); (ptr)->prev = (ptr); \ |
39 |
} while (0) |
37 |
} while (0) |
40 |
|
38 |
|
|
|
39 |
#if defined(__KERNEL__) || defined(__LINUX_KEYBOARD_H) |
40 |
|
41 |
/* |
41 |
/* |
42 |
* Insert a new entry between two known consecutive entries. |
42 |
* Insert a new entry between two known consecutive entries. |
43 |
* |
43 |
* |
44 |
* This is only for internal list manipulation where we know |
44 |
* This is only for internal list manipulation where we know |
45 |
* the prev/next entries already! |
45 |
* the prev/next entries already! |
46 |
*/ |
46 |
*/ |
47 |
static inline void __list_add(struct list_head *new, |
47 |
static inline void __list_add(struct list_head *_new, |
48 |
struct list_head *prev, |
48 |
struct list_head *prev, |
49 |
struct list_head *next) |
49 |
struct list_head *next) |
50 |
{ |
50 |
{ |
51 |
next->prev = new; |
51 |
next->prev = _new; |
52 |
new->next = next; |
52 |
_new->next = next; |
53 |
new->prev = prev; |
53 |
_new->prev = prev; |
54 |
prev->next = new; |
54 |
prev->next = _new; |
55 |
} |
55 |
} |
56 |
|
56 |
|
57 |
/** |
57 |
/** |
Lines 62-70
Link Here
|
62 |
* Insert a new entry after the specified head. |
62 |
* Insert a new entry after the specified head. |
63 |
* This is good for implementing stacks. |
63 |
* This is good for implementing stacks. |
64 |
*/ |
64 |
*/ |
65 |
static inline void list_add(struct list_head *new, struct list_head *head) |
65 |
static inline void list_add(struct list_head *_new, struct list_head *head) |
66 |
{ |
66 |
{ |
67 |
__list_add(new, head, head->next); |
67 |
__list_add(_new, head, head->next); |
68 |
} |
68 |
} |
69 |
|
69 |
|
70 |
/** |
70 |
/** |
Lines 75-83
Link Here
|
75 |
* Insert a new entry before the specified head. |
75 |
* Insert a new entry before the specified head. |
76 |
* This is useful for implementing queues. |
76 |
* This is useful for implementing queues. |
77 |
*/ |
77 |
*/ |
78 |
static inline void list_add_tail(struct list_head *new, struct list_head *head) |
78 |
static inline void list_add_tail(struct list_head *_new, struct list_head *head) |
79 |
{ |
79 |
{ |
80 |
__list_add(new, head->prev, head); |
80 |
__list_add(_new, head->prev, head); |
81 |
} |
81 |
} |
82 |
|
82 |
|
83 |
/* |
83 |
/* |
Lines 86-99
Link Here
|
86 |
* This is only for internal list manipulation where we know |
86 |
* This is only for internal list manipulation where we know |
87 |
* the prev/next entries already! |
87 |
* the prev/next entries already! |
88 |
*/ |
88 |
*/ |
89 |
static inline void __list_add_rcu(struct list_head * new, |
89 |
static inline void __list_add_rcu(struct list_head * _new, |
90 |
struct list_head * prev, struct list_head * next) |
90 |
struct list_head * prev, struct list_head * next) |
91 |
{ |
91 |
{ |
92 |
new->next = next; |
92 |
_new->next = next; |
93 |
new->prev = prev; |
93 |
_new->prev = prev; |
94 |
smp_wmb(); |
94 |
smp_wmb(); |
95 |
next->prev = new; |
95 |
next->prev = _new; |
96 |
prev->next = new; |
96 |
prev->next = _new; |
97 |
} |
97 |
} |
98 |
|
98 |
|
99 |
/** |
99 |
/** |
Lines 112-120
Link Here
|
112 |
* the _rcu list-traversal primitives, such as |
112 |
* the _rcu list-traversal primitives, such as |
113 |
* list_for_each_entry_rcu(). |
113 |
* list_for_each_entry_rcu(). |
114 |
*/ |
114 |
*/ |
115 |
static inline void list_add_rcu(struct list_head *new, struct list_head *head) |
115 |
static inline void list_add_rcu(struct list_head *_new, struct list_head *head) |
116 |
{ |
116 |
{ |
117 |
__list_add_rcu(new, head, head->next); |
117 |
__list_add_rcu(_new, head, head->next); |
118 |
} |
118 |
} |
119 |
|
119 |
|
120 |
/** |
120 |
/** |
Lines 133-142
Link Here
|
133 |
* the _rcu list-traversal primitives, such as |
133 |
* the _rcu list-traversal primitives, such as |
134 |
* list_for_each_entry_rcu(). |
134 |
* list_for_each_entry_rcu(). |
135 |
*/ |
135 |
*/ |
136 |
static inline void list_add_tail_rcu(struct list_head *new, |
136 |
static inline void list_add_tail_rcu(struct list_head *_new, |
137 |
struct list_head *head) |
137 |
struct list_head *head) |
138 |
{ |
138 |
{ |
139 |
__list_add_rcu(new, head->prev, head); |
139 |
__list_add_rcu(_new, head->prev, head); |
140 |
} |
140 |
} |
141 |
|
141 |
|
142 |
/* |
142 |
/* |
Lines 161-168
Link Here
|
161 |
static inline void list_del(struct list_head *entry) |
161 |
static inline void list_del(struct list_head *entry) |
162 |
{ |
162 |
{ |
163 |
__list_del(entry->prev, entry->next); |
163 |
__list_del(entry->prev, entry->next); |
164 |
entry->next = LIST_POISON1; |
164 |
entry->next = __cast__(list_head*) LIST_POISON1; |
165 |
entry->prev = LIST_POISON2; |
165 |
entry->prev = __cast__(list_head*) LIST_POISON2; |
166 |
} |
166 |
} |
167 |
|
167 |
|
168 |
/** |
168 |
/** |
Lines 192-198
Link Here
|
192 |
static inline void list_del_rcu(struct list_head *entry) |
192 |
static inline void list_del_rcu(struct list_head *entry) |
193 |
{ |
193 |
{ |
194 |
__list_del(entry->prev, entry->next); |
194 |
__list_del(entry->prev, entry->next); |
195 |
entry->prev = LIST_POISON2; |
195 |
entry->prev = __cast__(list_head*) LIST_POISON2; |
196 |
} |
196 |
} |
197 |
|
197 |
|
198 |
/* |
198 |
/* |
Lines 513-520
Link Here
|
513 |
|
513 |
|
514 |
static inline void __hlist_del(struct hlist_node *n) |
514 |
static inline void __hlist_del(struct hlist_node *n) |
515 |
{ |
515 |
{ |
516 |
struct hlist_node *next = n->next; |
516 |
struct hlist_node *next = __cast__(hlist_node*) n->next; |
517 |
struct hlist_node **pprev = n->pprev; |
517 |
struct hlist_node **pprev = __cast__(hlist_node**) n->pprev; |
518 |
*pprev = next; |
518 |
*pprev = next; |
519 |
if (next) |
519 |
if (next) |
520 |
next->pprev = pprev; |
520 |
next->pprev = pprev; |
Lines 523-530
Link Here
|
523 |
static inline void hlist_del(struct hlist_node *n) |
523 |
static inline void hlist_del(struct hlist_node *n) |
524 |
{ |
524 |
{ |
525 |
__hlist_del(n); |
525 |
__hlist_del(n); |
526 |
n->next = LIST_POISON1; |
526 |
n->next = __cast__(hlist_node*) LIST_POISON1; |
527 |
n->pprev = LIST_POISON2; |
527 |
n->pprev = __cast__(hlist_node**) LIST_POISON2; |
528 |
} |
528 |
} |
529 |
|
529 |
|
530 |
/** |
530 |
/** |
Lines 549-555
Link Here
|
549 |
static inline void hlist_del_rcu(struct hlist_node *n) |
549 |
static inline void hlist_del_rcu(struct hlist_node *n) |
550 |
{ |
550 |
{ |
551 |
__hlist_del(n); |
551 |
__hlist_del(n); |
552 |
n->pprev = LIST_POISON2; |
552 |
n->pprev = __cast__(hlist_node**) LIST_POISON2; |
553 |
} |
553 |
} |
554 |
|
554 |
|
555 |
static inline void hlist_del_init(struct hlist_node *n) |
555 |
static inline void hlist_del_init(struct hlist_node *n) |
Lines 700-707
Link Here
|
700 |
pos && ({ prefetch(pos->next); 1;}) && \ |
700 |
pos && ({ prefetch(pos->next); 1;}) && \ |
701 |
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
701 |
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
702 |
pos = rcu_dereference(pos->next)) |
702 |
pos = rcu_dereference(pos->next)) |
703 |
|
703 |
#endif |
704 |
#else |
|
|
705 |
#warning "don't include kernel headers in userspace" |
706 |
#endif /* __KERNEL__ */ |
707 |
#endif |
704 |
#endif |