kernel_list.h
/*
* kernel_list.h
* 描述:
* 此为内核链表结构(循环链表)
*/
#pragma once
#include <stdio.h>
struct list_head
{
struct list_head *prev;
struct list_head *next;
};
#define LIST_HEAD(name) struct list_head name={&(name),&(name)}
/*
* 初始化链表
*/
static inline void INIT_LIST_HEAD(struct list_head *node)
{
node->prev = node;
node->next = node;
}
/*
* 在prev与next节点之间插入节点new_node
*/
static inline void __list_add(struct list_head *new_node,struct list_head *prev,struct list_head *next)
{
prev->next = new_node;
next->prev = new_node;
new_node->prev = prev;
new_node->next = next;
}
/*
* 头插
*/
static inline void list_add(struct list_head *new_node,struct list_head *head)
{
__list_add(new_node,head,head->next);
}
/*
* 尾插
*/
static inline void list_add_tail(struct list_head *new_node,struct list_head *head)
{
__list_add(new_node,head->prev,head);
}
/