From: Masami Hiramatsu <mhiramat@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Jim Keniston <jkenisto@us.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
systemtap-ml <systemtap@sources.redhat.com>,
Prasanna S Panchamukhi <prasanna@in.ibm.com>,
Shaohua Li <shaohua.li@intel.com>,
David Miller <davem@davemloft.net>,
"Frank Ch. Eigler" <fche@redhat.com>
Subject: [PATCH -mm 1/5] list.h: add list_singleton
Date: Fri, 14 Mar 2008 16:40:36 -0400 [thread overview]
Message-ID: <47DAE2C4.2060303@redhat.com> (raw)
Add list_singleton to check a list has just one entry.
list_singleton is useful to check whether a list_head which
have been temporarily allocated for listing objects can be
released or not.
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
---
include/linux/list.h | 9 +++++++++
1 file changed, 9 insertions(+)
Index: 2.6.25-rc5-mm1/include/linux/list.h
===================================================================
--- 2.6.25-rc5-mm1.orig/include/linux/list.h
+++ 2.6.25-rc5-mm1/include/linux/list.h
@@ -211,6 +211,15 @@ static inline int list_empty_careful(con
return (next == head) && (next == head->prev);
}
+/**
+ * list_singleton - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static inline int list_singleton(const struct list_head *head)
+{
+ return !list_empty(head) && (head->next == head->prev);
+}
+
static inline void __list_splice(struct list_head *list,
struct list_head *head)
{
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
next reply other threads:[~2008-03-14 20:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-14 20:40 Masami Hiramatsu [this message]
2008-03-14 21:00 ` [PATCH -mm 1/5] list.h: add list_singleton Andrew Morton
2008-03-14 22:22 ` Masami Hiramatsu
2008-03-15 22:36 ` Peter Zijlstra
2008-03-17 15:04 ` Masami Hiramatsu
2008-03-17 15:13 ` Peter Zijlstra
2008-03-17 20:52 ` [PATCH -mm] list.h: rename list_singleton to list_is_singular Masami Hiramatsu
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=47DAE2C4.2060303@redhat.com \
--to=mhiramat@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ananth@in.ibm.com \
--cc=davem@davemloft.net \
--cc=fche@redhat.com \
--cc=jkenisto@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=prasanna@in.ibm.com \
--cc=shaohua.li@intel.com \
--cc=systemtap@sources.redhat.com \
/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