FD.io VPP  v20.09-64-g4f7b92f0a
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...
 
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 172 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)
#define P(fmt,...)
string name[64]
Definition: ip.api:44
#define clib_llist_prev(LP, name, E)
Get previous pool entry.
Definition: llist.h:87

Add entry after tail.

Parameters
LPlinked list pool
namelist anchor name
Enew entry
Hlist head

Definition at line 181 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)
string name[64]
Definition: ip.api:44
#define clib_llist_entry_index(LP, E)
Get list entry index.
Definition: llist.h:53

Initialize element in llist for entry.

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

Definition at line 95 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)
#define CLIB_LLIST_INVALID_INDEX
Definition: llist.h:35
string name[64]
Definition: ip.api:44

Check if element is linked in a list.

Parameters
Elist element
namelist anchor name

Definition at line 129 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)
string name[64]
Definition: ip.api:44
#define clib_llist_next(LP, name, E)
Get next pool entry.
Definition: llist.h:78

Walk list starting at head.

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

Definition at line 255 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)
string name[64]
Definition: ip.api:44
#define clib_llist_prev(LP, name, E)
Get previous pool entry.
Definition: llist.h:87

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 297 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)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:534
string name[64]
Definition: ip.api:44
#define clib_llist_entry_index(LP, E)
Get list entry index.
Definition: llist.h:53

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 275 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)
#define P(fmt,...)
string name[64]
Definition: ip.api:44
#define N
Definition: aes_cbc.c:225
#define clib_llist_next(LP, name, E)
Get next pool entry.
Definition: llist.h:78

Insert entry after previous.

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

Definition at line 158 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 121 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)); \
})
string name[64]
Definition: ip.api:44

Initialize llist head.

Parameters
LPlinked list pool
namelist anchor name

Definition at line 106 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 78 of file llist.h.

◆ clib_llist_next_index

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

Definition at line 69 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)
string name[64]
Definition: ip.api:44
#define clib_llist_next(LP, name, E)
Get next pool entry.
Definition: llist.h:78

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 215 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 87 of file llist.h.

◆ clib_llist_prev_index

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

Definition at line 61 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)
#define P(fmt,...)
#define CLIB_LLIST_INVALID_INDEX
Definition: llist.h:35
string name[64]
Definition: ip.api:44
#define N
Definition: aes_cbc.c:225
#define clib_llist_next(LP, name, E)
Get next pool entry.
Definition: llist.h:78
#define clib_llist_prev(LP, name, E)
Get previous pool entry.
Definition: llist.h:87

Remove entry from list.

Parameters
LPlinked list pool
namelist anchor name
Eentry to be removed

Definition at line 193 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)
#define P(fmt,...)
string name[64]
Definition: ip.api:44
#define clib_llist_next(LP, name, E)
Get next pool entry.
Definition: llist.h:78
#define clib_llist_prev(LP, name, E)
Get previous pool entry.
Definition: llist.h:87
#define clib_llist_entry_index(LP, E)
Get list entry index.
Definition: llist.h:53

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 231 of file llist.h.

Typedef Documentation

◆ clib_llist_anchor_t

◆ clib_llist_index_t

Definition at line 27 of file llist.h.