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__ /*************************************************** ...
随机推荐
- Matlab mex编程
经典教程:mex 编程 http://classes.soe.ucsc.edu/ee264/Fall11/cmex.pdf Matlab 快速编程: http://www.ee.columbia.ed ...
- oracle3
查看表结构 DESC emp; 查询所有列 SELECT * FROM dept; 切忌动不动就用select * set timing on; 打开显示操作时间的开关,在下面显示查询时间. CREA ...
- 在String中添加移动构造函数和移动赋值运算符
13.50 没有定义析构函数 #include<iostream> #include<string> #include<memory> #include<ut ...
- xcode 4 安装cocos2d-x 2.1.4
http://blog.csdn.net/xiaominghimi/article/details/6937685 从今天开始Himi将陆续更新cocos2d-X的博文,毕竟cocos2d-X的跨平台 ...
- webservice 生成代理类
webservice的调用方式有两种: 1. 直接在vs ide中通过web引用的方式,将发布于某个位置的web服务引进到工程里面.这种方式基本上会用vs.net的人都会. 2. 通过vs 命令提 ...
- Objhdu2001java
计算两点间的距离 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- NDK开发之日志打印
要在NDK中打印日志,只需要以下三步: 一.在Android.mk中添加以下内容: LOCAL_LDLIBS := -lm -llog 或者 LOCAL_LDLIBS:=-L$(SYSROOT)/us ...
- oracle常用数据类型
oracle中常用数据类型分为三大类:
- Android 开发实践 ViewGroup 实现左右滑出窗口(二)
接上一篇 <Android 开发实践 ViewGroup 实现左右滑出窗口(一)http://www.cnblogs.com/inkheart0124/p/3532862.html> 源码 ...
- SqlServer循环读取配置
USE [DB_JP_BaseInfo00] GO /****** Object: StoredProcedure [dbo].[sp_wx_getAppointmentInfo_Str] Scrip ...