gui: Check return value of para_exec_cmdline_pid().
[paraslash.git] / list.h
diff --git a/list.h b/list.h
index 80f36a1ba58ee0032fb3fbd99c4054a03c917cbd..e4b5a1f67b066b73d2a89e0b2e9a7cd6eac00a66 100644 (file)
--- a/list.h
+++ b/list.h
@@ -204,3 +204,25 @@ static inline int list_empty(const struct list_head *head)
                n = list_entry(pos->member.prev, typeof(*pos), member); \
             &pos->member != (head);                                    \
             pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
+/**
+ * Get the first element from a list
+ * \param ptr the list head to take the element from.
+ * \param type The type of the struct this is embedded in.
+ * \param member The name of the list_struct within the struct.
+ *
+ * Note that list is expected to be not empty.
+ */
+#define list_first_entry(ptr, type, member) \
+        list_entry((ptr)->next, type, member)
+
+/**
+ * Test whether a list has just one entry.
+ *
+ * \param head The list to test.
+ */
+static inline int list_is_singular(const struct list_head *head)
+{
+       return !list_empty(head) && (head->next == head->prev);
+}
+