[Mesa-dev] [PATCH 1/2] util: Fix foreach_list_typed_safe when exec_node is not at offset 0.

Matt Turner mattst88 at gmail.com
Tue Mar 10 21:45:38 PDT 2015


On Tue, Mar 10, 2015 at 8:31 PM, Ian Romanick <idr at freedesktop.org> wrote:
> Also... I'm not a fan of these ever-growing macros.  They're a lot like
> alligators.  They're pretty cute when they're small, but when they grow
> up they drown you in a river and eat you.  I feel like the users of
> this macro should just use foreach_list_safe, and use exec_node_data by
> hand.  That would simplify things a lot by hiding less from the
> programmer.

I don't know, I think with the bugs shaken out, the prevent a lot of
mistakes among other benefits.

Think for instance of the number of times we've fixed node->next !=
NULL to be node->next->next != NULL before the macros existed.

They also cut boilerplate from every linked list walk. These were some
diff-stats from some of the commits that started using them:

184 insertions(+), 291 deletions (commit 4d78446d)
41 insertions(+), 85 deletions (commit e0cb82d0)

Using macros also massively simplified the transition in the i965
backend from a single huge instruction list to a list of basic blocks,
each with their own instruction lists -- see commit 49374fab.


More information about the mesa-dev mailing list