login
Header Space

 
 

[PATCH -mm 1/5] list.h: add list_singleton

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew Morton <akpm@...>
Cc: Ananth N Mavinakayanahalli <ananth@...>, Jim Keniston <jkenisto@...>, LKML <linux-kernel@...>, systemtap-ml <systemtap@...>, Prasanna S Panchamukhi <prasanna@...>, Shaohua Li <shaohua.li@...>, David Miller <davem@...>, Frank Ch. Eigler <fche@...>
Date: Friday, March 14, 2008 - 4:40 pm

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





--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -mm 1/5] list.h: add list_singleton, Masami Hiramatsu, (Fri Mar 14, 4:40 pm)
Re: [PATCH -mm 1/5] list.h: add list_singleton, Andrew Morton, (Fri Mar 14, 5:00 pm)
Re: [PATCH -mm 1/5] list.h: add list_singleton, Masami Hiramatsu, (Fri Mar 14, 6:22 pm)
Re: [PATCH -mm 1/5] list.h: add list_singleton, Peter Zijlstra, (Sat Mar 15, 6:36 pm)
Re: [PATCH -mm 1/5] list.h: add list_singleton, Masami Hiramatsu, (Mon Mar 17, 11:04 am)
Re: [PATCH -mm 1/5] list.h: add list_singleton, Peter Zijlstra, (Mon Mar 17, 11:13 am)
[PATCH -mm] list.h: rename list_singleton to list_is_singular, Masami Hiramatsu, (Mon Mar 17, 4:52 pm)
speck-geostationary