patch-1.3.57 linux/include/linux/lists.h

Next file: linux/include/linux/mm.h
Previous file: linux/include/linux/kerneld.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.56/linux/include/linux/lists.h linux/include/linux/lists.h
@@ -0,0 +1,40 @@
+/*
+ * lists.h:  Simple list macros for Linux
+ */
+
+#define DLNODE(ptype)			       	       	       	\
+	struct {			 			\
+		ptype * dl_prev;	 			\
+		ptype * dl_next;	 			\
+	}
+
+#define DNODE_SINGLE(node) {(node),(node)}
+#define DNODE_NULL {0,0}
+
+#define DLIST_INIT(listnam)	                                \
+	(listnam).dl_prev = &(listnam);				\
+	(listnam).dl_last = &(listnam);
+
+#define DLIST_NEXT(listnam)	listnam.dl_next
+#define DLIST_PREV(listnam)	listnam.dl_prev
+
+#define DLIST_INSERT_AFTER(node, new, listnam)	do {		\
+	(new)->listnam.dl_prev = (node);			\
+	(new)->listnam.dl_next = (node)->listnam.dl_next;	\
+	(node)->listnam.dl_next->listnam.dl_prev = (new);	\
+	(node)->listnam.dl_next = (new);			\
+	} while (0)
+
+#define DLIST_INSERT_BEFORE(node, new, listnam)	do {		\
+	(new)->listnam.dl_next = (node);			\
+	(new)->listnam.dl_prev = (node)->listnam.dl_prev;	\
+	(node)->listnam.dl_prev->listnam.dl_next = (new);	\
+	(node)->listnam.dl_prev = (new);			\
+	} while (0)
+
+#define DLIST_DELETE(node, listnam)	do {		\
+	node->listnam.dl_prev->listnam.dl_next =		\
+		node->listnam.dl_next;				\
+	node->listnam.dl_next->listnam.dl_prev =		\
+		node->listnam.dl_prev;				\
+	} while (0)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this