tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] implementation of backward traversing of lists



On Fri 03 Oct 2008 at 13:58:59 +0300, Ilya Dogolazky wrote:
> For some list and an entry pointer defined by
>         LIST_HEAD(listhead, entry) ;

Looking at the header file, shouldn't that be

         LIST_HEAD(listhead, data) ;

to fit with the rest of your example? (Otherwise I'm misunderstanding
what's going on)

>         struct data
>         {
>           ... ;
>           LIST_ENTRY(data) xxx ;
>           ... ;
>         } *pointer, ..... ;
> the usage is:
>         struct data *previous = LIST_PREV(pointer, xxx, data) ;

> #define LIST_DIFF(elm, field) 
> ((uintptr_t)(&(elm)->field.le_next)-(uintptr_t)(elm))
> #define LIST_PREV_ADDR(elm, field) 
> ((uintptr_t)((elm)->field.le_prev)-LIST_DIFF(elm,field))

Can't you use the C standard macro offsetof from <stddef.h> instead of
LIST_DIFF?

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert    -- You author it, and I'll reader it.
\X/ rhialto/at/xs4all.nl      -- Cetero censeo "authored" delendum esse.


Home | Main Index | Thread Index | Old Index