zoukankan      html  css  js  c++  java
  • linux list

    linux list

    1. container_of

    #define container_of(ptr, type, member)                 /
    ({                                                        /
        const typeof( ((type *)0)->member ) *__mptr = (ptr);/
        (type *)( (char *)__mptr - offsetof(type,member) ); /
    })
    

    通过成员指针得到容器指针。

    2. struct list_head

    struct list_head {
        struct list_head *next, *prev;
    };
    

    3. list_entry

    #define list_entry(ptr, type, member) /
        container_of(ptr, type, member)
    

    4. list_for_each

    #define list_for_each(pos, head)   
        for (pos = (head)->next, prefetch(pos->next); pos != (head);   
            pos = pos->next, prefetch(pos->next)) 
    

    5. list_for_each_entry

        #define list_for_each_entry(pos, head, member)    /
             for (pos = list_entry((head)->next, typeof(*pos), member); /
                   prefetch(pos->member.next), &pos->member != (head);  /
                   pos = list_entry(pos->member.next, typeof(*pos), member))
    
  • 相关阅读:
    iou与giou对比
    Linux学习第一天 vim
    奖励加分申请
    人月神话阅读笔记3
    5.27
    5.26
    5.25
    5.23
    5.22
    5.21
  • 原文地址:https://www.cnblogs.com/gr-nick/p/10805616.html
Copyright © 2011-2022 走看看