[PATCH] libosmocore[master]: linuxlist: add llist_first and llist_last macros

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Feb 15 02:03:23 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1826

to look at the new patch set (#2).

linuxlist: add llist_first and llist_last macros

Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c
---
M include/osmocom/core/linuxlist.h
1 file changed, 30 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/1826/2

diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h
index affa827..1d6af17 100644
--- a/include/osmocom/core/linuxlist.h
+++ b/include/osmocom/core/linuxlist.h
@@ -367,6 +367,36 @@
 	return i;
 }
 
+/*! \brief return the first list item, if any.
+ *  \param head The llist head to take the first item of.
+ *  \returns struct llist_head pointer of first item, or NULL if empty.
+ */
+#define __llist_first(head) (((head)->next == (head)) ? NULL : (head)->next)
+
+/*! \brief return the first list item, if any.
+ *  \param head The llist head to take the first item of.
+ *  \param type The struct type of entries kept in this list.
+ *  \param member The name of the \ref llist_head within \a type
+ *  \returns first item, or NULL if empty.
+ */
+#define llist_first(head, type, member) \
+	llist_entry(__llist_first(head), type, member)
+
+/*! \brief return the last list item, if any.
+ *  \param head The llist head to take the last item of.
+ *  \returns struct llist_head pointer of last item, or NULL if empty.
+ */
+#define __llist_last(head) (((head)->next == (head)) ? NULL : (head)->prev)
+
+/*! \brief return the last list item, if any.
+ *  \param head The llist head to take the last item of.
+ *  \param type The struct type of entries kept in this list.
+ *  \param member The name of the \ref llist_head within \a type
+ *  \returns last item, or NULL if empty.
+ */
+#define llist_last(head, type, member) \
+	llist_entry(__llist_last(head), type, member)
+
 /*!
  *  }@
  */

-- 
To view, visit https://gerrit.osmocom.org/1826
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I296b7cf1c7cb07b24c2e17084b03fed321c53a7c
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder


More information about the gerrit-log mailing list