[Mesa-dev] [RFC] Moving from macro to inline for list manipulation

Keith Whitwell keithw at vmware.com
Tue Mar 29 03:14:18 PDT 2011


On Mon, 2011-03-28 at 17:54 -0400, Jerome Glisse wrote:
> Hi,
> 
> One short coming of macro has keep entertaining me until i figure out
> what was wrong, here is
> a simple scenario :
> 
> Macro can lead to hard to debug list bugs. For instance consider
> the following :
> LIST_ADD(item, list->prev)
> 3 instruction of the macro became :
> (list->prev)->next->prev = item
> which is equivalent to :
> list->prev = item
> Thus list prev field changes and next instruction in the macro
> (list->prev)->next = item
> became :
> item->next = item
> And you endup with list corruption, other case lead to similar
> list corruption. Inline function are not affected by this short
> coming
> 
> Thus i propose to switch list manipulation from macro to inline
> function, attached patch does exactly that. If there is no objection
> in next couple of week i will merge it. (to avoid mass renaming it
> keeps the macro that just wrap the functions it also add a bunch of
> new list walking helper)

I'm ok with this.  Those macros were supposed to be quick & dirty, but
they've been around much longer than I ever expected...

Keith



More information about the mesa-dev mailing list