summaryrefslogtreecommitdiff
path: root/include/linux/list.h
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2008-04-28 02:14:27 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 08:58:32 -0700
commit99602572812442d47403d85f376ad51298dd82a6 (patch)
tree204948267936e9a3f1c430d970c9a68f1583b55d /include/linux/list.h
parent3d8d996e0ca5b4093203d3f050b0f70b5c949ae8 (diff)
downloadlinux-next-99602572812442d47403d85f376ad51298dd82a6.tar.gz
list.h: add list_is_singular()
Add list_is_singular() to check a list has just one entry. list_is_singular() 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> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/list.h')
-rw-r--r--include/linux/list.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index dac16f99c701..b4a939b6b625 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -319,6 +319,15 @@ static inline int list_empty_careful(const struct list_head *head)
return (next == head) && (next == head->prev);
}
+/**
+ * list_is_singular - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static inline int list_is_singular(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)
{