public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mm 1/5] list.h: add list_singleton
@ 2008-03-14 20:40 Masami Hiramatsu
  2008-03-14 21:00 ` Andrew Morton
  0 siblings, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2008-03-14 20:40 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Ananth N Mavinakayanahalli, Jim Keniston, LKML, systemtap-ml,
	Prasanna S Panchamukhi, Shaohua Li, David Miller,
	Frank Ch. Eigler

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






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

end of thread, other threads:[~2008-03-17 20:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-14 20:40 [PATCH -mm 1/5] list.h: add list_singleton Masami Hiramatsu
2008-03-14 21:00 ` 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

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