list.h
#ifndef LISTHHHHHHH
#define LISTHHHHHHH #include "common.h" /* stolen from kernel */ typedef struct list_node {
struct list_node *next;
struct list_node *prev;
} list_node_t; typedef struct list_head {
struct list_node n;
} list_head_t; #define LIST_HEAD_INIT(name) { { &(name.n), &(name.n) } }
#define LIST_NODE_INIT { NULL, NULL } #define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
#define LIST_NODE(name) \
struct list_node name = LIST_NODE_INIT static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->n.next = &list->n;
list->n.prev = &list->n;
} static inline void INIT_LIST_NODE(struct list_node *list)
{
list->next = NULL;
list->prev = NULL;
} #define list_first_entry(head, type, member) \
list_entry((head)->n.next, type, member) static inline bool list_empty(const struct list_head *head)
{
return head->n.next == &head->n;
} static inline bool list_linked(const struct list_node *node)
{
return node->next != NULL;
} #define list_entry(ptr, type, member) \
container_of(ptr, type, member) #define list_for_each(pos, head) \
for (typeof(pos) LOCAL(n) = (pos = (head)->n.next, pos->next); \
pos != &(head)->n; \
pos = LOCAL(n), LOCAL(n) = pos->next) #define list_for_each_entry(pos, head, member) \
for (typeof(pos) LOCAL(n) = (pos = list_entry((head)->n.next, \
typeof(*pos), \
member), \
list_entry(pos->member.next, \
typeof(*pos), \
member)); \
&pos->member != &(head)->n; \
pos = LOCAL(n), LOCAL(n) = list_entry(LOCAL(n)->member.next, \
typeof(*LOCAL(n)), \
member)) static inline void __list_add(struct list_node *new,
struct list_node *prev, struct list_node *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
} static inline void list_add(struct list_node *new, struct list_head *head)
{
__list_add(new, &head->n, head->n.next);
} static inline void list_add_tail(struct list_node *new, struct list_head *head)
{
__list_add(new, head->n.prev, &head->n);
} static inline void __list_del(struct list_node *prev, struct list_node *next)
{
next->prev = prev;
prev->next = next;
} static inline void __list_del_entry(struct list_node *entry)
{
__list_del(entry->prev, entry->next);
} static inline void list_del(struct list_node *entry)
{
__list_del(entry->prev, entry->next);
entry->next = entry->prev = NULL;
} static inline void list_move(struct list_node *list, struct list_head *head)
{
__list_del_entry(list);
list_add(list, head);
} static inline void list_move_tail(struct list_node *list,
struct list_head *head)
{
__list_del_entry(list);
list_add_tail(list, head);
} static inline void __list_splice(const struct list_head *list,
struct list_node *prev, struct list_node *next)
{
struct list_node *first = list->n.next;
struct list_node *last = list->n.prev; first->prev = prev;
prev->next = first; last->next = next;
next->prev = last;
} static inline void list_splice_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, &head->n, head->n.next);
INIT_LIST_HEAD(list);
}
} static inline void list_splice_tail_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head->n.prev, &head->n);
INIT_LIST_HEAD(list);
}
} #endif
list.h的更多相关文章
- APUE中fcntl.h的使用及O_SYNC在Mac与Ubuntu下的测试
		此部分测试涉及到APUE V3中,第三章的图3-12到图3-14. 通过fcntl.h提供的功能,修改fd的文件属性,本处增加O_SYNC功能,并测试其效果. 本文涉及代码: tree ch3 ch3 ... 
- 关于apue.3e中apue.h的使用
		关于apue.3e中apue.h的使用 近来要学一遍APUE第三版,并于此开博做为记录. 先下载源文件: # url: http://http//www.apuebook.com/code3e.htm ... 
- YYModel 源码解读(二)之NSObject+YYModel.h (1)
		本篇文章主要介绍 _YYModelPropertyMeta 前边的内容 首先先解释一下前边的辅助函数和枚举变量,在写一个功能的时候,这些辅助的东西可能不是一开始就能想出来的,应该是在后续的编码过程中 ... 
