From: Dmitry Torokhov <dtor@insightbb.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@osdl.org>
Subject: [RFC/PATCH] Introduce list_get() and list_get_tail()
Date: Sat, 8 Jul 2006 01:24:21 -0400 [thread overview]
Message-ID: <200607080124.21856.dtor@insightbb.com> (raw)
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
next reply other threads:[~2006-07-08 5:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-08 5:24 Dmitry Torokhov [this message]
2006-07-08 13:58 ` [RFC/PATCH] Introduce list_get() and list_get_tail() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200607080124.21856.dtor@insightbb.com \
--to=dtor@insightbb.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox