aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-07-15 13:15:18 -0700
committerDave Barach <openvpp@barachs.net>2019-07-17 12:20:23 +0000
commit2062ec0d67fb83fa25fc938c992a8e882612c777 (patch)
treee74828ba6f90b5bee0e37183c3664682cd17d4bb /src/vppinfra
parent0dfbce6b76c40976beca671da57c773c6e8944b9 (diff)
session: use llist in session node evt handling
Type: refactor Change-Id: I24159e0a848f552b4e27acfb5fe6f2cd91b50a19 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/llist.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/vppinfra/llist.h b/src/vppinfra/llist.h
index 1648021681f..d521a725fc3 100644
--- a/src/vppinfra/llist.h
+++ b/src/vppinfra/llist.h
@@ -102,7 +102,17 @@ do { \
* @param H list head
* @return 1 if sentinel is the only node part of the list, 0 otherwise
*/
-#define clib_llist_is_empty(LP,name,H) ((H) == clib_llist_next((LP),name,(H)))
+#define clib_llist_is_empty(LP,name,H) \
+ (clib_llist_entry_index (LP,H) == (H)->name.next)
+/**
+ * Check if element is linked in a list
+ *
+ * @param E list element
+ * @param name list anchor name
+ */
+#define clib_llist_elt_is_linked(E,name) \
+ ((E)->name.next != CLIB_LLIST_INVALID_INDEX \
+ && (E)->name.prev != CLIB_LLIST_INVALID_INDEX)
/**
* Insert entry between previous and next
*
@@ -175,7 +185,22 @@ do { \
_lprev (_ll_var (N),name) = _lprev (E,name); \
_lnext (E,name) = _lprev (E,name) = CLIB_LLIST_INVALID_INDEX; \
}while (0)
-
+/**
+ * Removes and returns the first element in the list.
+ *
+ * The element is not freed. It's the responsability of the caller to
+ * free it.
+ *
+ * @param LP linked list pool
+ * @param name list anchor name
+ * @param E storage the first entry
+ * @param H list head entry
+ */
+#define clib_llist_pop_first(LP,name,E,H) \
+do { \
+ E = clib_llist_next (LP,name,H); \
+ clib_llist_remove (LP,name,E); \
+} while (0)
/**
* Splice two lists at a given position
*