summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-11-05 13:57:09 -0800
committerJason Ekstrand <[email protected]>2014-11-07 14:53:40 -0800
commit0c36aac83252d32dac8c4da2850539bff0b10301 (patch)
treef57ef6b0797255213a490e4059bfd422db791d31
parent706ad3b649e6a75fdac9dc9acc3caa9e6067b853 (diff)
glsl/list: Add an exec_list_validate function
This can be very useful for trying to debug list corruptions. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]>
-rw-r--r--src/glsl/list.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/glsl/list.h b/src/glsl/list.h
index b6c32bcccaf..e4b063cab58 100644
--- a/src/glsl/list.h
+++ b/src/glsl/list.h
@@ -521,6 +521,25 @@ exec_node_insert_list_before(struct exec_node *n, struct exec_list *before)
exec_list_make_empty(before);
}
+static inline void
+exec_list_validate(const struct exec_list *list)
+{
+ assert(list->head->prev == (const struct exec_node *) &list->head);
+ assert(list->tail == NULL);
+ assert(list->tail_pred->next == (const struct exec_node *) &list->tail);
+
+ /* We could try to use one of the interators below for this but they all
+ * either require C++ or assume the exec_node is embedded in a structure
+ * which is not the case for this function.
+ */
+ for (const struct exec_node *node = exec_list_get_head_const(list);
+ !exec_node_is_tail_sentinel(node);
+ node = exec_node_get_next_const(node)) {
+ assert(node->next->prev == node);
+ assert(node->prev->next == node);
+ }
+}
+
#ifdef __cplusplus
inline void exec_list::make_empty()
{