10#ifndef __TUYA_HLIST_H__
11#define __TUYA_HLIST_H__
13#include "tuya_cloud_types.h"
39#define HLIST_HEAD_INIT { .first = NULL}
45#define HLIST_HEAD(name) HLIST_HEAD name = {.first = NULL}
51#define INIT_HLIST_HEAD(ptr) ((ptr->first)=NULL)
57#define HLIST_ENTRY(ptr, type, member) CNTR_OF(ptr,type,member)
63#define HLIST_FOR_EACH_ENTRY(tpos, type, pos, head, member) \
64 for (pos = (head)->first; \
65 pos && (tpos = HLIST_ENTRY(pos, type, member), 1); \
72#define HLIST_FOR_EACH_ENTRY_CURR(tpos, type, pos, curr, member) \
73 for (pos = (curr)->next; \
74 pos && (tpos = HLIST_ENTRY(pos, type, member), 1); \
81#define HLIST_FOR_EACH_ENTRY_SAFE(tpos, type, pos, n, head, member) \
82 for (pos = (head)->first; \
83 pos && (n = pos->next, 1) && \
84 (tpos = HLIST_ENTRY(pos, type, member), 1); \
91#define HLIST_FOR_EACH(pos, head) \
92 for (pos = (head)->first; pos ; \
99#define HLIST_FOR_EACH_SAFE(pos, n, head) \
100 for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
110STATIC INLINE VOID tuya_init_hlist_node(INOUT
HLIST_NODE *h)
122STATIC INLINE INT_T tuya_hlist_empty(IN CONST
HLIST_HEAD *h)
133STATIC INLINE INT_T tuya_hlist_unhashed(IN CONST
HLIST_NODE *h)
146STATIC INLINE VOID __tuya_hlist_del(INOUT
HLIST_NODE *n)
161STATIC INLINE VOID tuya_hlist_del(INOUT
HLIST_NODE *n)
174STATIC INLINE VOID tuya_hlist_del_init(INOUT
HLIST_NODE *n)
176 if (!tuya_hlist_unhashed(n)) {
178 tuya_init_hlist_node(n);
194 first->pprev = &n->next;
196 n->pprev = &h->first;
210 n->pprev = next->pprev;
212 next->pprev = &n->next;
227 next->next = n->next;
229 next->pprev = &n->next;
232 next->next->pprev = &next->next;
hash list head
Definition: tuya_hlist.h:31
hash list node
Definition: tuya_hlist.h:23
struct hlist_node HLIST_NODE
hash list node
#define HLIST_HEAD(name)
hash list head define and initialization
Definition: tuya_hlist.h:45