FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
llist.h File Reference
+ Include dependency graph for llist.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  clib_llist_anchor
 

Macros

#define CLIB_LLIST_INVALID_INDEX   ((u32)~0)
 
#define clib_llist_entry_index(LP, E)   ((E) - (LP))
 Get list entry index. More...
 
#define clib_llist_get(LP, E)   pool_get (LP, E)
 Alloc new element. More...
 
#define clib_llist_put(LP, E)   pool_put (LP, E)
 Free element. More...
 
#define clib_llist_free(LP)   pool_free (LP)
 Free list supporting container. More...
 
#define clib_llist_elt(LP, EI)   pool_elt_at_index (LP, EI)
 Get list elt at index. More...
 
#define clib_llist_elts(LP)   pool_elts (LP)
 Get number of elements in supporting container. More...
 
list anchor name

Get next list entry index

Parameters
Epool entry
Returns
next index
#define clib_llist_prev_index(E, name)   _lprev(E,name)
 
#define clib_llist_next_index(E, name)   _lnext(E,name)
 
#define clib_llist_next(LP, name, E)   pool_elt_at_index((LP),_lnext((E),name))
 Get next pool entry. More...
 
#define clib_llist_prev(LP, name, E)   pool_elt_at_index((LP),_lprev((E),name))
 Get previous pool entry. More...
 
#define clib_llist_anchor_init(LP, name, E)
 Initialize element in llist for entry. More...
 
#define clib_llist_make_head(LP, name)
 Initialize llist head. More...
 
#define clib_llist_is_empty(LP, name, H)   (clib_llist_entry_index (LP,H) == (H)->name.next)
 Check is list is empty. More...
 
#define clib_llist_elt_is_linked(E, name)
 Check if element is linked in a list. More...
 
#define clib_llist_insert(LP, name, E, P)
 Insert entry after previous. More...
 
#define clib_llist_add(LP, name, E, H)   clib_llist_insert ((LP),name,(E),(H))
 Add entry after head. More...
 
#define clib_llist_add_tail(LP, name, E, H)
 Add entry after tail. More...
 
#define clib_llist_remove(LP, name, E)
 Remove entry from list. More...
 
#define clib_llist_pop_first(LP, name, E, H)
 Removes and returns the first element in the list. More...
 
#define clib_llist_splice(LP, name, P, H)
 Splice two lists at a given position. More...
 
#define clib_llist_foreach(LP, name, H, E, body)
 Walk list starting at head. More...
 
#define clib_llist_foreach_safe(LP, name, H, E, body)
 Walk list starting at head safe. More...
 
#define clib_llist_foreach_reverse(LP, name, H, E, body)
 Walk list starting at head in reverse order. More...
 

Typedefs

typedef u32 clib_llist_index_t
 
typedef struct clib_llist_anchor clib_llist_anchor_t
 

Macro Definition Documentation

◆ clib_llist_add

#define clib_llist_add (   LP,
  name,
  E,
 
)    clib_llist_insert ((LP),name,(E),(H))

Add entry after head.

Parameters
LPlinked list pool
namelist anchor name
Enew entry
Hlist head

Definition at line 210 of file llist.h.

◆ clib_llist_add_tail

#define clib_llist_add_tail (   LP,
  name,
  E,
 
)
Value:
do { \
typeof (LP) _ll_var (P) = clib_llist_prev ((LP),name,(H)); \
_llist_insert ((LP),name,(E),_ll_var (P),(H)); \
} while (0)

Add entry after tail.

Parameters
LPlinked list pool
namelist anchor name
Enew entry
Hlist head

Definition at line 219 of file llist.h.

◆ clib_llist_anchor_init

#define clib_llist_anchor_init (   LP,
  name,
 
)
Value:
do { \
_lprev ((E),name) = clib_llist_entry_index ((LP), (E)); \
_lnext ((E),name) = _lprev ((E),name); \
} while (0)

Initialize element in llist for entry.

Parameters
LPlinked list pool
namelist anchor name
Eentry whose ll anchor is to be initialized

Definition at line 133 of file llist.h.

◆ clib_llist_elt

#define clib_llist_elt (   LP,
  EI 
)    pool_elt_at_index (LP, EI)

Get list elt at index.

Parameters
LPlinked list pool
EIelement index
Returns
element

Definition at line 81 of file llist.h.

