Re: container-of Implementation

2013-01-14 Thread Geert Uytterhoeven
On Mon, Jan 14, 2013 at 11:46 AM, Schrober wrote: > I wondered why the container_of implementation is so complicated. > > #define container_of(ptr, type, member) ({ \ > const typeof( ((type *)0)->member ) *__mptr = (ptr);\ > (type *)( (char *)__mptr -

Re: container-of Implementation

2013-01-14 Thread Mikael Pettersson
Schrober writes: > Hi, > > I wondered why the container_of implementation is so complicated. > > #define container_of(ptr, type, member) ({ \ > const typeof( ((type *)0)->member ) *__mptr = (ptr);\ > (type *)( (char *)__mptr - offsetof(type,member) );}) >

container-of Implementation

2013-01-14 Thread Schrober
Hi, I wondered why the container_of implementation is so complicated. #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr);\ (type *)( (char *)__mptr - offsetof(type,member) );}) isn't the __mptr not

container-of Implementation

2013-01-14 Thread Schrober
Hi, I wondered why the container_of implementation is so complicated. #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)-member ) *__mptr = (ptr);\ (type *)( (char *)__mptr - offsetof(type,member) );}) isn't the __mptr not

Re: container-of Implementation

2013-01-14 Thread Mikael Pettersson
Schrober writes: Hi, I wondered why the container_of implementation is so complicated. #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)-member ) *__mptr = (ptr);\ (type *)( (char *)__mptr - offsetof(type,member) );}) isn't

Re: container-of Implementation

2013-01-14 Thread Geert Uytterhoeven
On Mon, Jan 14, 2013 at 11:46 AM, Schrober franzschro...@yahoo.de wrote: I wondered why the container_of implementation is so complicated. #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)-member ) *__mptr = (ptr);\ (type *)( (char