Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / util / list.h
index 69220c4fff0493ec2c776bdff76605c26b28ab8d..d50eb1ea5dde481711d1f726d47323d8544b4d3a 100644 (file)
@@ -77,11 +77,11 @@ static inline void list_addtail(struct list_head *item, struct list_head *list)
     list->prev = item;
 }
 
-static inline bool list_empty(const struct list_head *list);
+static inline bool list_is_empty(const struct list_head *list);
 
 static inline void list_replace(struct list_head *from, struct list_head *to)
 {
-    if (list_empty(from)) {
+    if (list_is_empty(from)) {
         list_inithead(to);
     } else {
         to->prev = from->prev;
@@ -106,7 +106,7 @@ static inline void list_delinit(struct list_head *item)
     item->prev = item;
 }
 
-static inline bool list_empty(const struct list_head *list)
+static inline bool list_is_empty(const struct list_head *list)
 {
    return list->next == list;
 }
@@ -130,7 +130,7 @@ static inline unsigned list_length(const struct list_head *list)
 
 static inline void list_splice(struct list_head *src, struct list_head *dst)
 {
-   if (list_empty(src))
+   if (list_is_empty(src))
       return;
 
    src->next->prev = dst;
@@ -141,7 +141,7 @@ static inline void list_splice(struct list_head *src, struct list_head *dst)
 
 static inline void list_splicetail(struct list_head *src, struct list_head *dst)
 {
-   if (list_empty(src))
+   if (list_is_empty(src))
       return;
 
    src->prev->next = dst;
@@ -158,17 +158,9 @@ static inline void list_validate(const struct list_head *list)
       assert(node->next->prev == node && node->prev->next == node);
 }
 
-#define LIST_ADD(__item, __list) list_add(__item, __list)
-#define LIST_REPLACE(__from, __to) list_replace(__from, __to)
-#define LIST_DEL(__item) list_del(__item)
-#define LIST_DELINIT(__item) list_delinit(__item)
-
 #define LIST_ENTRY(__type, __item, __field)   \
     ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
 
-#define LIST_IS_EMPTY(__list)                   \
-    ((__list)->next == (__list))
-
 /**
  * Cast from a pointer to a member of a struct back to the containing struct.
  *
@@ -249,9 +241,23 @@ static inline void list_validate(const struct list_head *list)
        &pos->member != (head);                                         \
        pos = LIST_ENTRY(type, pos->member.next, member))
 
+#define list_for_each_entry_from_safe(type, pos, start, head, member)   \
+   for (type *pos = LIST_ENTRY(type, (start), member),                  \
+            *__next = LIST_ENTRY(type, pos->member.next, member);      \
+       &pos->member != (head);                                         \
+       pos = __next,                                                   \
+       __next = LIST_ENTRY(type, __next->member.next, member))
+
 #define list_for_each_entry_from_rev(type, pos, start, head, member)    \
    for (type *pos = LIST_ENTRY(type, (start), member);                  \
        &pos->member != (head);                                         \
        pos = LIST_ENTRY(type, pos->member.prev, member))
 
+#define list_pair_for_each_entry(type, pos1, pos2, head1, head2, member) \
+   for (type *pos1 = LIST_ENTRY(type, (head1)->next, member),           \
+             *pos2 = LIST_ENTRY(type, (head2)->next, member);           \
+        &pos1->member != (head1) && &pos2->member != (head2);           \
+       pos1 = LIST_ENTRY(type, pos1->member.next, member),               \
+       pos2 = LIST_ENTRY(type, pos2->member.next, member))
+
 #endif /*_UTIL_LIST_H_*/