patch-2.1.58 linux/include/linux/list.h
Next file: linux/include/linux/mm.h
Previous file: linux/include/linux/fs.h
Back to the patch index
Back to the overall index
- Lines: 70
- Date:
Sun Oct 12 10:46:27 1997
- Orig file:
v2.1.57/linux/include/linux/list.h
- Orig date:
Thu Jul 17 10:06:08 1997
diff -u --recursive --new-file v2.1.57/linux/include/linux/list.h linux/include/linux/list.h
@@ -3,7 +3,14 @@
/*
* Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
*/
+
struct list_head {
struct list_head *next, *prev;
};
@@ -15,22 +22,46 @@
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
-static inline void list_add(struct list_head *new, struct list_head *head)
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head * new,
+ struct list_head * prev,
+ struct list_head * next)
{
- struct list_head *next = head->next;
next->prev = new;
new->next = next;
- new->prev = head;
- head->next = new;
+ new->prev = prev;
+ prev->next = new;
}
-static inline void list_del(struct list_head *entry)
+/*
+ * Insert a new entry after the specified head..
+ */
+static inline void list_add(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head, head->next);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
{
- struct list_head *next, *prev;
- next = entry->next;
- prev = entry->prev;
next->prev = prev;
prev->next = next;
+}
+
+static inline void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
}
static inline int list_empty(struct list_head *head)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov