Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Add initial dra...



details:   https://anonhg.NetBSD.org/src/rev/28ac18639e32
branches:  riastradh-drm2
changeset: 788000:28ac18639e32
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 24 00:49:48 2013 +0000

description:
Add initial draft of Linux list and hlist to <linux/list.h>.

Implemented in terms of TAILQ and LIST, respectively.
Not yet tested.

diffstat:

 sys/external/bsd/drm2/include/linux/list.h |  73 +++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 1 deletions(-)

diffs (85 lines):

diff -r 3756b1a5365d -r 28ac18639e32 sys/external/bsd/drm2/include/linux/list.h
--- a/sys/external/bsd/drm2/include/linux/list.h        Wed Jul 24 00:49:32 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/list.h        Wed Jul 24 00:49:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: list.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $   */
+/*     $NetBSD: list.h,v 1.1.2.2 2013/07/24 00:49:48 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,75 @@
 #ifndef _LINUX_LIST_H_
 #define _LINUX_LIST_H_
 
+#include <sys/null.h>
+#include <sys/queue.h>
+
+#include <linux/kernel.h>
+
+/*
+ * Doubly-linked lists.
+ */
+
+TAILQ_HEAD(list_head, list_node);
+struct list_node {
+       TAILQ_ENTRY(list_node) ln_entry;
+};
+
+static inline struct list_node *
+list_first(struct list_head *head)
+{
+       return TAILQ_FIRST(head);
+}
+
+static inline struct list_node *
+list_next(struct list_node *node)
+{
+       return TAILQ_NEXT(node, ln_entry);
+}
+
+#define        list_entry(PTR, TYPE, FIELD)    container_of(PTR, TYPE, FIELD)
+#define        list_for_each(VAR, HEAD)        TAILQ_FOREACH(VAR, HEAD, ln_entry)
+#define        list_for_each_safe(VAR, NEXT, HEAD)                             \
+       TAILQ_FOREACH_SAFE(VAR, HEAD, ln_entry, NEXT)
+
+#define        list_for_each_entry(VAR, HEAD, FIELD)                           \
+       for ((VAR) = ((TAILQ_FIRST((HEAD)) == NULL)? NULL :             \
+                   list_entry(TAILQ_FIRST((HEAD)), typeof(*(VAR)), FIELD)); \
+               (VAR) != NULL;                                          \
+               (VAR) = ((TAILQ_NEXT((VAR), FIELD) == NULL)? NULL :     \
+                   list_entry(TAILQ_NEXT((VAR), FIELD), typeof(*(VAR)), \
+                       FIELD)))
+
+/*
+ * `H'ead-only/`H'ash-table doubly-linked lists.
+ */
+
+LIST_HEAD(hlist_head, hlist_node);
+struct hlist_node {
+       LIST_ENTRY(hlist_node) hln_entry;
+};
+
+static inline struct hlist_node *
+hlist_first(struct hlist_head *head)
+{
+       return LIST_FIRST(head);
+}
+
+static inline struct hlist_node *
+hlist_next(struct hlist_node *node)
+{
+       return LIST_NEXT(node, hln_entry);
+}
+
+#define        hlist_entry(PTR, TYPE, FIELD)   container_of(PTR, TYPE, FIELD)
+#define        hlist_for_each(VAR, HEAD)       LIST_FOREACH(VAR, HEAD, hln_entry)
+#define        hlist_for_each_safe(VAR, NEXT, HEAD)                            \
+       LIST_FOREACH_SAFE(VAR, HEAD, hln_entry, NEXT)
+
+#define        hlist_for_each_entry(VAR, HLIST, HEAD, FIELD)                   \
+       for ((HLIST) = LIST_FIRST((HEAD));                              \
+               ((HLIST) != NULL) &&                                    \
+                   ((VAR) = hlist_entry((HLIST), typeof(*(VAR)), FIELD), 1); \
+               (HLIST) = LIST_NEXT((HLIST), hln_entry))
+
 #endif  /* _LINUX_LIST_H_ */



Home | Main Index | Thread Index | Old Index