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.h35
1 files changed, 15 insertions, 20 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 3a54266a1e85..cc6d2aa6b415 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -4,7 +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 8
9/* 9/*
10 * Simple doubly linked list implementation. 10 * Simple doubly linked list implementation.
@@ -367,18 +367,15 @@ static inline void list_splice_tail_init(struct list_head *list,
367 * @head: the head for your list. 367 * @head: the head for your list.
368 */ 368 */
369#define list_for_each(pos, head) \ 369#define list_for_each(pos, head) \
370 for (pos = (head)->next; prefetch(pos->next), pos != (head); \ 370 for (pos = (head)->next; pos != (head); pos = pos->next)
371 pos = pos->next)
372 371
373/** 372/**
374 * __list_for_each - iterate over a list 373 * __list_for_each - iterate over a list
375 * @pos: the &struct list_head to use as a loop cursor. 374 * @pos: the &struct list_head to use as a loop cursor.
376 * @head: the head for your list. 375 * @head: the head for your list.
377 * 376 *
378 * This variant differs from list_for_each() in that it's the 377 * This variant doesn't differ from list_for_each() any more.
379 * simplest possible list iteration code, no prefetching is done. 378 * We don't do prefetching in either case.
380 * Use this for code that knows the list to be very short (empty
381 * or 1 entry) most of the time.
382 */ 379 */
383#define __list_for_each(pos, head) \ 380#define __list_for_each(pos, head) \
384 for (pos = (head)->next; pos != (head); pos = pos->next) 381 for (pos = (head)->next; pos != (head); pos = pos->next)
@@ -389,8 +386,7 @@ static inline void list_splice_tail_init(struct list_head *list,
389 * @head: the head for your list. 386 * @head: the head for your list.
390 */ 387 */
391#define list_for_each_prev(pos, head) \ 388#define list_for_each_prev(pos, head) \
392 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ 389 for (pos = (head)->prev; pos != (head); pos = pos->prev)
393 pos = pos->prev)
394 390
395/** 391/**
396 * 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
@@ -410,7 +406,7 @@ static inline void list_splice_tail_init(struct list_head *list,
410 */ 406 */
411#define list_for_each_prev_safe(pos, n, head) \ 407#define list_for_each_prev_safe(pos, n, head) \
412 for (pos = (head)->prev, n = pos->prev; \ 408 for (pos = (head)->prev, n = pos->prev; \
413 prefetch(pos->prev), pos != (head); \ 409 pos != (head); \
414 pos = n, n = pos->prev) 410 pos = n, n = pos->prev)
415 411
416/** 412/**
@@ -421,7 +417,7 @@ static inline void list_splice_tail_init(struct list_head *list,
421 */ 417 */
422#define list_for_each_entry(pos, head, member) \ 418#define list_for_each_entry(pos, head, member) \
423 for (pos = list_entry((head)->next, typeof(*pos), member); \ 419 for (pos = list_entry((head)->next, typeof(*pos), member); \
424 prefetch(pos->member.next), &pos->member != (head); \ 420 &pos->member != (head); \
425 pos = list_entry(pos->member.next, typeof(*pos), member)) 421 pos = list_entry(pos->member.next, typeof(*pos), member))
426 422
427/** 423/**
@@ -432,7 +428,7 @@ static inline void list_splice_tail_init(struct list_head *list,
432 */ 428 */
433#define list_for_each_entry_reverse(pos, head, member) \ 429#define list_for_each_entry_reverse(pos, head, member) \
434 for (pos = list_entry((head)->prev, typeof(*pos), member); \ 430 for (pos = list_entry((head)->prev, typeof(*pos), member); \
435 prefetch(pos->member.prev), &pos->member != (head); \ 431 &pos->member != (head); \
436 pos = list_entry(pos->member.prev, typeof(*pos), member)) 432 pos = list_entry(pos->member.prev, typeof(*pos), member))
437 433
438/** 434/**
@@ -457,7 +453,7 @@ static inline void list_splice_tail_init(struct list_head *list,
457 */ 453 */
458#define list_for_each_entry_continue(pos, head, member) \ 454#define list_for_each_entry_continue(pos, head, member) \
459 for (pos = list_entry(pos->member.next, typeof(*pos), member); \ 455 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
460 prefetch(pos->member.next), &pos->member != (head); \ 456 &pos->member != (head); \
461 pos = list_entry(pos->member.next, typeof(*pos), member)) 457 pos = list_entry(pos->member.next, typeof(*pos), member))
462 458
463/** 459/**
@@ -471,7 +467,7 @@ static inline void list_splice_tail_init(struct list_head *list,
471 */ 467 */
472#define list_for_each_entry_continue_reverse(pos, head, member) \ 468#define list_for_each_entry_continue_reverse(pos, head, member) \
473 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ 469 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
474 prefetch(pos->member.prev), &pos->member != (head); \ 470 &pos->member != (head); \
475 pos = list_entry(pos->member.prev, typeof(*pos), member)) 471 pos = list_entry(pos->member.prev, typeof(*pos), member))
476 472
477/** 473/**
@@ -483,7 +479,7 @@ static inline void list_splice_tail_init(struct list_head *list,
483 * Iterate over list of given type, continuing from current position. 479 * Iterate over list of given type, continuing from current position.
484 */ 480 */
485#define list_for_each_entry_from(pos, head, member) \ 481#define list_for_each_entry_from(pos, head, member) \
486 for (; prefetch(pos->member.next), &pos->member != (head); \ 482 for (; &pos->member != (head); \
487 pos = list_entry(pos->member.next, typeof(*pos), member)) 483 pos = list_entry(pos->member.next, typeof(*pos), member))
488 484
489/** 485/**
@@ -664,8 +660,7 @@ static inline void hlist_move_list(struct hlist_head *old,
664#define hlist_entry(ptr, type, member) container_of(ptr,type,member) 660#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
665 661
666#define hlist_for_each(pos, head) \ 662#define hlist_for_each(pos, head) \
667 for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ 663 for (pos = (head)->first; pos ; pos = pos->next)
668 pos = pos->next)
669 664
670#define hlist_for_each_safe(pos, n, head) \ 665#define hlist_for_each_safe(pos, n, head) \
671 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ 666 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
@@ -680,7 +675,7 @@ static inline void hlist_move_list(struct hlist_head *old,
680 */ 675 */
681#define hlist_for_each_entry(tpos, pos, head, member) \ 676#define hlist_for_each_entry(tpos, pos, head, member) \
682 for (pos = (head)->first; \ 677 for (pos = (head)->first; \
683 pos && ({ prefetch(pos->next); 1;}) && \ 678 pos && \
684 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 679 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
685 pos = pos->next) 680 pos = pos->next)
686 681
@@ -692,7 +687,7 @@ static inline void hlist_move_list(struct hlist_head *old,
692 */ 687 */
693#define hlist_for_each_entry_continue(tpos, pos, member) \ 688#define hlist_for_each_entry_continue(tpos, pos, member) \
694 for (pos = (pos)->next; \ 689 for (pos = (pos)->next; \
695 pos && ({ prefetch(pos->next); 1;}) && \ 690 pos && \
696 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 691 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
697 pos = pos->next) 692 pos = pos->next)
698 693
@@ -703,7 +698,7 @@ static inline void hlist_move_list(struct hlist_head *old,
703 * @member: the name of the hlist_node within the struct. 698 * @member: the name of the hlist_node within the struct.
704 */ 699 */
705#define hlist_for_each_entry_from(tpos, pos, member) \ 700#define hlist_for_each_entry_from(tpos, pos, member) \
706 for (; pos && ({ prefetch(pos->next); 1;}) && \ 701 for (; pos && \
707 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 702 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
708 pos = pos->next) 703 pos = pos->next)
709 704