i965/fs: fix copy propagation of partially invalidated entries
[mesa.git] / src / util / list.h
index 946034710efd6e11b70b9645458ff3d8f39b6a75..f0dec5da60874c7cf9e6028589e9d1f03697816b 100644 (file)
@@ -99,6 +99,14 @@ static inline bool list_empty(struct list_head *list)
    return list->next == list;
 }
 
+/**
+ * Returns whether the list has exactly one element.
+ */
+static inline bool list_is_singular(const struct list_head *list)
+{
+   return list->next != NULL && list->next->next == list;
+}
+
 static inline unsigned list_length(struct list_head *list)
 {
    struct list_head *node;
@@ -108,6 +116,28 @@ static inline unsigned list_length(struct list_head *list)
    return length;
 }
 
+static inline void list_splice(struct list_head *src, struct list_head *dst)
+{
+   if (list_empty(src))
+      return;
+
+   src->next->prev = dst;
+   src->prev->next = dst->next;
+   dst->next->prev = src->prev;
+   dst->next = src->next;
+}
+
+static inline void list_splicetail(struct list_head *src, struct list_head *dst)
+{
+   if (list_empty(src))
+      return;
+
+   src->prev->next = dst;
+   src->next->prev = dst->prev;
+   dst->prev->next = src->next;
+   dst->prev = src->prev;
+}
+
 static inline void list_validate(struct list_head *list)
 {
    struct list_head *node;
@@ -140,6 +170,13 @@ static inline void list_validate(struct list_head *list)
             - ((char *)&(sample)->member - (char *)(sample)))
 #endif
 
+#define list_first_entry(ptr, type, member) \
+        LIST_ENTRY(type, (ptr)->next, member)
+
+#define list_last_entry(ptr, type, member) \
+        LIST_ENTRY(type, (ptr)->prev, member)
+
+
 #define LIST_FOR_EACH_ENTRY(pos, head, member)                         \
    for (pos = NULL, pos = container_of((head)->next, pos, member);     \
        &pos->member != (head);                                         \