public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH] Introduce list_get() and list_get_tail()
@ 2006-07-08  5:24 Dmitry Torokhov
  2006-07-08 13:58 ` Andi Kleen
  2006-07-08 18:31 ` Arnd Bergmann
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2006-07-08  5:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton

From: Dmitry Torokhov <dtor@mail.ru>

Add primitives to access first and last elements of a list instead
of accessng pointers directly.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

We have primitives to iterate over lists and to add/delete elements,
why not for accessing head/tail?

 include/linux/list.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+)

Index: work/include/linux/list.h
===================================================================
--- work.orig/include/linux/list.h
+++ work/include/linux/list.h
@@ -571,6 +571,24 @@ static inline void list_splice_init(stru
 		prefetch(rcu_dereference((pos))->next), (pos) != (head); \
         	(pos) = (pos)->next)
 
+/**
+ * list_get - get first element in a list
+ * @head: the head of your list
+ */
+static inline struct list_head *list_get(struct list_head *head)
+{
+	return head->next;
+}
+
+/**
+ * list_get_tail - get last element in a list
+ * @head: the head of your list
+ */
+static inline struct list_head *list_get_tail(struct list_head *head)
+{
+	return head->prev;
+}
+
 /*
  * Double linked lists with a single pointer list head.
  * Mostly useful for hash tables where the two pointer list head is

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-07-11 17:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-08  5:24 [RFC/PATCH] Introduce list_get() and list_get_tail() Dmitry Torokhov
2006-07-08 13:58 ` Andi Kleen
2006-07-08 14:16   ` Arjan van de Ven
2006-07-08 17:02     ` Matthieu CASTET
2006-07-09  3:28     ` Dmitry Torokhov
2006-07-11 17:43       ` Josef Sipek
2006-07-11 17:58         ` Dmitry Torokhov
2006-07-08 18:31 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox