⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.h

📁 fast lua plugin indexing module, can cache lua bytecode functions for c programs. useful for buildin
💻 H
📖 第 1 页 / 共 2 页
字号:
 * @pos:	the &struct list_head to use as a loop cursor. * @n:		another &struct list_head to use as temporary storage * @head:	the head for your list. */#define list_for_each_safe(pos, n, head) \	for (pos = (head)->next, n = pos->next; pos != (head); \		pos = n, n = pos->next)/** * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry * @pos:	the &struct list_head to use as a loop cursor. * @n:		another &struct list_head to use as temporary storage * @head:	the head for your list. */#define list_for_each_prev_safe(pos, n, head) \	for (pos = (head)->prev, n = pos->prev; \	     pos != (head); \	     pos = n, n = pos->prev)/** * list_for_each_entry	-	iterate over list of given type * @pos:	the type * to use as a loop cursor. * @head:	the head for your list. * @member:	the name of the list_struct within the struct. */#define list_for_each_entry(pos, head, member)				\	for (pos = list_entry((head)->next, typeof(*pos), member);	\	     &pos->member != (head); 	\	     pos = list_entry(pos->member.next, typeof(*pos), member))/** * list_for_each_entry_reverse - iterate backwards over list of given type. * @pos:	the type * to use as a loop cursor. * @head:	the head for your list. * @member:	the name of the list_struct within the struct. */#define list_for_each_entry_reverse(pos, head, member)			\	for (pos = list_entry((head)->prev, typeof(*pos), member);	\	     &pos->member != (head); 	\	     pos = list_entry(pos->member.prev, typeof(*pos), member))/** * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() * @pos:	the type * to use as a start point * @head:	the head of the list * @member:	the name of the list_struct within the struct. * * Prepares a pos entry for use as a start point in list_for_each_entry_continue(). */#define list_prepare_entry(pos, head, member) \	((pos) ? : list_entry(head, typeof(*pos), member))/** * list_for_each_entry_continue - continue iteration over list of given type * @pos:	the type * to use as a loop cursor. * @head:	the head for your list. * @member:	the name of the list_struct within the struct. * * Continue to iterate over list of given type, continuing after * the current position. */#define list_for_each_entry_continue(pos, head, member) 		\	for (pos = list_entry(pos->member.next, typeof(*pos), member);	\	     &pos->member != (head);	\	     pos = list_entry(pos->member.next, typeof(*pos), member))/** * list_for_each_entry_continue_reverse - iterate backwards from the given point * @pos:	the type * to use as a loop cursor. * @head:	the head for your list. * @member:	the name of the list_struct within the struct. * * Start to iterate over list of given type backwards, continuing after * the current position. */#define list_for_each_entry_continue_reverse(pos, head, member)		\	for (pos = list_entry(pos->member.prev, typeof(*pos), member);	\	     &pos->member != (head);	\	     pos = list_entry(pos->member.prev, typeof(*pos), member))/** * list_for_each_entry_from - iterate over list of given type from the current point * @pos:	the type * to use as a loop cursor. * @head:	the head for your list. * @member:	the name of the list_struct within the struct. * * Iterate over list of given type, continuing from current position. */#define list_for_each_entry_from(pos, head, member) 			\	for (; &pos->member != (head);	\	     pos = list_entry(pos->member.next, typeof(*pos), member))/** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos:	the type * to use as a loop cursor. * @n:		another type * to use as temporary storage * @head:	the head for your list. * @member:	the name of the list_struct within the struct. */#define list_for_each_entry_safe(pos, n, head, member)			\	for (pos = list_entry((head)->next, typeof(*pos), member),	\		n = list_entry(pos->member.next, typeof(*pos), member);	\	     &pos->member != (head); 					\	     pos = n, n = list_entry(n->member.next, typeof(*n), member))/** * list_for_each_entry_safe_continue * @pos:	the type * to use as a loop cursor. * @n:		another type * to use as temporary storage * @head:	the head for your list. * @member:	the name of the list_struct within the struct. * * Iterate over list of given type, continuing after current point, * safe against removal of list entry. */#define list_for_each_entry_safe_continue(pos, n, head, member) 		\	for (pos = list_entry(pos->member.next, typeof(*pos), member), 		\		n = list_entry(pos->member.next, typeof(*pos), member);		\	     &pos->member != (head);						\	     pos = n, n = list_entry(n->member.next, typeof(*n), member))/** * list_for_each_entry_safe_from * @pos:	the type * to use as a loop cursor. * @n:		another type * to use as temporary storage * @head:	the head for your list. * @member:	the name of the list_struct within the struct. * * Iterate over list of given type from current point, safe against * removal of list entry. */#define list_for_each_entry_safe_from(pos, n, head, member) 			\	for (n = list_entry(pos->member.next, typeof(*pos), member);		\	     &pos->member != (head);						\	     pos = n, n = list_entry(n->member.next, typeof(*n), member))/** * list_for_each_entry_safe_reverse * @pos:	the type * to use as a loop cursor. * @n:		another type * to use as temporary storage * @head:	the head for your list. * @member:	the name of the list_struct within the struct. * * Iterate backwards over list of given type, safe against removal * of list entry. */#define list_for_each_entry_safe_reverse(pos, n, head, member)		\	for (pos = list_entry((head)->prev, typeof(*pos), member),	\		n = list_entry(pos->member.prev, typeof(*pos), member);	\	     &pos->member != (head); 					\	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))/* * Double linked lists with a single pointer list head. * Mostly useful for hash tables where the two pointer list head is * too wasteful. * You lose the ability to access the tail in O(1). */struct hlist_head {	struct hlist_node *first;};struct hlist_node {	struct hlist_node *next, **pprev;};#define HLIST_HEAD_INIT { .first = NULL }#define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)static inline void INIT_HLIST_NODE(struct hlist_node *h){	h->next = NULL;	h->pprev = NULL;}static inline int hlist_unhashed(const struct hlist_node *h){	return !h->pprev;}static inline int hlist_empty(const struct hlist_head *h){	return !h->first;}static inline void __hlist_del(struct hlist_node *n){	struct hlist_node *next = n->next;	struct hlist_node **pprev = n->pprev;	*pprev = next;	if (next)		next->pprev = pprev;}static inline void hlist_del(struct hlist_node *n){	__hlist_del(n);	n->next = NULL;	n->pprev = NULL;}static inline void hlist_del_init(struct hlist_node *n){	if (!hlist_unhashed(n)) {		__hlist_del(n);		INIT_HLIST_NODE(n);	}}static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h){	struct hlist_node *first = h->first;	n->next = first;	if (first)		first->pprev = &n->next;	h->first = n;	n->pprev = &h->first;}/* next must be != NULL */static inline void hlist_add_before(struct hlist_node *n,					struct hlist_node *next){	n->pprev = next->pprev;	n->next = next;	next->pprev = &n->next;	*(n->pprev) = n;}static inline void hlist_add_after(struct hlist_node *n,					struct hlist_node *next){	next->next = n->next;	n->next = next;	next->pprev = &n->next;	if(next->next)		next->next->pprev  = &next->next;}#define hlist_entry(ptr, type, member) container_of(ptr,type,member)#define hlist_for_each(pos, head) \	for (pos = (head)->first; pos; pos = pos->next)#define hlist_for_each_safe(pos, n, head) \	for (pos = (head)->first; pos; pos = n)/** * hlist_for_each_entry	- iterate over list of given type * @tpos:	the type * to use as a loop cursor. * @pos:	the &struct hlist_node to use as a loop cursor. * @head:	the head for your list. * @member:	the name of the hlist_node within the struct. */#define hlist_for_each_entry(tpos, pos, head, member)			 \	for (pos = (head)->first; pos &&				 \		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \	     pos = pos->next)/** * hlist_for_each_entry_continue - iterate over a hlist continuing after current point * @tpos:	the type * to use as a loop cursor. * @pos:	the &struct hlist_node to use as a loop cursor. * @member:	the name of the hlist_node within the struct. */#define hlist_for_each_entry_continue(tpos, pos, member)		\	for (pos = (pos)->next; pos &&					\	     ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;});   \	     pos = pos->next)/** * hlist_for_each_entry_from - iterate over a hlist continuing from current point * @tpos:	the type * to use as a loop cursor. * @pos:	the &struct hlist_node to use as a loop cursor. * @member:	the name of the hlist_node within the struct. */#define hlist_for_each_entry_from(tpos, pos, member)			 \	for (; pos &&			 \		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \	     pos = pos->next)/** * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @tpos:	the type * to use as a loop cursor. * @pos:	the &struct hlist_node to use as a loop cursor. * @n:		another &struct hlist_node to use as temporary storage * @head:	the head for your list. * @member:	the name of the hlist_node within the struct. */#define hlist_for_each_entry_safe(tpos, pos, n, head, member) 		 \	for (pos = (head)->first;					 \	     pos && ({ n = pos->next; 1; }) && 				 \		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \	     pos = n)#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -