Rev 3297 | Rev 5270 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3297 | Rev 4065 | ||
---|---|---|---|
Line 359... | Line 359... | ||
359 | */ |
359 | */ |
360 | #define list_first_entry(ptr, type, member) \ |
360 | #define list_first_entry(ptr, type, member) \ |
361 | list_entry((ptr)->next, type, member) |
361 | list_entry((ptr)->next, type, member) |
Line 362... | Line 362... | ||
362 | 362 | ||
363 | /** |
363 | /** |
364 | * list_for_each - iterate over a list |
364 | * list_first_entry_or_null - get the first element from a list |
365 | * @pos: the &struct list_head to use as a loop cursor. |
365 | * @ptr: the list head to take the element from. |
- | 366 | * @type: the type of the struct this is embedded in. |
|
- | 367 | * @member: the name of the list_struct within the struct. |
|
- | 368 | * |
|
366 | * @head: the head for your list. |
369 | * Note that if the list is empty, it returns NULL. |
367 | */ |
370 | */ |
368 | #define list_for_each(pos, head) \ |
371 | #define list_first_entry_or_null(ptr, type, member) \ |
Line 369... | Line 372... | ||
369 | for (pos = (head)->next; pos != (head); pos = pos->next) |
372 | (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) |
370 | 373 | ||
371 | /** |
374 | /** |
372 | * __list_for_each - iterate over a list |
375 | * list_for_each - iterate over a list |
373 | * @pos: the &struct list_head to use as a loop cursor. |
- | |
374 | * @head: the head for your list. |
- | |
375 | * |
- | |
376 | * This variant doesn't differ from list_for_each() any more. |
376 | * @pos: the &struct list_head to use as a loop cursor. |
377 | * We don't do prefetching in either case. |
377 | * @head: the head for your list. |
378 | */ |
378 | */ |
Line 379... | Line 379... | ||
379 | #define __list_for_each(pos, head) \ |
379 | #define list_for_each(pos, head) \ |
380 | for (pos = (head)->next; pos != (head); pos = pos->next) |
380 | for (pos = (head)->next; pos != (head); pos = pos->next) |
381 | 381 | ||
Line 663... | Line 663... | ||
663 | 663 | ||
664 | #define hlist_for_each_safe(pos, n, head) \ |
664 | #define hlist_for_each_safe(pos, n, head) \ |
665 | for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ |
665 | for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ |
Line -... | Line 666... | ||
- | 666 | pos = n) |
|
- | 667 | ||
- | 668 | #define hlist_entry_safe(ptr, type, member) \ |
|
- | 669 | ({ typeof(ptr) ____ptr = (ptr); \ |
|
- | 670 | ____ptr ? hlist_entry(____ptr, type, member) : NULL; \ |
|
666 | pos = n) |
671 | }) |
667 | 672 | ||
668 | /** |
673 | /** |
669 | * hlist_for_each_entry - iterate over list of given type |
- | |
670 | * @tpos: the type * to use as a loop cursor. |
674 | * hlist_for_each_entry - iterate over list of given type |
671 | * @pos: the &struct hlist_node to use as a loop cursor. |
675 | * @pos: the type * to use as a loop cursor. |
672 | * @head: the head for your list. |
676 | * @head: the head for your list. |
673 | * @member: the name of the hlist_node within the struct. |
677 | * @member: the name of the hlist_node within the struct. |
674 | */ |
678 | */ |
675 | #define hlist_for_each_entry(tpos, pos, head, member) \ |
679 | #define hlist_for_each_entry(pos, head, member) \ |
676 | for (pos = (head)->first; \ |
680 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ |
677 | pos && \ |
- | |
Line 678... | Line 681... | ||
678 | ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
681 | pos; \ |
679 | pos = pos->next) |
682 | pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) |
680 | 683 | ||
681 | /** |
- | |
682 | * hlist_for_each_entry_continue - iterate over a hlist continuing after current point |
684 | /** |
683 | * @tpos: the type * to use as a loop cursor. |
685 | * hlist_for_each_entry_continue - iterate over a hlist continuing after current point |
684 | * @pos: the &struct hlist_node to use as a loop cursor. |
686 | * @pos: the type * to use as a loop cursor. |
685 | * @member: the name of the hlist_node within the struct. |
687 | * @member: the name of the hlist_node within the struct. |
686 | */ |
688 | */ |
687 | #define hlist_for_each_entry_continue(tpos, pos, member) \ |
689 | #define hlist_for_each_entry_continue(pos, member) \ |
688 | for (pos = (pos)->next; \ |
- | |
Line 689... | Line 690... | ||
689 | pos && \ |
690 | for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member);\ |
690 | ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
691 | pos; \ |
691 | pos = pos->next) |
692 | pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) |
692 | - | ||
693 | /** |
693 | |
694 | * hlist_for_each_entry_from - iterate over a hlist continuing from current point |
694 | /** |
695 | * @tpos: the type * to use as a loop cursor. |
695 | * hlist_for_each_entry_from - iterate over a hlist continuing from current point |
696 | * @pos: the &struct hlist_node to use as a loop cursor. |
696 | * @pos: the type * to use as a loop cursor. |
697 | * @member: the name of the hlist_node within the struct. |
697 | * @member: the name of the hlist_node within the struct. |
698 | */ |
- | |
Line 699... | Line 698... | ||
699 | #define hlist_for_each_entry_from(tpos, pos, member) \ |
698 | */ |
700 | for (; pos && \ |
699 | #define hlist_for_each_entry_from(pos, member) \ |
701 | ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
700 | for (; pos; \ |
702 | pos = pos->next) |
- | |
703 | 701 | pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) |
|
704 | /** |
702 | |
705 | * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry |
703 | /** |
706 | * @tpos: the type * to use as a loop cursor. |
704 | * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry |
707 | * @pos: the &struct hlist_node to use as a loop cursor. |
705 | * @pos: the type * to use as a loop cursor. |
708 | * @n: another &struct hlist_node to use as temporary storage |
706 | * @n: another &struct hlist_node to use as temporary storage |
709 | * @head: the head for your list. |
707 | * @head: the head for your list. |
710 | * @member: the name of the hlist_node within the struct. |
708 | * @member: the name of the hlist_node within the struct. |
711 | */ |
- | |
Line 712... | Line 709... | ||
712 | #define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ |
709 | */ |