1 /* SPDX-License-Identifier: GPL-2.0
5 * wrapper around linux/list.h.
7 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * This wrapper code is derived from Linux 3.19.2 include/linux/list.h
10 * and include/linux/rculist.h, hence the GPLv2 license applied to this
14 #ifndef _LTTNG_WRAPPER_LIST_H
15 #define _LTTNG_WRAPPER_LIST_H
17 #include <linux/list.h>
18 #include <linux/rculist.h>
21 * return the first or the next element in an RCU protected hlist
23 #define lttng_hlist_first_rcu(head) (*((struct hlist_node __rcu **)(&(head)->first)))
24 #define lttng_hlist_next_rcu(node) (*((struct hlist_node __rcu **)(&(node)->next)))
25 #define lttng_hlist_pprev_rcu(node) (*((struct hlist_node __rcu **)((node)->pprev)))
27 #define lttng_hlist_entry_safe(ptr, type, member) \
28 ({ typeof(ptr) ____ptr = (ptr); \
29 ____ptr ? hlist_entry(____ptr, type, member) : NULL; \
33 * lttng_hlist_for_each_entry - iterate over list of given type
34 * @pos: the type * to use as a loop cursor.
35 * @head: the head for your list.
36 * @member: the name of the hlist_node within the struct.
38 #define lttng_hlist_for_each_entry(pos, head, member) \
39 for (pos = lttng_hlist_entry_safe((head)->first, typeof(*(pos)), member);\
41 pos = lttng_hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
44 * lttng_hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
45 * @pos: the type * to use as a loop cursor.
46 * @n: another &struct hlist_node to use as temporary storage
47 * @head: the head for your list.
48 * @member: the name of the hlist_node within the struct.
50 #define lttng_hlist_for_each_entry_safe(pos, n, head, member) \
51 for (pos = lttng_hlist_entry_safe((head)->first, typeof(*pos), member);\
52 pos && ({ n = pos->member.next; 1; }); \
53 pos = lttng_hlist_entry_safe(n, typeof(*pos), member))
55 #endif /* _LTTNG_WRAPPER_LIST_H */
This page took 0.031138 seconds and 4 git commands to generate.