linux - What does this piece of code in the kernel.h mean? -
the below code linux kernel:
/** 639 * container_of - cast member of structure out containing structure 640 * @ptr: pointer member. 641 * @type: type of container struct embedded in. 642 * @member: name of member within struct. 643 * 644 */ 645 #define container_of(ptr, type, member) ({ \ 646 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 647 (type *)( (char *)__mptr - offsetof(type,member) );}) 648
i fail understand @ line 646-648. know these 2 lines comments above it, dont understand code word word. can explain me this?
the intent given anonymous pointer, know pointer element of larger structure, calculates beginning address of larger structure.
Comments
Post a Comment