Re: question about linked list implementation in kernel.h

2010-09-14 Thread Bond
On Tue, Sep 14, 2010 at 1:27 AM, Jan Ceuleers jan.ceule...@computer.orgwrote: On 11/09/10 17:49, Bond wrote: (type *)( (char *)__mptr - offsetof(type,member) );}) there a subtraction has been done why is this subtraction done? Not having read any of the documentation, what comes to mind

Re: question about linked list implementation in kernel.h

2010-09-12 Thread Bond
On Sat, Sep 11, 2010 at 10:09 PM, Manish Katiyar mkati...@gmail.com wrote: If you want some more details about this macro. http://www.spinics.net/lists/linux-usb-devel/msg11766.html Thanks but Manohars explanation was perfect for newbies like me.

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Carlo Caione
On 11/09/2010 14:33, Bond wrote: I read I was going through include/linux/kernel.h encountered following code #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)-member ) *__mptr = (ptr);\ in above code I am not clear with (type *)0 how is

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Bond
On Sat, Sep 11, 2010 at 6:22 PM, Carlo Caione carlo.cai...@gmail.comwrote: First link on google: Its not that I had not searched it did search but I had searched typedef and type and I kept reading links related to that only. What to be searched is not that obvious when some one is not clear.

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Bond
On Sat, Sep 11, 2010 at 6:22 PM, Carlo Caione carlo.cai...@gmail.comwrote: http://www.kroah.com/log/linux/container_of.html I am not able to understand a single bit of the explanaition on the above link. They have assumed I programmed PCI buses which I have not.

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Robert P. J. Day
On Sat, 11 Sep 2010, Bond wrote: On Sat, Sep 11, 2010 at 6:22 PM, Carlo Caione carlo.cai...@gmail.com wrote: http://www.kroah.com/log/linux/container_of.html I am not able to understand a single bit of the explanaition on the above link. They have assumed I programmed PCI buses which  I

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Manohar Vanga
I just made a small example (with comments) to play around with :-) Let me know if you feel something is wrong in my explanations (I'm still learning as well!) Hope it helps! On Sat, Sep 11, 2010 at 6:03 PM, Bond jamesbond.2...@gmail.com wrote: I read I was going through include/linux/kernel.h

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Bond
On Sat, Sep 11, 2010 at 9:12 PM, Bond jamesbond.2...@gmail.com wrote: http://crashcourse.ca/introduction-linux-kernel-programming/intermission-lets-talk-about-linked-lists-and-containerof-free Robert (type *)( (char *)__mptr - offsetof(type,member) );}) there a subtraction has been

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Carlo Caione
On 11/09/2010 17:45, Manohar Vanga wrote: I just made a small example (with comments) to play around with :-) Let me know if you feel something is wrong in my explanations (I'm still learning as well!) Hope it helps! It is correct. Good explanation. -- Carlo -- To unsubscribe from this list:

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Bond
On Sat, Sep 11, 2010 at 9:15 PM, Manohar Vanga manohar.va...@gmail.comwrote: I just made a small example (with comments) to play around with :-) Let me know if you feel something is wrong in my explanations (I'm still learning as well!) Hope it helps! Manohar I just happen to understand

Re: question about linked list implementation in kernel.h

2010-09-11 Thread Manish Katiyar
On Sat, Sep 11, 2010 at 5:33 AM, Bond jamesbond.2...@gmail.com wrote: I read I was going through include/linux/kernel.h encountered following code #define container_of(ptr, type, member) ({  \     const typeof( ((type *)0)-member ) *__mptr = (ptr);    \ in above