aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/list.h
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/linux/list.h
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'include/linux/list.h')
-rw-r--r--include/linux/list.h54
1 files changed, 30 insertions, 24 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index d167b5d7c0ac..cc6d2aa6b415 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -4,8 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/stddef.h> 5#include <linux/stddef.h>
6#include <linux/poison.h> 6#include <linux/poison.h>
7#include <linux/prefetch.h> 7#include <linux/const.h>
8#include <asm/system.h>
9 8
10/* 9/*
11 * Simple doubly linked list implementation. 10 * Simple doubly linked list implementation.
@@ -97,6 +96,11 @@ static inline void __list_del(struct list_head * prev, struct list_head * next)
97 * in an undefined state. 96 * in an undefined state.
98 */ 97 */
99#ifndef CONFIG_DEBUG_LIST 98#ifndef CONFIG_DEBUG_LIST
99static inline void __list_del_entry(struct list_head *entry)
100{
101 __list_del(entry->prev, entry->next);
102}
103
100static inline void list_del(struct list_head *entry) 104static inline void list_del(struct list_head *entry)
101{ 105{
102 __list_del(entry->prev, entry->next); 106 __list_del(entry->prev, entry->next);
@@ -104,6 +108,7 @@ static inline void list_del(struct list_head *entry)
104 entry->prev = LIST_POISON2; 108 entry->prev = LIST_POISON2;
105} 109}
106#else 110#else
111extern void __list_del_entry(struct list_head *entry);
107extern void list_del(struct list_head *entry); 112extern void list_del(struct list_head *entry);
108#endif 113#endif
109 114
@@ -136,7 +141,7 @@ static inline void list_replace_init(struct list_head *old,
136 */ 141 */
137static inline void list_del_init(struct list_head *entry) 142static inline void list_del_init(struct list_head *entry)
138{ 143{
139 __list_del(entry->prev, entry->next); 144 __list_del_entry(entry);
140 INIT_LIST_HEAD(entry); 145 INIT_LIST_HEAD(entry);
141} 146}
142 147
@@ -147,7 +152,7 @@ static inline void list_del_init(struct list_head *entry)
147 */ 152 */
148static inline void list_move(struct list_head *list, struct list_head *head) 153static inline void list_move(struct list_head *list, struct list_head *head)
149{ 154{
150 __list_del(list->prev, list->next); 155 __list_del_entry(list);
151 list_add(list, head); 156 list_add(list, head);
152} 157}
153 158
@@ -159,7 +164,7 @@ static inline void list_move(struct list_head *list, struct list_head *head)
159static inline void list_move_tail(struct list_head *list, 164static inline void list_move_tail(struct list_head *list,
160 struct list_head *head) 165 struct list_head *head)
161{ 166{
162 __list_del(list->prev, list->next); 167 __list_del_entry(list);
163 list_add_tail(list, head); 168 list_add_tail(list, head);
164} 169}
165 170
@@ -362,18 +367,15 @@ static inline void list_splice_tail_init(struct list_head *list,
362 * @head: the head for your list. 367 * @head: the head for your list.
363 */ 368 */
364#define list_for_each(pos, head) \ 369#define list_for_each(pos, head) \
365 for (pos = (head)->next; prefetch(pos->next), pos != (head); \ 370 for (pos = (head)->next; pos != (head); pos = pos->next)
366 pos = pos->next)
367 371
368/** 372/**
369 * __list_for_each - iterate over a list 373 * __list_for_each - iterate over a list
370 * @pos: the &struct list_head to use as a loop cursor. 374 * @pos: the &struct list_head to use as a loop cursor.
371 * @head: the head for your list. 375 * @head: the head for your list.
372 * 376 *
373 * This variant differs from list_for_each() in that it's the 377 * This variant doesn't differ from list_for_each() any more.
374 * simplest possible list iteration code, no prefetching is done. 378 * We don't do prefetching in either case.
375 * Use this for code that knows the list to be very short (empty
376 * or 1 entry) most of the time.
377 */ 379 */
378#define __list_for_each(pos, head) \ 380#define __list_for_each(pos, head) \
379 for (pos = (head)->next; pos != (head); pos = pos->next) 381 for (pos = (head)->next; pos != (head); pos = pos->next)
@@ -384,8 +386,7 @@ static inline void list_splice_tail_init(struct list_head *list,
384 * @head: the head for your list. 386 * @head: the head for your list.
385 */ 387 */
386#define list_for_each_prev(pos, head) \ 388#define list_for_each_prev(pos, head) \
387 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ 389 for (pos = (head)->prev; pos != (head); pos = pos->prev)
388 pos = pos->prev)
389 390
390/** 391/**
391 * list_for_each_safe - iterate over a list safe against removal of list entry 392 * list_for_each_safe - iterate over a list safe against removal of list entry
@@ -405,7 +406,7 @@ static inline void list_splice_tail_init(struct list_head *list,
405 */ 406 */
406#define list_for_each_prev_safe(pos, n, head) \ 407#define list_for_each_prev_safe(pos, n, head) \
407 for (pos = (head)->prev, n = pos->prev; \ 408 for (pos = (head)->prev, n = pos->prev; \
408 prefetch(pos->prev), pos != (head); \ 409 pos != (head); \
409 pos = n, n = pos->prev) 410 pos = n, n = pos->prev)
410 411
411/** 412/**
@@ -416,7 +417,7 @@ static inline void list_splice_tail_init(struct list_head *list,
416 */ 417 */
417#define list_for_each_entry(pos, head, member) \ 418#define list_for_each_entry(pos, head, member) \
418 for (pos = list_entry((head)->next, typeof(*pos), member); \ 419 for (pos = list_entry((head)->next, typeof(*pos), member); \
419 prefetch(pos->member.next), &pos->member != (head); \ 420 &pos->member != (head); \
420 pos = list_entry(pos->member.next, typeof(*pos), member)) 421 pos = list_entry(pos->member.next, typeof(*pos), member))
421 422
422/** 423/**
@@ -427,7 +428,7 @@ static inline void list_splice_tail_init(struct list_head *list,
427 */ 428 */
428#define list_for_each_entry_reverse(pos, head, member) \ 429#define list_for_each_entry_reverse(pos, head, member) \
429 for (pos = list_entry((head)->prev, typeof(*pos), member); \ 430 for (pos = list_entry((head)->prev, typeof(*pos), member); \
430 prefetch(pos->member.prev), &pos->member != (head); \ 431 &pos->member != (head); \
431 pos = list_entry(pos->member.prev, typeof(*pos), member)) 432 pos = list_entry(pos->member.prev, typeof(*pos), member))
432 433
433/** 434/**
@@ -452,7 +453,7 @@ static inline void list_splice_tail_init(struct list_head *list,
452 */ 453 */
453#define list_for_each_entry_continue(pos, head, member) \ 454#define list_for_each_entry_continue(pos, head, member) \
454 for (pos = list_entry(pos->member.next, typeof(*pos), member); \ 455 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
455 prefetch(pos->member.next), &pos->member != (head); \ 456 &pos->member != (head); \
456 pos = list_entry(pos->member.next, typeof(*pos), member)) 457 pos = list_entry(pos->member.next, typeof(*pos), member))
457 458
458/** 459/**
@@ -466,7 +467,7 @@ static inline void list_splice_tail_init(struct list_head *list,
466 */ 467 */
467#define list_for_each_entry_continue_reverse(pos, head, member) \ 468#define list_for_each_entry_continue_reverse(pos, head, member) \
468 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ 469 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
469 prefetch(pos->member.prev), &pos->member != (head); \ 470 &pos->member != (head); \
470 pos = list_entry(pos->member.prev, typeof(*pos), member)) 471 pos = list_entry(pos->member.prev, typeof(*pos), member))
471 472
472/** 473/**
@@ -478,7 +479,7 @@ static inline void list_splice_tail_init(struct list_head *list,
478 * Iterate over list of given type, continuing from current position. 479 * Iterate over list of given type, continuing from current position.
479 */ 480 */
480#define list_for_each_entry_from(pos, head, member) \ 481#define list_for_each_entry_from(pos, head, member) \
481 for (; prefetch(pos->member.next), &pos->member != (head); \ 482 for (; &pos->member != (head); \
482 pos = list_entry(pos->member.next, typeof(*pos), member)) 483 pos = list_entry(pos->member.next, typeof(*pos), member))
483 484
484/** 485/**
@@ -637,6 +638,12 @@ static inline void hlist_add_after(struct hlist_node *n,
637 next->next->pprev = &next->next; 638 next->next->pprev = &next->next;
638} 639}
639 640
641/* after that we'll appear to be on some hlist and hlist_del will work */
642static inline void hlist_add_fake(struct hlist_node *n)
643{
644 n->pprev = &n->next;
645}
646
640/* 647/*
641 * Move a list from one list head to another. Fixup the pprev 648 * Move a list from one list head to another. Fixup the pprev
642 * reference of the first entry if it exists. 649 * reference of the first entry if it exists.
@@ -653,8 +660,7 @@ static inline void hlist_move_list(struct hlist_head *old,
653#define hlist_entry(ptr, type, member) container_of(ptr,type,member) 660#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
654 661
655#define hlist_for_each(pos, head) \ 662#define hlist_for_each(pos, head) \
656 for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ 663 for (pos = (head)->first; pos ; pos = pos->next)
657 pos = pos->next)
658 664
659#define hlist_for_each_safe(pos, n, head) \ 665#define hlist_for_each_safe(pos, n, head) \
660 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ 666 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
@@ -669,7 +675,7 @@ static inline void hlist_move_list(struct hlist_head *old,
669 */ 675 */
670#define hlist_for_each_entry(tpos, pos, head, member) \ 676#define hlist_for_each_entry(tpos, pos, head, member) \
671 for (pos = (head)->first; \ 677 for (pos = (head)->first; \
672 pos && ({ prefetch(pos->next); 1;}) && \ 678 pos && \
673 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 679 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
674 pos = pos->next) 680 pos = pos->next)
675 681
@@ -681,7 +687,7 @@ static inline void hlist_move_list(struct hlist_head *old,
681 */ 687 */
682#define hlist_for_each_entry_continue(tpos, pos, member) \ 688#define hlist_for_each_entry_continue(tpos, pos, member) \
683 for (pos = (pos)->next; \ 689 for (pos = (pos)->next; \
684 pos && ({ prefetch(pos->next); 1;}) && \ 690 pos && \
685 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 691 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
686 pos = pos->next) 692 pos = pos->next)
687 693
@@ -692,7 +698,7 @@ static inline void hlist_move_list(struct hlist_head *old,
692 * @member: the name of the hlist_node within the struct. 698 * @member: the name of the hlist_node within the struct.
693 */ 699 */
694#define hlist_for_each_entry_from(tpos, pos, member) \ 700#define hlist_for_each_entry_from(tpos, pos, member) \
695 for (; pos && ({ prefetch(pos->next); 1;}) && \ 701 for (; pos && \
696 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 702 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
697 pos = pos->next) 703 pos = pos->next)
698 704