aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
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
*