zoukankan      html  css  js  c++  java
  • 内核分析阅读笔记

    include/Linux/stddef.h中macro offsetof define,list:

    #define offsetof(TYPE,MEMBER) ((size_t) &((TYPE *)0)->MEMBER)

    offsetof macro对于上述示例的展开剂分析:&((struct example_struct *)0)->list表示当结构example_struct正好在地址0上时其成员list的地址,即成员位移.

    traverse linked list member element;

    下面使用list_entry macro遍历链表得到链表指针,再从链表指针映射回对应结构example_struct的指针,然后,对其成员priority进行操作,函数example_add_entry的功能是给链表加入新的结构成员

    void example_add_entry(struct example_struct *new)

    {

      struct list_head *ptr;

      struct example_struct *entry;

      //遍历链表

      for (ptr = example_list.next;ptr != &example_list;ptr = ptr->next) {

      //映射回 对应结构example_struct的指针

      entry = list_entry(ptr,struct todo_Struct,list);

      

    }

    }

  • 相关阅读:
    iOS开发UI篇—字典转模型
    使用python编写批量卸载android应用的脚本
    CircularProgressBar
    Custom-Progress-Dialog-Android
    picasso jar
    swift
    Python编程
    H264分析工具
    Android Websites
    AnATools
  • 原文地址:https://www.cnblogs.com/ruiy/p/linked.html
Copyright © 2011-2022 走看看