◆ clib_llist_elt_is_linked

#define clib_llist_elt_is_linked (   E,
  name 
)
Value:
&& (E)->name.prev != CLIB_LLIST_INVALID_INDEX)

Check if element is linked in a list.

Parameters
Elist element
namelist anchor name

Definition at line 167 of file llist.h.

◆ clib_llist_elts

#define clib_llist_elts (   LP)    pool_elts (LP)

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

Parameters
LPlinked list pool
Returns
number of elements

Definition at line 91 of file llist.h.

◆ clib_llist_entry_index

#define clib_llist_entry_index (   LP,
 
)    ((E) - (LP))

Get list entry index.

Parameters
LPlinked list pool
Epool entry
Returns
pool entry index

Definition at line 53 of file llist.h.

◆ clib_llist_foreach

#define clib_llist_foreach (   LP,
  name,
  H,
  E,
  body 
)
Value:
do { \
typeof (LP) _ll_var (n); \
(E) = clib_llist_next (LP,name,H); \
while (E != H) \
{ \
_ll_var (n) = clib_llist_next (LP,name,E); \
do { body; } while (0); \
(E) = _ll_var (n); \
} \
} while (0)

Walk list starting at head.

Parameters
LPlinked list pool
namelist anchor name
Hhead entry
Eentry iterator
bodycode to be executed

Definition at line 293 of file llist.h.

◆ clib_llist_foreach_reverse

#define clib_llist_foreach_reverse (   LP,
  name,
  H,
  E,
  body 
)
Value:
do { \
typeof (LP) _ll_var (p); \
(E) = clib_llist_prev (LP,name,H); \
while (E != H) \
{ \
_ll_var (p) = clib_llist_prev (LP,name,E); \
do { body; } while (0); \
(E) = _ll_var (p); \
} \
} while (0)

Walk list starting at head in reverse order.

Parameters
LPlinked list pool
namelist anchor name
Hhead entry
Eentry iterator
bodycode to be executed

Definition at line 335 of file llist.h.

◆ clib_llist_foreach_safe

#define clib_llist_foreach_safe (   LP,
  name,
  H,
  E,
  body 
)
Value:
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 safe.

Parameters
LPlinked list pool
namelist anchor name
HIhead index
EIentry index iterator
bodycode to be executed

Definition at line 313 of file llist.h.

◆ clib_llist_free

#define clib_llist_free (   LP)    pool_free (LP)

Free list supporting container.

Parameters
LPlinked list pool

Definition at line 73 of file llist.h.

◆ clib_llist_get

#define clib_llist_get (   LP,
 
)    pool_get (LP, E)

Alloc new element.

Parameters
LPlinked list pool
Eelement to be returned

Definition at line 60 of file llist.h.

◆ clib_llist_insert

#define clib_llist_insert (   LP,
  name,
  E,
  P 
)
Value:
do { \
typeof (LP) _ll_var (N) = clib_llist_next (LP,name,P); \
_llist_insert ((LP),name,(E),(P), _ll_var (N)); \
} while (0)

Insert entry after previous.

Parameters
LPlinked list pool
namelist anchor name
Enew entry
Pprevious in list

Definition at line 196 of file llist.h.

◆ CLIB_LLIST_INVALID_INDEX

#define CLIB_LLIST_INVALID_INDEX   ((u32)~0)

Definition at line 35 of file llist.h.

◆ clib_llist_is_empty

#define clib_llist_is_empty (   LP,
  name,
 
)    (clib_llist_entry_index (LP,H) == (H)->name.next)

Check is list is empty.

Parameters
LPlinked list pool
namelist anchor name
Hlist head
Returns
1 if sentinel is the only node part of the list, 0 otherwise

Definition at line 159 of file llist.h.

◆ clib_llist_make_head

#define clib_llist_make_head (   LP,
  name 
)
Value:
({ \
typeof (LP) _ll_var (head); \
pool_get_zero ((LP), _ll_var (head)); \
clib_llist_anchor_init ((LP),name,_ll_var (head)); \
clib_llist_entry_index ((LP), _ll_var (head)); \
})

Initialize llist head.

Parameters
LPlinked list pool
namelist anchor name

Definition at line 144 of file llist.h.

◆ clib_llist_next

#define clib_llist_next (   LP,
  name,
 
)    pool_elt_at_index((LP),_lnext((E),name))

Get next pool entry.

