ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

list.h
Go to the documentation of this file.
00001   #ifndef _LINUX_LIST_H
00002   #define _LINUX_LIST_H
00003   
00004 
00005   /*
00006    * Simple doubly linked list implementation.
00007    *
00008    * Some of the internal functions ("__xxx") are useful when
00009    * manipulating whole lists rather than single entries, as
00010    * sometimes we already know the next/prev entries and we can
00011    * generate better code by using them directly rather than
00012    * using the generic single-entry routines.
00013    */
00014   
00015   struct list_head {
00016           struct list_head *next, *prev;
00017   };
00018   
00019   #define LIST_HEAD_INIT(name) { &(name), &(name) }
00020   
00021   #define LIST_HEAD(name) \
00022           struct list_head name = LIST_HEAD_INIT(name)
00023   
00024   #define INIT_LIST_HEAD(ptr) do { \
00025           (ptr)->next = (ptr); (ptr)->prev = (ptr); \
00026   } while (0)
00027   
00028 
00029   /*
00030    * Insert a new entry between two known consecutive entries. 
00031    *
00032    * This is only for internal list manipulation where we know
00033    * the prev/next entries already!
00034    */
00035   static inline void __list_add(struct list_head *new,
00036                                 struct list_head *prev,
00037                                 struct list_head *next)
00038   {
00039           next->prev = new;
00040           new->next = next;
00041           new->prev = prev;
00042           prev->next = new;
00043   }
00044   
00053   static inline void list_add(struct list_head *new, struct list_head *head)
00054   {
00055          __list_add(new, head, head->next);
00056   }
00057  
00066   static inline void list_add_tail(struct list_head *new, struct list_head *head)
00067   {
00068           __list_add(new, head->prev, head);
00069   }
00070   
00071   /*
00072    * Delete a list entry by making the prev/next entries
00073    * point to each other.
00074    *
00075    * This is only for internal list manipulation where we know
00076    * the prev/next entries already!
00077    */
00078   static inline void __list_del(struct list_head *prev, struct list_head *next)
00079   {
00080           next->prev = prev;
00081           prev->next = next;
00082   }
00083   
00089   static inline void list_del(struct list_head *entry)
00090   {
00091           __list_del(entry->prev, entry->next);
00092           entry->next = (void *) 0;
00093           entry->prev = (void *) 0;
00094   }
00095   
00100  static inline void list_del_init(struct list_head *entry)
00101  {
00102          __list_del(entry->prev, entry->next);
00103          INIT_LIST_HEAD(entry); 
00104  }
00105  
00111  static inline void list_move(struct list_head *list, struct list_head *head)
00112  {
00113          __list_del(list->prev, list->next);
00114          list_add(list, head);
00115  }
00116  
00122  static inline void list_move_tail(struct list_head *list,
00123                                    struct list_head *head)
00124  {
00125          __list_del(list->prev, list->next);
00126          list_add_tail(list, head);
00127  }
00128  
00133  static inline int list_empty(struct list_head *head)
00134  {
00135          return head->next == head;
00136  }
00137  
00138  static inline void __list_splice(struct list_head *list,
00139                                   struct list_head *head)
00140  {
00141          struct list_head *first = list->next;
00142          struct list_head *last = list->prev;
00143          struct list_head *at = head->next;
00144  
00145          first->prev = head;
00146          head->next = first;
00147  
00148          last->next = at;
00149          at->prev = last;
00150  }
00151  
00157  static inline void list_splice(struct list_head *list, struct list_head *head)
00158  {
00159          if (!list_empty(list))
00160                  __list_splice(list, head);
00161  }
00162  
00170  static inline void list_splice_init(struct list_head *list,
00171                                      struct list_head *head)
00172  {
00173          if (!list_empty(list)) {
00174                  __list_splice(list, head);
00175                  INIT_LIST_HEAD(list);
00176          }
00177  }
00178  
00185  #define list_entry(ptr, type, member) \
00186          ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
00187  
00193  #define list_for_each(pos, head) \
00194          for (pos = (head)->next; pos != (head); \
00195                  pos = pos->next)
00196 
00201  #define list_for_each_prev(pos, head) \
00202          for (pos = (head)->prev; pos != (head); \
00203                  pos = pos->prev)
00204                  
00211  #define list_for_each_safe(pos, n, head) \
00212          for (pos = (head)->next, n = pos->next; pos != (head); \
00213                  pos = n, n = pos->next)
00214  
00221  #define list_for_each_entry(pos, head, member)                          \
00222          for (pos = list_entry((head)->next, typeof(*pos), member);      \
00223               &pos->member != (head);                                    \
00224               pos = list_entry(pos->member.next, typeof(*pos), member))
00225  
00233  #define list_for_each_entry_safe(pos, n, head, member)                  \
00234          for (pos = list_entry((head)->next, typeof(*pos), member),      \
00235                  n = list_entry(pos->member.next, typeof(*pos), member); \
00236               &pos->member != (head);                                    \
00237               pos = n, n = list_entry(n->member.next, typeof(*n), member))
00238  
00246  #define list_for_each_entry_continue(pos, head, member)                 \
00247          for (pos = list_entry(pos->member.next, typeof(*pos), member);  \
00248               &pos->member != (head);                                    \
00249               pos = list_entry(pos->member.next, typeof(*pos), member))
00250  
00251  #endif

Generated on Sun May 27 2012 04:27:26 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.