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__ /*************************************************** ...
随机推荐
- git 命令归纳
git 新手一枚,随用随更新 git clone git@example.com:project-name.git 克隆 git branch [-a -r] 查看分支[所有 远端] git pull ...
- Struts工作流程
Java Web 都是使用线程来处理用户的请求(request)的,一次请求对应一个处理线程.Struts 2会为每个处理线程分配一个Action对象, 将提交的参数注射到Action属性中,并调用A ...
- 使用Git操作GitHub代码入门教程
GitHub除了网页操作外,还可以借助本地客户端git(或github for windows)来增删修改远程代码.使用Git操作来连接GitHub可以通过Https或SSH方式,使用SSH方式可以免 ...
- CXF错误:Unsupported major.minor version 51.0,java.lang.UnsupportedClassVersionErro
CXF错误:Unsupported major.minor version 51.0 java.lang.UnsupportedClassVersionError >>>>&g ...
- 3G/4G网卡使用
整体架构: pppd call option & ----------↓---------- option脚本(设置PPP连接) ----------↓---------- chat脚本(进行 ...
- JDK1.8聚合操作
在java8 JDK包含许多聚合操作(如平均值,总和,最小,最大,和计数),返回一个计算流stream的聚合结果.这些聚合操作被称为聚合操作.JDK除返回单个值的聚合操作外,还有很多聚合操作返回一个c ...
- javascript 【js‘s word】
http://mp.weixin.qq.com/s?__biz=MjM5MzY2NDY0Ng==&mid=214013689&idx=1&sn=21e03f6c7bf73893 ...
- Socket服务器整体架构概述
转载:http://www.cnblogs.com/tianzhiliang/archive/2010/10/28/1863684.html Socket服务器主要用于提供高效.稳定的数据处理.消息转 ...
- OPENQUERY
SELECT * FROM OPENQUERY(saql007,' SELECT col1,col2,col3 FROM dbname.shemaname.tablename WHERE (1=1 ...
- 15第十五章UDF用户自定义函数(转载)
15第十五章UDF用户自定义函数 待补上 原文链接 本文由豆约翰博客备份专家远程一键发布