当前位置: 首页 > news >正文

googl浏览器做桌面版网站兰州网站推广建设公司

googl浏览器做桌面版网站,兰州网站推广建设公司,泰安的网络建设公司,h5 和手机网站1. 关于list_head struct list_head是Linux内核定义的双向链表#xff0c;包含一个指向前驱节点和后继节点的指针的结构体。其定义如下#xff1a; struct list_head {struct list_head *next, *prev; //双向链表#xff0c;指向节点的指针 };1.1 链表的定义和初始化 有两…1. 关于list_head struct list_head是Linux内核定义的双向链表包含一个指向前驱节点和后继节点的指针的结构体。其定义如下 struct list_head {struct list_head *next, *prev; //双向链表指向节点的指针 };1.1 链表的定义和初始化 有两种方式来定义和初始化链表头 方法一利用宏LIST_HEAD定义并初始化方法二先定义再利用宏INIT_LIST_HEAD初始化 //方法1利用LIST_HEAD定义并初始化链表 static LIST_HEAD(registered_llhw); //方法2先定义再初始化链表 struct list_head registered_llhw; //定义一个链表注册链路层hardware INIT_LIST_HEAD(registered_llhw); //初始化链表//相关宏定义如下 #define LIST_HEAD(name) \ struct list_head name LIST_HEAD_INIT(name)#define LIST_HEAD_INIT(name) { (name), (name)}//即初始化后链表的nexth和prev都指向自己。 #define INIT_LIST_HEAD(ptr) do { \(ptr)-next (ptr); \(ptr)-prev (ptr); \ }while(0) 1.2 链表节点增/删 使用list_add/list_add_tail来添加链表节点。 list_add(entry, ListHead);//在head之后添加 static inline void list_add(struct list_head *new, struct list_head *head) {__list_add(new, head, head-next); }static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) {next-prev new;new-next next;new-prev prev;prev-next new; }//添加到head之前即链表的尾部增加 static inline void list_add_tail(struct list_head *new, struct list_head *head) {__list_add(new, head-prev, head); }#ifdef CONFIG_ILLEGAL_POINTER_VALUE # define POISON_POINTER_DELTA _AC(CONFIG_ILLEGAL_POINTER_VALUE, UL) #else # define POISON_POINTER_DELTA 0 #endif// 定义两个特殊的宏将已经释放的节点指向这个位置避免重复删除一个已经被释放的节点避免出现潜在的漏洞。 // 实际上还起到用于标记已经删除节点的意义。 #define LIST_POISON1 ((void *) 0x00100100 POISON_POINTER_DELTA) #define LIST_POISON2 ((void *) 0x00200200 POISON_POINTER_DELTA)// 从双向链表中删除一个节点 static inline void list_del(struct list_head *entry) {__list_del_entry(entry);entry-next LIST_POISON1;entry-prev LIST_POISON2;//为什么不直接指向空指针NULL在正常环境下这个非空指针将会引起页错误。//可被用来验证没有初始化的链表节点。可以区分是被list删除的还是本身没有初始化的便于调试。 }static inline void __list_del(struct list_head *prev, struct list_head *next) {next-prev prev;WRITE_ONCE(prev-next, next); }static inline __list_del_entry(struct list_head *entry) {if(!__list_del_entry_valid(entry))return;__list_del(entry-prev, entry-next); } 1.3 遍历链表中节点 list_for_each_entry宏实际上是一个for循环利用传入的pos作为循环变量从表头head开始逐项向后next移动pos直到又回到head。 /*** list_for_each_entry - iterate over list of given type* pos: the type * to use as a loop cursor* head: the head for your list.* member: the name of the list_struct within the struct*/ #define list_for_each_entry(pos, head, member) \for(pos list_entry((head)-next, typeof(*pos), member); \prefetch(pos-member.netx), pos-member ! (head); \pos list_entry(pos-member.next, typeof(*pos), member))// prefetch是告诉CPU哪些元素有可能马上要用到预取一下可以提高速度用于预期以提高遍历速度// 从指针ptr中获取所在结构体类型type并返回结构体指针。 // member是结构体中双向链表节点的成员名。注意不能用于空链表和未初始化的链表。 /*** list_entry - get the struct for this entry* ptr: the struct list_head pointer* type: the type of the struct this is embeded in* member: the name of the list_struct within the struct */ #define list_entry(ptr, type, member) container_of(ptr, type, member)//container_of用于根据一个结构体变量中的一个域成员变量的指针来获取指向整个结构体变量的指针/*** container_of - cast a member of a structrue out to the containing structure* ptr: the pointer to the member* type: the type of the container struct this is embeded in* member: the name of the member within the struct*/ #define container_of(ptr, type, member) ({ \const typeof(((type *)0)-member )*__mptr (ptr);(type *)((char *)__mptr - offsetof(type, member)); //得到结构体的地址得到结构体指针})//强制将整型常量转换为TYPE型指针指针指向的地址为0也就是从0开始的一块存储空间映射为TYPE对象 //然后对MEMBER进行取地址由于起始地址为0也就获得MEMBER成员在TYPE中的偏移量强制无符号整型 #define offsetof(TYPE, MEMBER) ((size_t)((TYPE *)0)-MEMBER)提示对于container_ofoffsetof宏是Linux中常用的两个宏用来处理结构体与结构体成员之间的指针转化。可以多加熟练与使用在很多场景都可以得到应用。需要包含头文件stddef.h。
http://www.hkea.cn/news/14317252/

相关文章:

  • 淘宝的网站建设方案有哪些做的很漂亮的网站
  • dede5.7 做的网站 下 加一个discuz论坛东莞百度推广优化排名
  • 哪个网站可以做制图兼职做软件app需要多少钱
  • 郑州汉狮做网站网络公司网站后台申请邮箱
  • 做公众号的模版的网站网站建设公司选择哪家好
  • 高端网站建设 南京东营网站制作方案
  • 重庆网站建站价格东营 微信网站建设
  • 网站积分程序怎么建设江苏建设招标网站
  • 官网建站合作模版个人做论坛网站要什么证件
  • 经典网站建设案例wordpress外贸模板
  • 青岛建网站人知名室内设计网站
  • 网站建设 秦皇岛公司哪家好电商网页设计教程
  • 做企业网站建设公司哪家好乐潍清网站额建设
  • 网站怎么做下载链接无锡网络推广公司
  • 香河做网站湖南seo推广方法
  • net网站开发 兼职黄骅市属于
  • 本地顺德网站建设找企业名录的网站
  • php网站模板下载财务软件哪个最好用最简单
  • 建立网站 要怎么做做网站的属于什么岗位
  • 潍坊网站建设优化想找个人建网站
  • 做一静态网站 多少钱浙江1万家企业
  • 网站运营面试问题怎么成立自己的网站
  • 大学生可以做的网站网络营销怎么做有特色
  • 网站建设合同示范文本网页微信注册新号怎么注册
  • 江苏外贸网站建设腾讯云服务器用什么软件做网站
  • 红旗渠建设集团网站浙江省建设信息港岗位证书查询
  • 网站 项目 需求成都视觉设计公司
  • 怎么做网站小图标公司不需要做网站了
  • 北京网站设计有名 乐云践新简单做网站的价格
  • 辽宁住房和建设厅网站首页黑龙江省建设工程招标网站