[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1460706713-5942-3-git-send-email-jiri@resnulli.us>
Date: Fri, 15 Apr 2016 09:51:44 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: netdev@...r.kernel.org
Cc: stephen@...workplumber.org, davem@...emloft.net,
idosch@...lanox.com, eladr@...lanox.com, yotamg@...lanox.com,
ogerlitz@...lanox.com, roopa@...ulusnetworks.com,
nikolay@...ulusnetworks.com, jhs@...atatu.com,
john.fastabend@...il.com, rami.rosen@...el.com,
gospo@...ulusnetworks.com, sfeldma@...il.com
Subject: [patch iproute2 02/11] list: add list_for_each_entry_reverse macro
From: Jiri Pirko <jiri@...lanox.com>
Signed-off-by: Jiri Pirko <jiri@...lanox.com>
---
include/list.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/list.h b/include/list.h
index cdebe4d..b549c3e 100644
--- a/include/list.h
+++ b/include/list.h
@@ -50,9 +50,15 @@ static inline void list_del(struct list_head *entry)
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
+#define list_last_entry(ptr, type, member) \
+ list_entry((ptr)->prev, type, member)
+
#define list_next_entry(pos, member) \
list_entry((pos)->member.next, typeof(*(pos)), member)
+#define list_prev_entry(pos, member) \
+ list_entry((pos)->member.prev, typeof(*(pos)), member)
+
#define list_for_each_entry(pos, head, member) \
for (pos = list_first_entry(head, typeof(*pos), member); \
&pos->member != (head); \
@@ -64,6 +70,11 @@ static inline void list_del(struct list_head *entry)
&pos->member != (head); \
pos = n, n = list_next_entry(n, member))
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_last_entry(head, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_prev_entry(pos, member))
+
struct hlist_head {
struct hlist_node *first;
};
--
2.5.5
Powered by blists - more mailing lists