#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的更多相关文章

  1. APUE中fcntl.h的使用及O_SYNC在Mac与Ubuntu下的测试

    此部分测试涉及到APUE V3中,第三章的图3-12到图3-14. 通过fcntl.h提供的功能,修改fd的文件属性,本处增加O_SYNC功能,并测试其效果. 本文涉及代码: tree ch3 ch3 ...

  2. 关于apue.3e中apue.h的使用

    关于apue.3e中apue.h的使用 近来要学一遍APUE第三版,并于此开博做为记录. 先下载源文件: # url: http://http//www.apuebook.com/code3e.htm ...

  3. YYModel 源码解读(二)之NSObject+YYModel.h (1)

    本篇文章主要介绍 _YYModelPropertyMeta 前边的内容 首先先解释一下前边的辅助函数和枚举变量,在写一个功能的时候,这些辅助的东西可能不是一开始就能想出来的,应该是在后续的编码过程中 ...

  4. YYModel 源码解读(一)之YYModel.h

    #if __has_include(<YYModel/YYModel.h>) FOUNDATION_EXPORT double YYModelVersionNumber; FOUNDATI ...

  5. error RC1015: cannot open include file 'afxres.h' 解决办法

    在为WindowsPhone8程序添加本地化的过程中遇到这个问题: 问题原因就是afxres.h文件缺失,下载它,放到VS安装目录下的VS\include目录下就可以了(选择目录的时候注意对应对版本) ...

  6. afxcomctl32.h与afxcomctl32.inl报错

    afxcomctl32.h与afxcomctl32.inl报错 编译公司一个几年前的老项目,是从VC6.0升级到VS2005的. 1.编译时报缺少头文件,于是附件包含目录,于是出现了以下报错: 1&g ...

  7. C标准头文件<math.h>

    定义域错误可以理解为超出了函数的适用范围,如果发生了定义域错误,设errno为EDOM 如果结果不能表示为double值,则发生值域错误,如果结果上溢,则函数返回HUGE_VAL的值,设errno为E ...

  8. C标准头文件<ctype.h>

    主要包括了一些字符识别和转换函数 字符判断 isalnum() //函数原型 #include<ctype.h> int isalum(int c); 功能:如果输入的字符是字母(alph ...

  9. xcode中的.h和.m文件分别是什么意思?各有什么用?

    .h 表示头文件,用来声明各种成员变量,方法,属性之类的.在import的时候用头文件. .m 主要用来实现.h 里声明的方法.举个例子,如果要写一个方法,你要在.h里先声明: - (void)myM ...

  10. __dbg.h

    #ifndef __HSS_DBG_HSS__ #define __HSS_DBG_HSS__ /*************************************************** ...

随机推荐

  1. 第三篇——第二部分——第五文 配置SQL Server镜像——域环境SQL Server镜像日常维护

    本文接上面两篇搭建镜像的文章: 第三篇--第二部分--第三文 配置SQL Server镜像--域环境:http://blog.csdn.net/dba_huangzj/article/details/ ...

  2. C和指针 (pointers on C)——第四章:语句(上)

    第四章--语句(上) 总结总结!!! C没有布尔类型,所以在一些逻辑推断时候必须用整型表达式,零值为假,非零值为真. for比while把控制循环的表达式收集起来放在一个地方,以便寻找. do语句比w ...

  3. PureMVC(JS版)源码解析(六):MacroCommand类

    上一篇博客,我们讲解了SimpleCommand类,接下来我们看一下与SimpleCommand类很相似的MacroCommand类. MacroCommand类和SimpleCommand类一样,都 ...

  4. ServletContext对象--三大域对象

    Servlet三大域对象的应用 request.session.application(ServletContext) ServletContext是一个全局的储存信息的空间,服务器开始就存在,服务器 ...

  5. GUI编程笔记(java)03:GUI的组件继承图

    1.组件继承图: 2.分析上面的组件继承图 (1)Component:public abstract class Component extends Object implements ImageOb ...

  6. android线程与线程池-----AsyncTask(一)《android开发艺术与探索》

    线程在android是个重要的概念,从用途上讲,线程分为主线程和子线程,主线程负责页面相关,子线程负责耗时操作. 在android中除了Thread本身还有 AsyncTask  IntentServ ...

  7. js常用笔记

    此文仅为笔记,代码来源自网络 网络技术文档:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript 1.使用||和&&简化语句, ...

  8. 学习使用Et采集的过程和分析

  9. MES项目中出现的一个事务嵌套的使用场景

    昨天在MES项目中,需要在业务逻辑的几个关键点记录错误信息,需要把错误信息写入数据表. 但是由于整个业务逻辑都是包在一个事务模板里面的 比如这样的: WhhTransactionTemplate tr ...

  10. JQuery Datatables(二)

    前篇讲到了Datatables的基本用法,链接地址:http://www.cnblogs.com/wumian1360/p/4263129.html 今天来实现5,6,7三点. 其实Datatable ...