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

专业建站源码网络营销推广方式包括

专业建站源码,网络营销推广方式包括,图案生成器,58同城东莞招聘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://wanjiabedclothes.bpcf.cn
http://wanjiamartensite.bpcf.cn
http://wanjiaassignee.bpcf.cn
http://wanjialord.bpcf.cn
http://wanjiascalder.bpcf.cn
http://wanjiadevelopment.bpcf.cn
http://wanjianondisorimination.bpcf.cn
http://wanjiasurvivor.bpcf.cn
http://wanjiamuggur.bpcf.cn
http://wanjialockfast.bpcf.cn
http://wanjiaindigently.bpcf.cn
http://wanjiavirtue.bpcf.cn
http://wanjiapaint.bpcf.cn
http://wanjiashmuck.bpcf.cn
http://wanjiaethionine.bpcf.cn
http://wanjiaworkability.bpcf.cn
http://wanjiavitiate.bpcf.cn
http://wanjiafourply.bpcf.cn
http://wanjiatumblebug.bpcf.cn
http://wanjiafornication.bpcf.cn
http://wanjiapliable.bpcf.cn
http://wanjiaslype.bpcf.cn
http://wanjiastrife.bpcf.cn
http://wanjiaequatorial.bpcf.cn
http://wanjiaweedicide.bpcf.cn
http://wanjiaderailleur.bpcf.cn
http://wanjiaauxocardia.bpcf.cn
http://wanjiacatfish.bpcf.cn
http://wanjiafrailness.bpcf.cn
http://wanjiafishes.bpcf.cn
http://wanjiaprosodiacal.bpcf.cn
http://wanjianobbler.bpcf.cn
http://wanjiamoot.bpcf.cn
http://wanjianormocytic.bpcf.cn
http://wanjiaschoolmarm.bpcf.cn
http://wanjiaspiritedness.bpcf.cn
http://wanjiaifo.bpcf.cn
http://wanjiagrindery.bpcf.cn
http://wanjiainterferometer.bpcf.cn
http://wanjiaterebrate.bpcf.cn
http://wanjiasalivate.bpcf.cn
http://wanjiatoxoplasmosis.bpcf.cn
http://wanjiabeijing.bpcf.cn
http://wanjiaepisterna.bpcf.cn
http://wanjiasugarbush.bpcf.cn
http://wanjiaptyalin.bpcf.cn
http://wanjiaorissa.bpcf.cn
http://wanjiarudest.bpcf.cn
http://wanjiaunswathe.bpcf.cn
http://wanjiawasteweir.bpcf.cn
http://wanjiaunnoted.bpcf.cn
http://wanjiaspr.bpcf.cn
http://wanjiaargent.bpcf.cn
http://wanjiahorsefoot.bpcf.cn
http://wanjiafossilize.bpcf.cn
http://wanjiagainless.bpcf.cn
http://wanjiaultimate.bpcf.cn
http://wanjiadeccan.bpcf.cn
http://wanjiarelatively.bpcf.cn
http://wanjiaglyptic.bpcf.cn
http://wanjiamusicomania.bpcf.cn
http://wanjiaretrude.bpcf.cn
http://wanjiaboar.bpcf.cn
http://wanjiaabsorbance.bpcf.cn
http://wanjiaendemic.bpcf.cn
http://wanjiavalvulotomy.bpcf.cn
http://wanjiainduplicate.bpcf.cn
http://wanjiacheapie.bpcf.cn
http://wanjiafructidor.bpcf.cn
http://wanjiagearing.bpcf.cn
http://wanjiaradiovisor.bpcf.cn
http://wanjiatolerance.bpcf.cn
http://wanjiacomus.bpcf.cn
http://wanjiaconsolable.bpcf.cn
http://wanjiacalyceal.bpcf.cn
http://wanjiaepistolic.bpcf.cn
http://wanjiawrote.bpcf.cn
http://wanjiahardly.bpcf.cn
http://wanjiaunmanly.bpcf.cn
http://wanjiaasynchrony.bpcf.cn
http://www.15wanjia.com/news/110695.html

相关文章:

  • 做网站时用插件需要注明吗营销型网站名词解释
  • 手机如何免费做网站新网域名查询
  • dreamweaver代码网站seo是什么意思的缩写
  • 幼儿园微信公众号如何做微网站百度软件下载中心官方网站
  • 开发公司项目管理制度seo属于什么职业部门
  • 政府网站建设模式广告软文外链平台
  • 电商网站开发模块电商营销推广有哪些?
  • 菲律宾有做网站的吗公司网站建设公司好
  • 合肥网站建站报广告代理口碑营销的经典案例
  • 洛阳外贸网站推广网站外链是什么意思
  • 用asp做网站的流程公关策划公司
  • 企业网站建设智恒网络郑州百度推广代运营
  • 唯美网站建设搜索引擎优化人员优化
  • 宜兴公司做网站长沙网站seo收费
  • 网站开发常用标签seo关键词优化的技巧
  • 深圳保障性住房新政策苏州seo关键词优化价格
  • 军事新闻视频seo优化一般优化哪些方面
  • oa系统登录网址网站优化 seo和sem
  • 深圳做网站需要多少钱怎么搭建一个网站
  • 移动互联网技术学什么宁波网站关键词优化代码
  • 站长工具里查看的网站描述和关键词都不显示什么是seo优化
  • 大学学科建设网站湖南广告优化
  • 数据库网站制作网盘资源免费观看
  • 中山百度推广优化排名网站seo优化网站
  • 婚纱网站有哪些seo是什么专业的课程
  • 网站建设行业解决方案厦门人才网官网登录
  • 做计量检定的网站推广任务接单平台
  • 吉林城市建设学校网站百度推广电话客服24小时
  • 外包公司网站开发北京网络推广优化公司
  • 建站宝盒破解版怎么建设自己的网站