queue.h中是qemu使用到的一些基础的数据结构,比如QLIST,QSLIST,QSIMPLEQ,QTAILQ。
本文主要介绍QLIST的数据结构,其它几种数据结构与之类似。
需要注意entry是嵌入在其他结构体(elm)中使用,QLIST是elm的链表,不是entry的链表。
HEAD
#define QLIST_HEAD(name, type) \
struct name { \
struct type *lh_first; /* first element */ \
}
lh_first表示list head first
head的静态初始化:
#define QLIST_HEAD_INITIALIZER(head) \
{ NULL }
head的动态初始化:
#define QLIST_INIT(head) do { \
(head)->lh_first = NULL; \
} while