Module Name: src Committed By: martin Date: Fri Aug 22 10:38:07 UTC 2014
Modified Files: src/sys/external/bsd/common/include/linux [netbsd-7]: list.h Log Message: Pull up following revision(s) (requested by riastradh in ticket #47): sys/external/bsd/common/include/linux/list.h: revision 1.5 Add some Linux list routines. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/external/bsd/common/include/linux/list.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/common/include/linux/list.h diff -u src/sys/external/bsd/common/include/linux/list.h:1.4 src/sys/external/bsd/common/include/linux/list.h:1.4.2.1 --- src/sys/external/bsd/common/include/linux/list.h:1.4 Wed Jul 16 20:59:57 2014 +++ src/sys/external/bsd/common/include/linux/list.h Fri Aug 22 10:38:07 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: list.h,v 1.4 2014/07/16 20:59:57 riastradh Exp $ */ +/* $NetBSD: list.h,v 1.4.2.1 2014/08/22 10:38:07 martin Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -74,6 +74,12 @@ list_first(const struct list_head *head) } 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 @@ list_del_init(struct list_head *node) #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 @@ list_del_init(struct list_head *node) (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 @@ list_del_init(struct list_head *node) &(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)) && \