Subversion Repositories Kolibri OS

Rev

Rev 859 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. typedef struct link
  3. {
  4.   struct link *prev;
  5.   struct link *next;
  6. }link_t;
  7.  
  8. #define list_get_instance(link, type, member) \
  9.   ((type *)(((u8_t *)(link)) - ((u8_t *)&(((type *)NULL)->member))))
  10.  
  11. static inline void link_initialize(link_t *link)
  12. {
  13.         link->prev = NULL;
  14.         link->next = NULL;
  15. }
  16.  
  17. static inline void list_initialize(link_t *head)
  18. {
  19.         head->prev = head;
  20.         head->next = head;
  21. }
  22.  
  23. static inline void list_append(link_t *link, link_t *head)
  24. {
  25.         link->prev = head->prev;
  26.         link->next = head;
  27.         head->prev->next = link;
  28.         head->prev = link;
  29. }
  30.  
  31. static inline void list_remove(link_t *link)
  32. {
  33.         link->next->prev = link->prev;
  34.         link->prev->next = link->next;
  35.         link_initialize(link);
  36. }
  37.  
  38. static inline bool list_empty(link_t *head)
  39. {
  40.         return head->next == head ? true : false;
  41. }
  42.  
  43. static inline void list_prepend(link_t *link, link_t *head)
  44. {
  45.         link->next = head->next;
  46.         link->prev = head;
  47.         head->next->prev = link;
  48.         head->next = link;
  49. }
  50.  
  51.