Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/common/include/linux Add some Linux list ro...
details: https://anonhg.NetBSD.org/src/rev/51cff9103ad0
branches: trunk
changeset: 331704:51cff9103ad0
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Aug 20 15:26:52 2014 +0000
description:
Add some Linux list routines.
diffstat:
sys/external/bsd/common/include/linux/list.h | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diffs (60 lines):
diff -r cae98a173a86 -r 51cff9103ad0 sys/external/bsd/common/include/linux/list.h
--- a/sys/external/bsd/common/include/linux/list.h Wed Aug 20 15:19:39 2014 +0000
+++ b/sys/external/bsd/common/include/linux/list.h Wed Aug 20 15:26:52 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: list.h,v 1.4 2014/07/16 20:59:57 riastradh Exp $ */
+/* $NetBSD: list.h,v 1.5 2014/08/20 15:26:52 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -74,6 +74,12 @@
}
static inline struct list_head *
+list_last(const struct list_head *head)
+{
+ return head->prev;
+}
+
+static inline struct list_head *
list_next(const struct list_head *node)
{
return node->next;
@@ -192,8 +198,12 @@
#define list_entry(PTR, TYPE, FIELD) container_of(PTR, TYPE, FIELD)
#define list_first_entry(PTR, TYPE, FIELD) \
list_entry(list_first((PTR)), TYPE, FIELD)
+#define list_last_entry(PTR, TYPE, FIELD) \
+ list_entry(list_last((PTR)), TYPE, FIELD)
#define list_next_entry(ENTRY, FIELD) \
list_entry(list_next(&(ENTRY)->FIELD), typeof(*(ENTRY)), FIELD)
+#define list_prev_entry(ENTRY, FIELD) \
+ list_entry(list_prev(&(ENTRY)->FIELD), typeof(*(ENTRY)), FIELD)
#define list_for_each(VAR, HEAD) \
for ((VAR) = list_first((HEAD)); \
@@ -211,6 +221,12 @@
(VAR) = list_entry(list_next(&(VAR)->FIELD), typeof(*(VAR)), \
FIELD))
+#define list_for_each_entry_reverse(VAR, HEAD, FIELD) \
+ for ((VAR) = list_entry(list_last((HEAD)), typeof(*(VAR)), FIELD); \
+ &(VAR)->FIELD != (HEAD); \
+ (VAR) = list_entry(list_prev(&(VAR)->FIELD), typeof(*(VAR)), \
+ FIELD))
+
#define list_for_each_entry_safe(VAR, NEXT, HEAD, FIELD) \
for ((VAR) = list_entry(list_first((HEAD)), typeof(*(VAR)), FIELD); \
(&(VAR)->FIELD != (HEAD)) && \
@@ -223,6 +239,11 @@
&(VAR)->FIELD != (HEAD); \
(VAR) = list_next_entry((VAR), FIELD))
+#define list_for_each_entry_continue_reverse(VAR, HEAD, FIELD) \
+ for ((VAR) = list_prev_entry((VAR), FIELD); \
+ &(VAR)->FIELD != (HEAD); \
+ (VAR) = list_prev_entry((VAR), FIELD))
+
#define list_for_each_entry_safe_from(VAR, NEXT, HEAD, FIELD) \
for (; \
(&(VAR)->FIELD != (HEAD)) && \
Home |
Main Index |
Thread Index |
Old Index