From c2b605e9129ca739ddfacf9da41015875b98e922 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 22 Aug 2014 10:38:07 +0000 Subject: [PATCH] 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. --- sys/external/bsd/common/include/linux/list.h | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sys/external/bsd/common/include/linux/list.h b/sys/external/bsd/common/include/linux/list.h index 645c98409f1d..9b0be14df188 100644 --- a/sys/external/bsd/common/include/linux/list.h +++ b/sys/external/bsd/common/include/linux/list.h @@ -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. @@ -73,6 +73,12 @@ list_first(const struct list_head *head) return head->next; } +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) { @@ -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)) && \