]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/hlist.h
2 * double-linked hash list with single head implementation taken from linux
3 * kernel headers as of 2.6.38-rc1.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 struct hlist_node
*next
;
23 struct hlist_node
**pprev
;
26 struct hlist_node
*first
;
29 #define HLIST_HEAD_INIT { .first = NULL }
30 static inline void INIT_HLIST_NODE(struct hlist_node
*h
)
36 static inline void hlist_add_head(struct hlist_node
*n
, struct hlist_head
*h
)
38 struct hlist_node
*first
= h
->first
;
41 first
->pprev
= &n
->next
;
46 static inline void __hlist_del(struct hlist_node
*n
)
48 struct hlist_node
*next
= n
->next
;
49 struct hlist_node
**pprev
= n
->pprev
;
55 static inline void hlist_del(struct hlist_node
*n
)
60 #define hlist_entry(ptr, type, member) ({ \
61 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
62 (type *)( (char *)__mptr - offsetof(type,member) );})
65 #define hlist_for_each(pos, head) \
66 for (pos = (head)->first; pos; pos = pos->next)
68 #define hlist_for_each_entry(tpos, pos, head, member) \
69 for (pos = (head)->first; \
70 pos && ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
74 #endif /* __LIST_H__ */