mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 07:06:47 +00:00
doc: 更新List文档
This commit is contained in:
parent
bde283fc80
commit
7087e9fbc1
@ -60,6 +60,8 @@
|
||||
|
||||
我的邮箱:longjin@RinGoTek.cn
|
||||
|
||||
社区邮箱:contact@DragonOS.org
|
||||
|
||||
我的博客:[longjin666.cn](https://longjin666.cn)
|
||||
|
||||
## 赞赏
|
||||
|
@ -54,6 +54,8 @@
|
||||
|
||||
Email:longjin@RinGoTek.cn
|
||||
|
||||
Community Contact Email: contact@DragonOS.org
|
||||
|
||||
Blog:[longjin666.cn](https://longjin666.cn)
|
||||
|
||||
## Reward
|
||||
|
@ -30,6 +30,7 @@
|
||||
- [x] fork
|
||||
- [x] exec
|
||||
- [x] 进程睡眠(支持高精度睡眠)
|
||||
- [x] kthread机制
|
||||
|
||||
#### 同步原语
|
||||
|
||||
@ -53,6 +54,7 @@
|
||||
- [x] VFS
|
||||
- [x] fat32
|
||||
- [x] devfs
|
||||
- [x] rootfs
|
||||
|
||||
### 异常及中断处理
|
||||
|
||||
|
@ -60,6 +60,18 @@
|
||||
|
||||
  待删除的结点
|
||||
|
||||
### `list_del_init(struct List *entry)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从链表中删除结点entry,并将这个entry使用list_init()进行重新初始化。
|
||||
|
||||
#### 参数
|
||||
|
||||
**entry**
|
||||
|
||||
  待删除的结点
|
||||
|
||||
### `bool list_empty(struct List *entry)`
|
||||
|
||||
#### 描述
|
||||
@ -96,6 +108,334 @@
|
||||
|
||||
  链表中的一个结点
|
||||
|
||||
### `void list_replace(struct List *old, struct List *new)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  将链表中的old结点替换成new结点
|
||||
|
||||
#### 参数
|
||||
|
||||
**old**
|
||||
|
||||
  要被换下来的结点
|
||||
|
||||
**new**
|
||||
|
||||
  要被换入链表的新的结点
|
||||
|
||||
(_list_entry)=
|
||||
|
||||
### `list_entry(ptr, type, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  该宏能通过ptr指向的List获取到List所处的结构体的地址
|
||||
|
||||
#### 参数
|
||||
|
||||
**ptr**
|
||||
|
||||
  指向List结构体的指针
|
||||
|
||||
**type**
|
||||
|
||||
  要被换入链表的新的结点
|
||||
|
||||
**member**
|
||||
|
||||
  List结构体在上述的“包裹list结构体的结构体”中的变量名
|
||||
|
||||
### `list_first_entry(ptr, type, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  获取链表中的第一个元素。请注意,该宏要求链表非空,否则会出错。
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_entry() <_list_entry>`相同
|
||||
|
||||
### `list_first_entry_or_null(ptr, type, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  获取链表中的第一个元素。若链表为空,则返回NULL。
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_entry() <_list_entry>`相同
|
||||
|
||||
### `list_last_entry(ptr, type, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  获取链表中的最后一个元素。请注意,该宏要求链表非空,否则会出错。
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_entry() <_list_entry>`相同
|
||||
|
||||
### `list_last_entry_or_full(ptr, type, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  获取链表中的最后一个元素。若链表为空,则返回NULL。
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_entry() <_list_entry>`相同
|
||||
|
||||
(_list_next_entry)=
|
||||
### `list_next_entry(pos, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  获取链表中的下一个元素
|
||||
|
||||
#### 参数
|
||||
|
||||
**pos**
|
||||
|
||||
  指向当前的外层结构体的指针
|
||||
|
||||
**member**
|
||||
|
||||
  链表结构体在外层结构体内的变量名
|
||||
|
||||
### `list_prev_entry(pos, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  获取链表中的上一个元素
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_next_entry() <_list_next_entry>`相同
|
||||
|
||||
(_list_for_each)=
|
||||
### `list_for_each(ptr, head)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  遍历整个链表(从前往后)
|
||||
|
||||
#### 参数
|
||||
|
||||
**ptr**
|
||||
|
||||
  指向List结构体的指针
|
||||
|
||||
**head**
|
||||
|
||||
  指向链表头结点的指针(struct List*)
|
||||
|
||||
### `list_for_each_prev(ptr, head)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  遍历整个链表(从后往前)
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_for_each() <_list_for_each>`相同
|
||||
|
||||
(_list_for_each_safe)=
|
||||
### `list_for_each_safe(ptr, n, head)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从前往后遍历整个链表(支持删除当前链表结点)
|
||||
|
||||
  该宏通过暂存中间变量,防止在迭代链表的过程中,由于删除了当前ptr所指向的链表结点从而造成错误.
|
||||
|
||||
#### 参数
|
||||
|
||||
**ptr**
|
||||
|
||||
  指向List结构体的指针
|
||||
|
||||
**n**
|
||||
|
||||
  用于存储临时值的List类型的指针
|
||||
|
||||
**head**
|
||||
|
||||
  指向链表头结点的指针(struct List*)
|
||||
|
||||
### `list_for_each_prev_safe(ptr, n, head)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从后往前遍历整个链表.(支持删除当前链表结点)
|
||||
|
||||
  该宏通过暂存中间变量,防止在迭代链表的过程中,由于删除了当前ptr所指向的链表结点从而造成错误.
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_for_each_safe() <_list_for_each_safe>`相同
|
||||
|
||||
(_list_for_each_entry)=
|
||||
### `list_for_each_entry(pos, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从头开始迭代给定类型的链表
|
||||
|
||||
#### 参数
|
||||
|
||||
**pos**
|
||||
|
||||
  指向特定类型的结构体的指针
|
||||
|
||||
**head**
|
||||
|
||||
  指向链表头结点的指针(struct List*)
|
||||
|
||||
**member**
|
||||
|
||||
  struct List在pos的结构体中的成员变量名
|
||||
|
||||
### `list_for_each_entry_reverse(pos, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  逆序迭代给定类型的链表
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_for_each_entry() <_list_for_each_entry>`相同
|
||||
|
||||
### `list_for_each_entry_safe(pos, n, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从头开始迭代给定类型的链表(支持删除当前链表结点)
|
||||
|
||||
#### 参数
|
||||
|
||||
**pos**
|
||||
|
||||
  指向特定类型的结构体的指针
|
||||
|
||||
**n**
|
||||
|
||||
  用于存储临时值的,和pos相同类型的指针
|
||||
|
||||
**head**
|
||||
|
||||
  指向链表头结点的指针(struct List*)
|
||||
|
||||
**member**
|
||||
|
||||
  struct List在pos的结构体中的成员变量名
|
||||
|
||||
### `list_prepare_entry(pos, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  为{ref}`list_for_each_entry_continue() <_list_for_each_entry_continue>`准备一个'pos'结构体
|
||||
|
||||
#### 参数
|
||||
|
||||
**pos**
|
||||
|
||||
  指向特定类型的结构体的,用作迭代起点的指针
|
||||
|
||||
**head**
|
||||
|
||||
  指向要开始迭代的struct List结构体的指针
|
||||
|
||||
**member**
|
||||
|
||||
  struct List在pos的结构体中的成员变量名
|
||||
|
||||
(_list_for_each_entry_continue)=
|
||||
### `list_for_each_entry_continue(pos, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从指定的位置的【下一个元素开始】,继续迭代给定的链表
|
||||
|
||||
#### 参数
|
||||
|
||||
**pos**
|
||||
|
||||
  指向特定类型的结构体的指针。该指针用作迭代的指针。
|
||||
|
||||
**head**
|
||||
|
||||
  指向要开始迭代的struct List结构体的指针
|
||||
|
||||
**member**
|
||||
|
||||
  struct List在pos的结构体中的成员变量名
|
||||
|
||||
### `list_for_each_entry_continue_reverse(pos, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从指定的位置的【上一个元素开始】,【逆序】迭代给定的链表
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_for_each_entry_continue() <_list_for_each_entry_continue>`的相同
|
||||
|
||||
### `list_for_each_entry_from(pos, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从指定的位置开始,继续迭代给定的链表
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_for_each_entry_continue() <_list_for_each_entry_continue>`的相同
|
||||
|
||||
(_list_for_each_entry_safe_continue)=
|
||||
### `list_for_each_entry_safe_continue(pos, n, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从指定的位置的【下一个元素开始】,继续迭代给定的链表.(支持删除当前链表结点)
|
||||
|
||||
#### 参数
|
||||
|
||||
**pos**
|
||||
|
||||
  指向特定类型的结构体的指针。该指针用作迭代的指针。
|
||||
|
||||
**n**
|
||||
|
||||
  用于存储临时值的,和pos相同类型的指针
|
||||
|
||||
**head**
|
||||
|
||||
  指向要开始迭代的struct List结构体的指针
|
||||
|
||||
**member**
|
||||
|
||||
  struct List在pos的结构体中的成员变量名
|
||||
|
||||
### `list_for_each_entry_safe_continue_reverse(pos, n, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从指定的位置的【上一个元素开始】,【逆序】迭代给定的链表。(支持删除当前链表结点)
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_for_each_entry_safe_continue() <_list_for_each_entry_safe_continue>`的相同
|
||||
|
||||
### `list_for_each_entry_safe_from(pos, n, head, member)`
|
||||
|
||||
#### 描述
|
||||
|
||||
  从指定的位置开始,继续迭代给定的链表.(支持删除当前链表结点)
|
||||
|
||||
#### 参数
|
||||
|
||||
  与{ref}`list_for_each_entry_safe_continue() <_list_for_each_entry_safe_continue>`的相同
|
||||
|
||||
---
|
||||
|
||||
## 基础C函数库
|
||||
|
@ -214,7 +214,7 @@ static inline struct List *list_next(struct List *entry)
|
||||
for ((ptr) = (head)->prev; (ptr) != (head); (ptr) = (ptr)->prev)
|
||||
|
||||
/**
|
||||
* @brief 遍历整个链表(从前往后)(支持链表的删除操作)
|
||||
* @brief 遍历整个链表(从前往后)(支持删除当前链表结点)
|
||||
* 该宏通过暂存中间变量,防止在迭代链表的过程中,由于删除了当前ptr所指向的链表结点从而造成错误
|
||||
*
|
||||
* @param ptr the &struct list_head to use as a loop cursor.
|
||||
|
Loading…
x
Reference in New Issue
Block a user