Re: question about linked list implementation in kernel.h

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

 





On Tue, Sep 14, 2010 at 1:27 AM, Jan Ceuleers <jan.ceuleers@xxxxxxxxxxxx> wrote:
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 is this:

if __mptr is a pointer to the member of a structure, the above _expression_ returns a pointer to the first byte of the containing structure, typecast to the type of the structure.

Example:

typedef struct {
       int a;
       char b;
} test_t;

test_t test;

Now assume that __mptr is a pointer to test.b, then the above _expression_ returns a pointer to test, i.e. a pointer to the structure that b is a member of.

Jan

Hi,
Jan no problem I am clear with the original question that I had asked with Manohar.
 

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux