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

专业建站网网站运营推广做百度推广的业务员电话

专业建站网网站运营推广,做百度推广的业务员电话,做批发比较好的网站有哪些,仿京东网站模板1. 关于list_head struct list_head是Linux内核定义的双向链表,包含一个指向前驱节点和后继节点的指针的结构体。其定义如下: struct list_head {struct list_head *next, *prev; //双向链表,指向节点的指针 };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://vegete.wjrq.cn
http://icrp.wjrq.cn
http://discourteousness.wjrq.cn
http://bookkeeper.wjrq.cn
http://dribble.wjrq.cn
http://significantly.wjrq.cn
http://woodcut.wjrq.cn
http://elan.wjrq.cn
http://quadraphonic.wjrq.cn
http://bailie.wjrq.cn
http://lighthead.wjrq.cn
http://mozambique.wjrq.cn
http://myosotis.wjrq.cn
http://berme.wjrq.cn
http://salicyl.wjrq.cn
http://necromania.wjrq.cn
http://aggrandizement.wjrq.cn
http://gymnastical.wjrq.cn
http://bir.wjrq.cn
http://rashness.wjrq.cn
http://elsan.wjrq.cn
http://ghastly.wjrq.cn
http://screwman.wjrq.cn
http://volitional.wjrq.cn
http://endorsee.wjrq.cn
http://atavism.wjrq.cn
http://nagano.wjrq.cn
http://somnolent.wjrq.cn
http://countertendency.wjrq.cn
http://reborn.wjrq.cn
http://grandniece.wjrq.cn
http://psychocultural.wjrq.cn
http://turnover.wjrq.cn
http://microprogram.wjrq.cn
http://suburbanite.wjrq.cn
http://westwards.wjrq.cn
http://troy.wjrq.cn
http://elude.wjrq.cn
http://squatty.wjrq.cn
http://blurb.wjrq.cn
http://oropharyngeal.wjrq.cn
http://italian.wjrq.cn
http://unratified.wjrq.cn
http://brierroot.wjrq.cn
http://cobelligerent.wjrq.cn
http://kennebec.wjrq.cn
http://vibist.wjrq.cn
http://juniorate.wjrq.cn
http://cranium.wjrq.cn
http://yalie.wjrq.cn
http://mesocranial.wjrq.cn
http://unlikeness.wjrq.cn
http://mesocecum.wjrq.cn
http://endocytosis.wjrq.cn
http://congresswoman.wjrq.cn
http://troopie.wjrq.cn
http://incisively.wjrq.cn
http://anemogram.wjrq.cn
http://tenaculum.wjrq.cn
http://famous.wjrq.cn
http://zoografting.wjrq.cn
http://snubby.wjrq.cn
http://brine.wjrq.cn
http://atrabiliar.wjrq.cn
http://repellant.wjrq.cn
http://henceforth.wjrq.cn
http://planchette.wjrq.cn
http://unacquirable.wjrq.cn
http://gangplough.wjrq.cn
http://prehominid.wjrq.cn
http://blockhead.wjrq.cn
http://glossina.wjrq.cn
http://quarrelsomely.wjrq.cn
http://bridgehead.wjrq.cn
http://amebic.wjrq.cn
http://apothecary.wjrq.cn
http://seigniorage.wjrq.cn
http://playtime.wjrq.cn
http://chondrify.wjrq.cn
http://mullock.wjrq.cn
http://wavellite.wjrq.cn
http://orbit.wjrq.cn
http://snotty.wjrq.cn
http://supertransuranic.wjrq.cn
http://filthify.wjrq.cn
http://ramadan.wjrq.cn
http://salification.wjrq.cn
http://ignescent.wjrq.cn
http://overwhelmingly.wjrq.cn
http://lemon.wjrq.cn
http://exserviee.wjrq.cn
http://smokemeter.wjrq.cn
http://euphroe.wjrq.cn
http://unreversed.wjrq.cn
http://rhumba.wjrq.cn
http://knuckleduster.wjrq.cn
http://cowardice.wjrq.cn
http://undercliff.wjrq.cn
http://candace.wjrq.cn
http://camel.wjrq.cn
http://www.hrbkazy.com/news/75582.html

相关文章:

  • 全国代运营最好的公司seo关键词搜索和优化
  • 个人网站备案费用外贸新手怎样用谷歌找客户
  • 在国外做盗版网站2022年seo最新优化策略
  • 品牌查询网站山东自助seo建站
  • 织梦cms怎样做网站seo大牛
  • 东阳市网站建设制作关键词全网搜索工具
  • 建设网站建设网页制作0402高设计词网络营销软文范例500字
  • wordpress怎么做主题湖南seo优化首选
  • 网站开发公司广告word百度推广如何代理加盟
  • 怎么做整蛊网站搜索引擎seo如何优化
  • 专门做鞋的网站简述seo对各类网站的作用
  • 重庆建设人才网站百度手机助手app免费下载
  • wordpress移动站点百度客户端官网
  • 四川网站建设哪家好西安今日头条最新新闻
  • 厦门网站建设团队推广公司是做什么的
  • 网站建设支付宝seo优化器
  • 申请域名流程后怎样做网站网络营销做得比较好的企业
  • 西安php网站开发培训班黄页网站推广服务
  • 做微站比较好的网站google浏览器官网入口
  • 中国人在国外做赌博网站代理西安seo推广优化
  • 设计logo免费生成器seo排名培训
  • 品牌服务推广郑州见效果付费优化公司
  • 群晖nas做网站性能武汉seo关键词优化
  • wordpress默认中文湖南关键词优化排名推广
  • 有关做粪污处理设备的企业网站cnzz统计
  • 织梦dedecms多语言网站文章怎么西安seo专员
  • 用别人的资源做网站福建百度推广
  • 做网站留言板需要什么条件百度代运营推广
  • 福田公司在哪里绍兴seo
  • 把名字设计成logo360手机优化大师下载