Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef _LINUX_LIST_H
  2. #define _LINUX_LIST_H
  3.  
  4. //#include <linux/stddef.h>
  5. //#include <linux/poison.h>
  6. //#include <linux/prefetch.h>
  7. //#include <asm/system.h>
  8.  
  9. /*
  10.  * Simple doubly linked list implementation.
  11.  *
  12.  * Some of the internal functions ("__xxx") are useful when
  13.  * manipulating whole lists rather than single entries, as
  14.  * sometimes we already know the next/prev entries and we can
  15.  * generate better code by using them directly rather than
  16.  * using the generic single-entry routines.
  17.  */
  18.  
  19. #define LIST_POISON1   ((struct list_head*)0xFFFF0100)
  20. #define LIST_POISON2   ((struct list_head*)0xFFFF0200)
  21.  
  22. #define prefetch(x) __builtin_prefetch(x)
  23.  
  24. struct list_head {
  25.         struct list_head *next, *prev;
  26. };
  27.  
  28. #define LIST_HEAD_INIT(name) { &(name), &(name) }
  29.  
  30. #define LIST_HEAD(name) \
  31.         struct list_head name = LIST_HEAD_INIT(name)
  32.  
  33. static inline void INIT_LIST_HEAD(struct list_head *list)
  34. {
  35.         list->next = list;
  36.         list->prev = list;
  37. }
  38.  
  39. /*
  40.  * Insert a new entry between two known consecutive entries.
  41.  *
  42.  * This is only for internal list manipulation where we know
  43.  * the prev/next entries already!
  44.  */
  45. #ifndef CONFIG_DEBUG_LIST
  46. static inline void __list_add(struct list_head *new,
  47.                               struct list_head *prev,
  48.                               struct list_head *next)
  49. {
  50.         next->prev = new;
  51.         new->next = next;
  52.         new->prev = prev;
  53.         prev->next = new;
  54. }
  55. #else
  56. extern void __list_add(struct list_head *new,
  57.                               struct list_head *prev,
  58.                               struct list_head *next);
  59. #endif
  60.  
  61. /**
  62.  * list_add - add a new entry
  63.  * @new: new entry to be added
  64.  * @head: list head to add it after
  65.  *
  66.  * Insert a new entry after the specified head.
  67.  * This is good for implementing stacks.
  68.  */
  69. static inline void list_add(struct list_head *new, struct list_head *head)
  70. {
  71.         __list_add(new, head, head->next);
  72. }
  73.  
  74.  
  75. /**
  76.  * list_add_tail - add a new entry
  77.  * @new: new entry to be added
  78.  * @head: list head to add it before
  79.  *
  80.  * Insert a new entry before the specified head.
  81.  * This is useful for implementing queues.
  82.  */
  83. static inline void list_add_tail(struct list_head *new, struct list_head *head)
  84. {
  85.         __list_add(new, head->prev, head);
  86. }
  87.  
  88. /*
  89.  * Delete a list entry by making the prev/next entries
  90.  * point to each other.
  91.  *
  92.  * This is only for internal list manipulation where we know
  93.  * the prev/next entries already!
  94.  */
  95. static inline void __list_del(struct list_head * prev, struct list_head * next)
  96. {
  97.         next->prev = prev;
  98.         prev->next = next;
  99. }
  100.  
  101. /**
  102.  * list_del - deletes entry from list.
  103.  * @entry: the element to delete from the list.
  104.  * Note: list_empty() on entry does not return true after this, the entry is
  105.  * in an undefined state.
  106.  */
  107. #ifndef CONFIG_DEBUG_LIST
  108. static inline void list_del(struct list_head *entry)
  109. {
  110.         __list_del(entry->prev, entry->next);
  111.         entry->next = LIST_POISON1;
  112.         entry->prev = LIST_POISON2;
  113. }
  114. #else
  115. extern void list_del(struct list_head *entry);
  116. #endif
  117.  
  118. /**
  119.  * list_replace - replace old entry by new one
  120.  * @old : the element to be replaced
  121.  * @new : the new element to insert
  122.  *
  123.  * If @old was empty, it will be overwritten.
  124.  */
  125. static inline void list_replace(struct list_head *old,
  126.                                 struct list_head *new)
  127. {
  128.         new->next = old->next;
  129.         new->next->prev = new;
  130.         new->prev = old->prev;
  131.         new->prev->next = new;
  132. }
  133.  
  134. static inline void list_replace_init(struct list_head *old,
  135.                                         struct list_head *new)
  136. {
  137.         list_replace(old, new);
  138.         INIT_LIST_HEAD(old);
  139. }
  140.  
  141. /**
  142.  * list_del_init - deletes entry from list and reinitialize it.
  143.  * @entry: the element to delete from the list.
  144.  */
  145. static inline void list_del_init(struct list_head *entry)
  146. {
  147.         __list_del(entry->prev, entry->next);
  148.         INIT_LIST_HEAD(entry);
  149. }
  150.  
  151. /**
  152.  * list_move - delete from one list and add as another's head
  153.  * @list: the entry to move
  154.  * @head: the head that will precede our entry
  155.  */
  156. static inline void list_move(struct list_head *list, struct list_head *head)
  157. {
  158.         __list_del(list->prev, list->next);
  159.         list_add(list, head);
  160. }
  161.  
  162. /**
  163.  * list_move_tail - delete from one list and add as another's tail
  164.  * @list: the entry to move
  165.  * @head: the head that will follow our entry
  166.  */
  167. static inline void list_move_tail(struct list_head *list,
  168.                                   struct list_head *head)
  169. {
  170.         __list_del(list->prev, list->next);
  171.         list_add_tail(list, head);
  172. }
  173.  
  174. /**
  175.  * list_is_last - tests whether @list is the last entry in list @head
  176.  * @list: the entry to test
  177.  * @head: the head of the list
  178.  */
  179. static inline int list_is_last(const struct list_head *list,
  180.                                 const struct list_head *head)
  181. {
  182.         return list->next == head;
  183. }
  184.  
  185. /**
  186.  * list_empty - tests whether a list is empty
  187.  * @head: the list to test.
  188.  */
  189. static inline int list_empty(const struct list_head *head)
  190. {
  191.         return head->next == head;
  192. }
  193.  
  194. /**
  195.  * list_empty_careful - tests whether a list is empty and not being modified
  196.  * @head: the list to test
  197.  *
  198.  * Description:
  199.  * tests whether a list is empty _and_ checks that no other CPU might be
  200.  * in the process of modifying either member (next or prev)
  201.  *
  202.  * NOTE: using list_empty_careful() without synchronization
  203.  * can only be safe if the only activity that can happen
  204.  * to the list entry is list_del_init(). Eg. it cannot be used
  205.  * if another CPU could re-list_add() it.
  206.  */
  207. static inline int list_empty_careful(const struct list_head *head)
  208. {
  209.         struct list_head *next = head->next;
  210.         return (next == head) && (next == head->prev);
  211. }
  212.  
  213. /**
  214.  * list_is_singular - tests whether a list has just one entry.
  215.  * @head: the list to test.
  216.  */
  217. static inline int list_is_singular(const struct list_head *head)
  218. {
  219.         return !list_empty(head) && (head->next == head->prev);
  220. }
  221.  
  222. static inline void __list_cut_position(struct list_head *list,
  223.                 struct list_head *head, struct list_head *entry)
  224. {
  225.         struct list_head *new_first = entry->next;
  226.         list->next = head->next;
  227.         list->next->prev = list;
  228.         list->prev = entry;
  229.         entry->next = list;
  230.         head->next = new_first;
  231.         new_first->prev = head;
  232. }
  233.  
  234. /**
  235.  * list_cut_position - cut a list into two
  236.  * @list: a new list to add all removed entries
  237.  * @head: a list with entries
  238.  * @entry: an entry within head, could be the head itself
  239.  *      and if so we won't cut the list
  240.  *
  241.  * This helper moves the initial part of @head, up to and
  242.  * including @entry, from @head to @list. You should
  243.  * pass on @entry an element you know is on @head. @list
  244.  * should be an empty list or a list you do not care about
  245.  * losing its data.
  246.  *
  247.  */
  248. static inline void list_cut_position(struct list_head *list,
  249.                 struct list_head *head, struct list_head *entry)
  250. {
  251.         if (list_empty(head))
  252.                 return;
  253.         if (list_is_singular(head) &&
  254.                 (head->next != entry && head != entry))
  255.                 return;
  256.         if (entry == head)
  257.                 INIT_LIST_HEAD(list);
  258.         else
  259.                 __list_cut_position(list, head, entry);
  260. }
  261.  
  262. static inline void __list_splice(const struct list_head *list,
  263.                                  struct list_head *prev,
  264.                                  struct list_head *next)
  265. {
  266.         struct list_head *first = list->next;
  267.         struct list_head *last = list->prev;
  268.  
  269.         first->prev = prev;
  270.         prev->next = first;
  271.  
  272.         last->next = next;
  273.         next->prev = last;
  274. }
  275.  
  276. /**
  277.  * list_splice - join two lists, this is designed for stacks
  278.  * @list: the new list to add.
  279.  * @head: the place to add it in the first list.
  280.  */
  281. static inline void list_splice(const struct list_head *list,
  282.                                 struct list_head *head)
  283. {
  284.         if (!list_empty(list))
  285.                 __list_splice(list, head, head->next);
  286. }
  287.  
  288. /**
  289.  * list_splice_tail - join two lists, each list being a queue
  290.  * @list: the new list to add.
  291.  * @head: the place to add it in the first list.
  292.  */
  293. static inline void list_splice_tail(struct list_head *list,
  294.                                 struct list_head *head)
  295. {
  296.         if (!list_empty(list))
  297.                 __list_splice(list, head->prev, head);
  298. }
  299.  
  300. /**
  301.  * list_splice_init - join two lists and reinitialise the emptied list.
  302.  * @list: the new list to add.
  303.  * @head: the place to add it in the first list.
  304.  *
  305.  * The list at @list is reinitialised
  306.  */
  307. static inline void list_splice_init(struct list_head *list,
  308.                                     struct list_head *head)
  309. {
  310.         if (!list_empty(list)) {
  311.                 __list_splice(list, head, head->next);
  312.                 INIT_LIST_HEAD(list);
  313.         }
  314. }
  315.  
  316. /**
  317.  * list_splice_tail_init - join two lists and reinitialise the emptied list
  318.  * @list: the new list to add.
  319.  * @head: the place to add it in the first list.
  320.  *
  321.  * Each of the lists is a queue.
  322.  * The list at @list is reinitialised
  323.  */
  324. static inline void list_splice_tail_init(struct list_head *list,
  325.                                          struct list_head *head)
  326. {
  327.         if (!list_empty(list)) {
  328.                 __list_splice(list, head->prev, head);
  329.                 INIT_LIST_HEAD(list);
  330.         }
  331. }
  332.  
  333. /**
  334.  * list_entry - get the struct for this entry
  335.  * @ptr:        the &struct list_head pointer.
  336.  * @type:       the type of the struct this is embedded in.
  337.  * @member:     the name of the list_struct within the struct.
  338.  */
  339. #define list_entry(ptr, type, member) \
  340.         container_of(ptr, type, member)
  341.  
  342. /**
  343.  * list_first_entry - get the first element from a list
  344.  * @ptr:        the list head to take the element from.
  345.  * @type:       the type of the struct this is embedded in.
  346.  * @member:     the name of the list_struct within the struct.
  347.  *
  348.  * Note, that list is expected to be not empty.
  349.  */
  350. #define list_first_entry(ptr, type, member) \
  351.         list_entry((ptr)->next, type, member)
  352.  
  353. /**
  354.  * list_for_each        -       iterate over a list
  355.  * @pos:        the &struct list_head to use as a loop cursor.
  356.  * @head:       the head for your list.
  357.  */
  358. #define list_for_each(pos, head) \
  359.         for (pos = (head)->next; prefetch(pos->next), pos != (head); \
  360.                 pos = pos->next)
  361.  
  362. /**
  363.  * __list_for_each      -       iterate over a list
  364.  * @pos:        the &struct list_head to use as a loop cursor.
  365.  * @head:       the head for your list.
  366.  *
  367.  * This variant differs from list_for_each() in that it's the
  368.  * simplest possible list iteration code, no prefetching is done.
  369.  * Use this for code that knows the list to be very short (empty
  370.  * or 1 entry) most of the time.
  371.  */
  372. #define __list_for_each(pos, head) \
  373.         for (pos = (head)->next; pos != (head); pos = pos->next)
  374.  
  375. /**
  376.  * list_for_each_prev   -       iterate over a list backwards
  377.  * @pos:        the &struct list_head to use as a loop cursor.
  378.  * @head:       the head for your list.
  379.  */
  380. #define list_for_each_prev(pos, head) \
  381.         for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
  382.                 pos = pos->prev)
  383.  
  384. /**
  385.  * list_for_each_safe - iterate over a list safe against removal of list entry
  386.  * @pos:        the &struct list_head to use as a loop cursor.
  387.  * @n:          another &struct list_head to use as temporary storage
  388.  * @head:       the head for your list.
  389.  */
  390. #define list_for_each_safe(pos, n, head) \
  391.         for (pos = (head)->next, n = pos->next; pos != (head); \
  392.                 pos = n, n = pos->next)
  393.  
  394. /**
  395.  * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
  396.  * @pos:        the &struct list_head to use as a loop cursor.
  397.  * @n:          another &struct list_head to use as temporary storage
  398.  * @head:       the head for your list.
  399.  */
  400. #define list_for_each_prev_safe(pos, n, head) \
  401.         for (pos = (head)->prev, n = pos->prev; \
  402.              prefetch(pos->prev), pos != (head); \
  403.              pos = n, n = pos->prev)
  404.  
  405. /**
  406.  * list_for_each_entry  -       iterate over list of given type
  407.  * @pos:        the type * to use as a loop cursor.
  408.  * @head:       the head for your list.
  409.  * @member:     the name of the list_struct within the struct.
  410.  */
  411. #define list_for_each_entry(pos, head, member)                          \
  412.         for (pos = list_entry((head)->next, typeof(*pos), member);      \
  413.              prefetch(pos->member.next), &pos->member != (head);        \
  414.              pos = list_entry(pos->member.next, typeof(*pos), member))
  415.  
  416. /**
  417.  * list_for_each_entry_reverse - iterate backwards over list of given type.
  418.  * @pos:        the type * to use as a loop cursor.
  419.  * @head:       the head for your list.
  420.  * @member:     the name of the list_struct within the struct.
  421.  */
  422. #define list_for_each_entry_reverse(pos, head, member)                  \
  423.         for (pos = list_entry((head)->prev, typeof(*pos), member);      \
  424.              prefetch(pos->member.prev), &pos->member != (head);        \
  425.              pos = list_entry(pos->member.prev, typeof(*pos), member))
  426.  
  427. /**
  428.  * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
  429.  * @pos:        the type * to use as a start point
  430.  * @head:       the head of the list
  431.  * @member:     the name of the list_struct within the struct.
  432.  *
  433.  * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
  434.  */
  435. #define list_prepare_entry(pos, head, member) \
  436.         ((pos) ? : list_entry(head, typeof(*pos), member))
  437.  
  438. /**
  439.  * list_for_each_entry_continue - continue iteration over list of given type
  440.  * @pos:        the type * to use as a loop cursor.
  441.  * @head:       the head for your list.
  442.  * @member:     the name of the list_struct within the struct.
  443.  *
  444.  * Continue to iterate over list of given type, continuing after
  445.  * the current position.
  446.  */
  447. #define list_for_each_entry_continue(pos, head, member)                 \
  448.         for (pos = list_entry(pos->member.next, typeof(*pos), member);  \
  449.              prefetch(pos->member.next), &pos->member != (head);        \
  450.              pos = list_entry(pos->member.next, typeof(*pos), member))
  451.  
  452. /**
  453.  * list_for_each_entry_continue_reverse - iterate backwards from the given point
  454.  * @pos:        the type * to use as a loop cursor.
  455.  * @head:       the head for your list.
  456.  * @member:     the name of the list_struct within the struct.
  457.  *
  458.  * Start to iterate over list of given type backwards, continuing after
  459.  * the current position.
  460.  */
  461. #define list_for_each_entry_continue_reverse(pos, head, member)         \
  462.         for (pos = list_entry(pos->member.prev, typeof(*pos), member);  \
  463.              prefetch(pos->member.prev), &pos->member != (head);        \
  464.              pos = list_entry(pos->member.prev, typeof(*pos), member))
  465.  
  466. /**
  467.  * list_for_each_entry_from - iterate over list of given type from the current point
  468.  * @pos:        the type * to use as a loop cursor.
  469.  * @head:       the head for your list.
  470.  * @member:     the name of the list_struct within the struct.
  471.  *
  472.  * Iterate over list of given type, continuing from current position.
  473.  */
  474. #define list_for_each_entry_from(pos, head, member)                     \
  475.         for (; prefetch(pos->member.next), &pos->member != (head);      \
  476.              pos = list_entry(pos->member.next, typeof(*pos), member))
  477.  
  478. /**
  479.  * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  480.  * @pos:        the type * to use as a loop cursor.
  481.  * @n:          another type * to use as temporary storage
  482.  * @head:       the head for your list.
  483.  * @member:     the name of the list_struct within the struct.
  484.  */
  485. #define list_for_each_entry_safe(pos, n, head, member)                  \
  486.         for (pos = list_entry((head)->next, typeof(*pos), member),      \
  487.                 n = list_entry(pos->member.next, typeof(*pos), member); \
  488.              &pos->member != (head);                                    \
  489.              pos = n, n = list_entry(n->member.next, typeof(*n), member))
  490.  
  491. /**
  492.  * list_for_each_entry_safe_continue
  493.  * @pos:        the type * to use as a loop cursor.
  494.  * @n:          another type * to use as temporary storage
  495.  * @head:       the head for your list.
  496.  * @member:     the name of the list_struct within the struct.
  497.  *
  498.  * Iterate over list of given type, continuing after current point,
  499.  * safe against removal of list entry.
  500.  */
  501. #define list_for_each_entry_safe_continue(pos, n, head, member)                 \
  502.         for (pos = list_entry(pos->member.next, typeof(*pos), member),          \
  503.                 n = list_entry(pos->member.next, typeof(*pos), member);         \
  504.              &pos->member != (head);                                            \
  505.              pos = n, n = list_entry(n->member.next, typeof(*n), member))
  506.  
  507. /**
  508.  * list_for_each_entry_safe_from
  509.  * @pos:        the type * to use as a loop cursor.
  510.  * @n:          another type * to use as temporary storage
  511.  * @head:       the head for your list.
  512.  * @member:     the name of the list_struct within the struct.
  513.  *
  514.  * Iterate over list of given type from current point, safe against
  515.  * removal of list entry.
  516.  */
  517. #define list_for_each_entry_safe_from(pos, n, head, member)                     \
  518.         for (n = list_entry(pos->member.next, typeof(*pos), member);            \
  519.              &pos->member != (head);                                            \
  520.              pos = n, n = list_entry(n->member.next, typeof(*n), member))
  521.  
  522. /**
  523.  * list_for_each_entry_safe_reverse
  524.  * @pos:        the type * to use as a loop cursor.
  525.  * @n:          another type * to use as temporary storage
  526.  * @head:       the head for your list.
  527.  * @member:     the name of the list_struct within the struct.
  528.  *
  529.  * Iterate backwards over list of given type, safe against removal
  530.  * of list entry.
  531.  */
  532. #define list_for_each_entry_safe_reverse(pos, n, head, member)          \
  533.         for (pos = list_entry((head)->prev, typeof(*pos), member),      \
  534.                 n = list_entry(pos->member.prev, typeof(*pos), member); \
  535.              &pos->member != (head);                                    \
  536.              pos = n, n = list_entry(n->member.prev, typeof(*n), member))
  537.  
  538. /*
  539.  * Double linked lists with a single pointer list head.
  540.  * Mostly useful for hash tables where the two pointer list head is
  541.  * too wasteful.
  542.  * You lose the ability to access the tail in O(1).
  543.  */
  544.  
  545. #if 0
  546. struct hlist_head {
  547.         struct hlist_node *first;
  548. };
  549.  
  550. struct hlist_node {
  551.         struct hlist_node *next, **pprev;
  552. };
  553.  
  554. #define HLIST_HEAD_INIT { .first = NULL }
  555. #define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }
  556. #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
  557. static inline void INIT_HLIST_NODE(struct hlist_node *h)
  558. {
  559.         h->next = NULL;
  560.         h->pprev = NULL;
  561. }
  562.  
  563. static inline int hlist_unhashed(const struct hlist_node *h)
  564. {
  565.         return !h->pprev;
  566. }
  567.  
  568. static inline int hlist_empty(const struct hlist_head *h)
  569. {
  570.         return !h->first;
  571. }
  572.  
  573. static inline void __hlist_del(struct hlist_node *n)
  574. {
  575.         struct hlist_node *next = n->next;
  576.         struct hlist_node **pprev = n->pprev;
  577.         *pprev = next;
  578.         if (next)
  579.                 next->pprev = pprev;
  580. }
  581.  
  582. static inline void hlist_del(struct hlist_node *n)
  583. {
  584.         __hlist_del(n);
  585.         n->next = LIST_POISON1;
  586.         n->pprev = LIST_POISON2;
  587. }
  588.  
  589. static inline void hlist_del_init(struct hlist_node *n)
  590. {
  591.         if (!hlist_unhashed(n)) {
  592.                 __hlist_del(n);
  593.                 INIT_HLIST_NODE(n);
  594.         }
  595. }
  596.  
  597. static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
  598. {
  599.         struct hlist_node *first = h->first;
  600.         n->next = first;
  601.         if (first)
  602.                 first->pprev = &n->next;
  603.         h->first = n;
  604.         n->pprev = &h->first;
  605. }
  606.  
  607. /* next must be != NULL */
  608. static inline void hlist_add_before(struct hlist_node *n,
  609.                                         struct hlist_node *next)
  610. {
  611.         n->pprev = next->pprev;
  612.         n->next = next;
  613.         next->pprev = &n->next;
  614.         *(n->pprev) = n;
  615. }
  616.  
  617. static inline void hlist_add_after(struct hlist_node *n,
  618.                                         struct hlist_node *next)
  619. {
  620.         next->next = n->next;
  621.         n->next = next;
  622.         next->pprev = &n->next;
  623.  
  624.         if(next->next)
  625.                 next->next->pprev  = &next->next;
  626. }
  627.  
  628. /*
  629.  * Move a list from one list head to another. Fixup the pprev
  630.  * reference of the first entry if it exists.
  631.  */
  632. static inline void hlist_move_list(struct hlist_head *old,
  633.                                    struct hlist_head *new)
  634. {
  635.         new->first = old->first;
  636.         if (new->first)
  637.                 new->first->pprev = &new->first;
  638.         old->first = NULL;
  639. }
  640.  
  641. #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
  642.  
  643. #define hlist_for_each(pos, head) \
  644.         for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
  645.              pos = pos->next)
  646.  
  647. #define hlist_for_each_safe(pos, n, head) \
  648.         for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
  649.              pos = n)
  650.  
  651. /**
  652.  * hlist_for_each_entry - iterate over list of given type
  653.  * @tpos:       the type * to use as a loop cursor.
  654.  * @pos:        the &struct hlist_node to use as a loop cursor.
  655.  * @head:       the head for your list.
  656.  * @member:     the name of the hlist_node within the struct.
  657.  */
  658. #define hlist_for_each_entry(tpos, pos, head, member)                    \
  659.         for (pos = (head)->first;                                        \
  660.              pos && ({ prefetch(pos->next); 1;}) &&                      \
  661.                 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  662.              pos = pos->next)
  663.  
  664. /**
  665.  * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
  666.  * @tpos:       the type * to use as a loop cursor.
  667.  * @pos:        the &struct hlist_node to use as a loop cursor.
  668.  * @member:     the name of the hlist_node within the struct.
  669.  */
  670. #define hlist_for_each_entry_continue(tpos, pos, member)                 \
  671.         for (pos = (pos)->next;                                          \
  672.              pos && ({ prefetch(pos->next); 1;}) &&                      \
  673.                 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  674.              pos = pos->next)
  675.  
  676. /**
  677.  * hlist_for_each_entry_from - iterate over a hlist continuing from current point
  678.  * @tpos:       the type * to use as a loop cursor.
  679.  * @pos:        the &struct hlist_node to use as a loop cursor.
  680.  * @member:     the name of the hlist_node within the struct.
  681.  */
  682. #define hlist_for_each_entry_from(tpos, pos, member)                     \
  683.         for (; pos && ({ prefetch(pos->next); 1;}) &&                    \
  684.                 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  685.              pos = pos->next)
  686.  
  687. /**
  688.  * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  689.  * @tpos:       the type * to use as a loop cursor.
  690.  * @pos:        the &struct hlist_node to use as a loop cursor.
  691.  * @n:          another &struct hlist_node to use as temporary storage
  692.  * @head:       the head for your list.
  693.  * @member:     the name of the hlist_node within the struct.
  694.  */
  695. #define hlist_for_each_entry_safe(tpos, pos, n, head, member)            \
  696.         for (pos = (head)->first;                                        \
  697.              pos && ({ n = pos->next; 1; }) &&                           \
  698.                 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  699.              pos = n)
  700.  
  701. #endif
  702.  
  703. #endif
  704.