[Mesa-dev] [PATCH 09/13] util/list: Add list_empty and list_length functions

Jason Ekstrand jason at jlekstrand.net
Tue May 5 11:35:11 PDT 2015

On Tue, May 5, 2015 at 11:21 AM, Neil Roberts <neil at linux.intel.com> wrote:
> Jason Ekstrand <jason at jlekstrand.net> writes:
>> +static inline bool list_empty(struct list_head *list)
>> +{
>> +   return list->next == list;
>> +}
> It would be good if list.h also included stdbool.h in order to get the
> declaration of bool. However, will that cause problems on MSVC? Is the
> Gallium code compiled on MSVC in general?

Rob Clark pointed that out.  I've fixed it locally.

>> +static inline unsigned list_length(struct list_head *list)
>> +{
>> +   unsigned length = 0;
>> +   for (struct list_head *node = list->next; node != list; node = node->next)
>> +      length++;
>> +   return length;
>> +}
> Any reason not to use one of the list iterator macros here? Is it safe
> to use a C99-ism outside of a macro in this header? Maybe MSVC
> supports this particular C99-ism anyway.

Because the list iterators work on a subtype and making them work on
the  node itself is kind of painful.  Why C99? No good reason, I could
can that easily enough.

> For what it's worth, I'm strongly in favour of using these kernel-style
> lists instead of exec_list. The kernel ones seem much less confusing.
> Regards,
> - Neil

More information about the mesa-dev mailing list