api: Remove deprecated message from API
[vpp.git] / src / vppinfra / llist.h
index d521a72..4281090 100644 (file)
@@ -51,6 +51,60 @@ typedef struct clib_llist_anchor
  * @return     pool entry index
  */
 #define clib_llist_entry_index(LP,E) ((E) - (LP))
+/**
+ * Alloc new element
+ *
+ * @param LP   linked list pool
+ * @param E    element to be returned
+ */
+#define clib_llist_get(LP, E) pool_get (LP, E)
+/**
+ * Free element
+ *
+ * @param LP   linked list pool
+ * @param E    element to be freed
+ */
+#define clib_llist_put(LP, E) pool_put (LP, E)
+/**
+ * Free list supporting container
+ *
+ * @param LP   linked list pool
+ */
+#define clib_llist_free(LP) pool_free (LP)
+/**
+ * Get list elt at index
+ *
+ * @param LP   linked list pool
+ * @param EI   element index
+ * @return     element
+ */
+#define clib_llist_elt(LP, EI) pool_elt_at_index (LP, EI)
+/**
+ * Get number of elements in supporting container
+ *
+ * This is NOT the elements linked in the list but the number of
+ * elements consumed out of the supporting pool
+ *
+ * @param LP   linked list pool
+ * @return     number of elements
+ */
+#define clib_llist_elts(LP) pool_elts (LP)
+/**
+ * Get prev list entry index
+ *
+ * @param E    pool entry
+ * @name       list anchor name
+ * @return     previous index
+ */
+#define clib_llist_prev_index(E,name) _lprev(E,name)
+/**
+ * Get next list entry index
+ *
+ * @param E    pool entry
+ * @name       list anchor name
+ * @return     next index
+ */
+#define clib_llist_next_index(E,name) _lnext(E,name)
 /**
  * Get next pool entry
  *
@@ -247,6 +301,28 @@ do {                                                                       \
       (E) = _ll_var (n);                                               \
     }                                                                  \
 } while (0)
+/**
+ * Walk list starting at head safe
+ *
+ * @param LP   linked list pool
+ * @param name list anchor name
+ * @param HI   head index
+ * @param EI   entry index iterator
+ * @param body code to be executed
+ */
+#define clib_llist_foreach_safe(LP,name,H,E,body)                      \
+do {                                                                   \
+  clib_llist_index_t _ll_var (HI) = clib_llist_entry_index (LP, H);    \
+  clib_llist_index_t _ll_var (EI), _ll_var (NI);                       \
+  _ll_var (EI) = _lnext ((H),name);                                    \
+  while (_ll_var (EI) != _ll_var (HI))                                 \
+    {                                                                  \
+      (E) = pool_elt_at_index (LP, _ll_var (EI));                      \
+      _ll_var (NI) = _lnext ((E),name);                                        \
+      do { body; } while (0);                                          \
+      _ll_var (EI) = _ll_var (NI);                                     \
+    }                                                                  \
+} while (0)
 /**
  * Walk list starting at head in reverse order
  *