- YYModel 源码解读(一)之YYModel.h
		#if __has_include(<YYModel/YYModel.h>) FOUNDATION_EXPORT double YYModelVersionNumber; FOUNDATI ... 
- error RC1015: cannot open include file 'afxres.h' 解决办法
		在为WindowsPhone8程序添加本地化的过程中遇到这个问题: 问题原因就是afxres.h文件缺失,下载它,放到VS安装目录下的VS\include目录下就可以了(选择目录的时候注意对应对版本) ... 
- afxcomctl32.h与afxcomctl32.inl报错
		afxcomctl32.h与afxcomctl32.inl报错 编译公司一个几年前的老项目,是从VC6.0升级到VS2005的. 1.编译时报缺少头文件,于是附件包含目录,于是出现了以下报错: 1&g ... 
- C标准头文件<math.h>
		定义域错误可以理解为超出了函数的适用范围,如果发生了定义域错误,设errno为EDOM 如果结果不能表示为double值,则发生值域错误,如果结果上溢,则函数返回HUGE_VAL的值,设errno为E ... 
- C标准头文件<ctype.h>
		主要包括了一些字符识别和转换函数 字符判断 isalnum() //函数原型 #include<ctype.h> int isalum(int c); 功能:如果输入的字符是字母(alph ... 
- xcode中的.h和.m文件分别是什么意思?各有什么用?
		.h 表示头文件,用来声明各种成员变量,方法,属性之类的.在import的时候用头文件. .m 主要用来实现.h 里声明的方法.举个例子,如果要写一个方法,你要在.h里先声明: - (void)myM ... 
- __dbg.h
		#ifndef __HSS_DBG_HSS__ #define __HSS_DBG_HSS__ /*************************************************** ... 
随机推荐
- CreateEvent的使用方法
			CreateEvent的使用方法收藏 新一篇: PreCreateWindow的作用和用法 | 旧一篇: VC中_T()的作用 function StorePage(){d=document;t=d ... 
- 百度的android采访分析
			今天早上10分,我接到一个电话采访百度.当然,我说提前.我的病是多么强烈延迟.所以我也没怎么准备,当然,我也看他们的真实水平的思考.在这次审查中! ! ! ! ! !! .! ! ! !.!! !.! ... 
- 购买SSD固态硬盘须当心,你知道什么是SLC、 MLC、TLC闪存芯片颗粒吗?
			固态硬盘凭借其存取速率超快等自身优势,被越来越多的电脑爱好者所青睐,并迅速普及到了广大用户的电脑中,因为固态硬盘与传统机械硬盘相比,确实在运行效率等方面有了质的提升,但是亦是美网络小编要提醒大家的是, ... 
- JPA entity versioning (@Version and Optimistic Locking)
			详情见: http://www.byteslounge.com/tutorials/jpa-entity-versioning-version-and-optimistic-locking 
- easyui-treegrid移除树节点出错
			easyui-treegrid移除树节点出错 >>>>>>>>>>>>>>>>>>>& ... 
- PS之放射背景
			效果图 素材 新建图层,填充颜色 新建图层,矩形工具画条形 滤镜-扭曲-极坐标 合并图层,效果如下 新建图层,画一个适当的圆 滤镜-模糊-高斯模糊 将素材人物抠出来放在中间 
- ECshop--导航栏模块细究
			花了一下午的时间,总算解决了. 本来想在前台界面上分析看看ecshop导航栏设置,在浏览器里面是定位到了"nav-manu"下面,然后子目录是在m_left下可以看到是动态生成一系 ... 
- 删除mysql重复记录的办法
			网上有很多的办法,但是大多数都是通过临时表的办法,其实你是可以用一句简单的sql就可以做到: alter ignore table SOMETABLE add primary key(fields n ... 
- python 简明教程笔记
			1,python特点 python 注重的是如何解决问题,而不是语法和结构简单高效.扩展性 2,安装 python python -V 检测是否安装pythonctrl+d ... 
- [IO] C# INI文件读写类与源码下载 (转载)
			/// <summary> /// 类说明:INI文件读写类. /// 编 码 人:苏飞 /// 联系方式:361983679 /// 更新网站:[url]http://www.sufei ... 
