1 #ifndef _LTTNG_WRAPPER_LIST_H
2 #define _LTTNG_WRAPPER_LIST_H
7 * wrapper around linux/list.h.
9 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; only version 2 of the License.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * This wrapper code is derived from Linux 3.19.2 include/linux/list.h
25 * and include/linux/rculist.h, hence the GPLv2 license applied to this
29 #include <linux/list.h>
30 #include <linux/rculist.h>
33 * return the first or the next element in an RCU protected hlist
35 #define lttng_hlist_first_rcu(head) (*((struct hlist_node __rcu **)(&(head)->first)))
36 #define lttng_hlist_next_rcu(node) (*((struct hlist_node __rcu **)(&(node)->next)))
37 #define lttng_hlist_pprev_rcu(node) (*((struct hlist_node __rcu **)((node)->pprev)))
39 #define lttng_hlist_entry_safe(ptr, type, member) \
40 ({ typeof(ptr) ____ptr = (ptr); \
41 ____ptr ? hlist_entry(____ptr, type, member) : NULL; \
45 * lttng_hlist_for_each_entry - iterate over list of given type
46 * @pos: the type * to use as a loop cursor.
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(pos, head, member) \
51 for (pos = lttng_hlist_entry_safe((head)->first, typeof(*(pos)), member);\
53 pos = lttng_hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
56 * lttng_hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
57 * @pos: the type * to use as a loop cursor.
58 * @n: another &struct hlist_node to use as temporary storage
59 * @head: the head for your list.
60 * @member: the name of the hlist_node within the struct.
62 #define lttng_hlist_for_each_entry_safe(pos, n, head, member) \
63 for (pos = lttng_hlist_entry_safe((head)->first, typeof(*pos), member);\
64 pos && ({ n = pos->member.next; 1; }); \
65 pos = lttng_hlist_entry_safe(n, typeof(*pos), member))
67 #endif /* _LTTNG_WRAPPER_LIST_H */
This page took 0.059088 seconds and 4 git commands to generate.