[Mesa-dev] [RFC 1/2] glsl/list: Add an iteration helper that starts after the given node

Jason Ekstrand jason at jlekstrand.net
Mon Sep 19 05:33:53 UTC 2016


On Sun, Sep 18, 2016 at 10:27 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:

> On Thursday, September 15, 2016 9:00:35 PM PDT Jason Ekstrand wrote:
> > ---
> >  src/compiler/glsl/list.h | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/src/compiler/glsl/list.h b/src/compiler/glsl/list.h
> > index b5b5b36..8371519 100644
> > --- a/src/compiler/glsl/list.h
> > +++ b/src/compiler/glsl/list.h
> > @@ -714,6 +714,15 @@ inline void exec_node::insert_before(exec_list
> *before)
> >          __node = __next, __next =
>     \
> >             exec_node_data(__type, (__next)->__field.next, __field))
> >
>
> Perhaps add:
>
> /* __after must be a valid list node (not the tail sentinel) */
>
> (if after is the tail sentinel, __node will be NULL, and then trying to
> obtain (__node)->__field.next will dereference that NULL pointer.)
>
> Either way, patch 1 is
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
>
> (I haven't thought about patch 2, sorry)
>

I wouldn't bother for the moment.  I'm pretty sure it's broken and I think
that Connor is right that trying to make block-splitting more deterministic
is more-or-less a fool's errand.


> > +#define foreach_list_typed_safe_after(__type, __node, __field,
> __after)    \
> > +   for (__type * __node =
>     \
> > +           exec_node_data(__type, (__after)->__field.next, __field),
>    \
> > +               * __next =
>     \
> > +           exec_node_data(__type, (__node)->__field.next, __field);
>     \
> > +        (__node)->__field.next != NULL;
>     \
> > +        __node = __next, __next =
>     \
> > +           exec_node_data(__type, (__next)->__field.next, __field))
> > +
> >  #define foreach_list_typed_reverse_safe(__type, __node, __field,
> __list)   \
> >     for (__type * __node =
>     \
> >             exec_node_data(__type, (__list)->tail_sentinel.prev,
> __field),  \
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160918/a45b4e28/attachment.html>


More information about the mesa-dev mailing list