hi,
this patch adds slist.h, a header-file providing simple single-linked-list
helper functions.
especially slist_for_each will improve:
o readability
o performance (due to the use of prefetch())
wherever it's used
please apply,
tm
diff -Nru a/include/linux/slist.h b/include/linux/slist.h
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/include/linux/slist.h Sun Jun 9 22:32:55 2002
@@ -0,0 +1,57 @@
+#ifndef _LINUX_SLIST_H
+#define _LINUX_SLIST_H
+
+#if defined(__KERNEL__)
+
+#include <linux/prefetch.h>
+
+/*
+ * Simple single linked list helper-functions.
+ * (taken from list.h)
+ */
+
+/**
+ * slist_add_front - add a new entry at the first slot, moving the old head
+ * to the second slot
+ * @new: new entry to be added
+ * @head: head of the single linked list
+ *
+ * Insert a new entry before the specified head.
+ * This is good for implementing stacks.
+ */
+
+#define slist_add_front(_new, _head) \
+do { \
+ _new->next = _head; \
+ _head = _new->next; \
+} while (0)
+
+
+/**
+ * slist_add - add a new entry
+ * @new: new entry to be added
+ * @head: head of the single linked list
+ *
+ * Insert a new entry before the specified head.
+ * This is good for implementing stacks.
+ */
+
+#define slist_add(_new, _head) \
+do { \
+ _new->next = _head->next; \
+ _head->next = _new; \
+} while (0)
+
+
+/**
+ * slist_for_each - iterate over a list
+ * @pos: the pointer to use as a loop counter.
+ * @head: the head for your list (this is also the first entry).
+ */
+#define slist_for_each(pos, head) \
+ for (pos = head, prefetch(pos->next); pos; \
+ pos = pos->next, prefetch(pos->next))
+
+
+#endif /* __KERNEL__ */
+
+#endif
-- in some way i do, and in some way i don't.- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:14 EST