1、container_of的作用:
    
   
    
     
      
       根据一个结构体(type)变量中的一个域成员变量(member)的指针(ptr)来获取指向整个结构体变量的指针。
      
     
     
    
   
    
     2、container_of的定义:
    
   
    
     #define container_of(ptr, type, member) \
    
   
    
     
     
     ({
     
    
   
    
     
     
     const typeof(((type *)0)->member) *__mptr = (ptr);
    
   
    
     
     
     (type *)((char *)__mptr – offsetof(type,member));
    
   
    
     
     
     })
    
   
    
     3、解释含义:
    
   
    
     
      
       (1) ( (TYPE *)0 ) 将零转型为TYPE类型指针;
      
      
      
       (2) ((TYPE *)0)->MEMBER 访问结构中的数据成员;
      
      
     
    
   
    
     
      
       (3)typeof用于获取
       
        ((TYPE *)0)->MEMBER对象的数据类型;
       
      
     
    
   
    
     
      
       
        (4)offsetof用于获取成员member在type中地址的偏移量;
       
      
     
    
   
 