Parameters
LPlinked list pool
namelist anchor name
Epool entry
Returns
next pool entry

Definition at line 116 of file llist.h.

◆ clib_llist_next_index

#define clib_llist_next_index (   E,
  name 
)    _lnext(E,name)

Definition at line 107 of file llist.h.

◆ clib_llist_pop_first

#define clib_llist_pop_first (   LP,
  name,
  E,
 
)
Value:
do { \
E = clib_llist_next (LP,name,H); \
clib_llist_remove (LP,name,E); \
} 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.

Parameters
LPlinked list pool
namelist anchor name
Estorage the first entry
Hlist head entry

Definition at line 253 of file llist.h.

◆ clib_llist_prev

#define clib_llist_prev (   LP,
  name,
 
)    pool_elt_at_index((LP),_lprev((E),name))

Get previous pool entry.

Parameters
LPlinked list pool
namelist anchor name
Epool entry
Returns
previous pool entry

Definition at line 125 of file llist.h.

◆ clib_llist_prev_index

#define clib_llist_prev_index (   E,
  name 
)    _lprev(E,name)

Definition at line 99 of file llist.h.

◆ clib_llist_put

#define clib_llist_put (   LP,
 
)    pool_put (LP, E)

Free element.

Parameters
LPlinked list pool
Eelement to be freed

Definition at line 67 of file llist.h.

◆ clib_llist_remove

#define clib_llist_remove (   LP,
  name,
 
)
Value:
do { \
ASSERT ((E) != clib_llist_next (LP,name,E));/* don't remove sentinel */\
ASSERT (_lnext (E,name) != CLIB_LLIST_INVALID_INDEX); \
ASSERT (_lprev (E,name) != CLIB_LLIST_INVALID_INDEX); \
typeof (LP) _ll_var (P) = clib_llist_prev ((LP),name,E); \
typeof (LP) _ll_var (N) = clib_llist_next ((LP),name,E); \
_lnext (_ll_var (P),name) = _lnext (E,name); \
_lprev (_ll_var (N),name) = _lprev (E,name); \
_lnext (E,name) = _lprev (E,name) = CLIB_LLIST_INVALID_INDEX; \
}while (0)

Remove entry from list.

Parameters
LPlinked list pool
namelist anchor name
Eentry to be removed

Definition at line 231 of file llist.h.

◆ clib_llist_splice

#define clib_llist_splice (   LP,
  name,
  P,
 
)
Value:
do { \
typeof (LP) _ll_var (fe) = clib_llist_next (LP,name,H); \
if (_ll_var (fe) != (H)) \
{ \
typeof (LP) _ll_var (le) = clib_llist_prev (LP,name,H); \
typeof (LP) _ll_var (ne) = clib_llist_next (LP,name,P); \
_lprev (_ll_var (fe),name) = clib_llist_entry_index(LP,P); \
_lnext (_ll_var (le),name) = clib_llist_entry_index(LP,_ll_var (ne));\
_lnext (P,name) = clib_llist_entry_index (LP,_ll_var (fe)); \
_lprev (_ll_var (ne),name) = clib_llist_entry_index(LP,_ll_var (le));\
_lnext (H,name) = clib_llist_entry_index(LP,H); \
_lprev (H,name) = _lnext (H,name); \
} \
} while (0)

Splice two lists at a given position.

List spliced into destination list is left with 0 entries, i.e., head is made to point to itself.

Parameters
LPlinked list pool
namelist anchor name
Pposition in destination where source list is spliced
Hhead of source list that will be spliced into destination

Definition at line 269 of file llist.h.

Typedef Documentation

◆ clib_llist_anchor_t

◆ clib_llist_index_t

Definition at line 27 of file llist.h.

pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
name
string name[64]
Definition: fib.api:25
CLIB_LLIST_INVALID_INDEX
#define CLIB_LLIST_INVALID_INDEX
Definition: llist.h:35
P
#define P(fmt,...)
clib_llist_entry_index
#define clib_llist_entry_index(LP, E)
Get list entry index.
Definition: llist.h:53
clib_llist_next
#define clib_llist_next(LP, name, E)
Get next pool entry.
Definition: llist.h:116
clib_llist_prev
#define clib_llist_prev(LP, name, E)
Get previous pool entry.
Definition: llist.h:125
N
#define N
Definition: aes_cbc.c:225