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

Brian Paul brianp at vmware.com
Tue May 5 11:38:28 PDT 2015


On 05/05/2015 12:21 PM, Neil Roberts 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?

No, and yes.


>
>> +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.

I don't remember off-hand.

-Brian

>
> 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
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=AwIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=AatEjMM7ntWsECW9oVPLk_C3Z0CK7QBIqbXVP_ETF2w&s=TOtSOLlRYSt9tEJikNpITMxBHKDnURqnl6d7RRDfl4w&e=
>



More information about the mesa-dev mailing list