CNDP  22.08.0
cne_tailq.h File Reference
#include <sys/queue.h>
#include <stdio.h>
#include <cne_common.h>

Go to the source code of this file.

Data Structures

struct  cne_tailq_entry
struct  cne_tailq_head


#define CNE_TAILQ_CAST(tailq_entry, struct_name)   (struct struct_name *)&(tailq_entry)->tailq_head
#define CNE_TAILQ_LOOKUP(name, struct_name)   CNE_TAILQ_CAST(cne_tailq_lookup(name), struct_name)
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)


 TAILQ_HEAD (cne_tailq_entry_head, cne_tailq_entry)
CNDP_API int cne_tailqs_init (void)
CNDP_API int cne_tailq_register (struct cne_tailq_elem *t)
CNDP_API void cne_dump_tailq (void)
CNDP_API struct cne_tailq_headcne_tailq_lookup (const char *name)
CNDP_API int cne_eal_tailq_register (struct cne_tailq_elem *t)

Detailed Description

Defines cne_tailq APIs to safely iterate over a list of items or structures. The tailq APIs add non-list items to a tailq list. Add items to a tailq list by allocating a cne_tailq_entry structure and adding the structure pointer to the member. The calling function must supply protection against multiple accesses to a given cne_tailq list.

Definition in file cne_tailq.h.

Macro Definition Documentation


#define CNE_TAILQ_CAST (   tailq_entry,
)    (struct struct_name *)&(tailq_entry)->tailq_head

Return the first tailq entry cast to the right struct.

Definition at line 67 of file cne_tailq.h.


#define CNE_TAILQ_LOOKUP (   name,
)    CNE_TAILQ_CAST(cne_tailq_lookup(name), struct_name)

Utility macro to make looking up a tailqueue for a particular struct easier.

nameThe name of tailq
struct_nameThe name of the list type we are using. (Generally this is the same as the first parameter passed to TAILQ_HEAD macro)
The return value, typecast to the appropriate structure pointer type. NULL on error, since the tailq_head is the first element in the cne_tailq_head structure.

Definition at line 85 of file cne_tailq.h.


#define TAILQ_FOREACH_SAFE (   var,
for ((var) = TAILQ_FIRST((head)); \
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (tvar))

This macro permits both remove and free var within the loop safely.

Definition at line 147 of file cne_tailq.h.

Function Documentation


TAILQ_HEAD ( cne_tailq_entry_head  ,


◆ cne_tailqs_init()

CNDP_API int cne_tailqs_init ( void  )

Initialize the tailq structures.

0 on success, -1 on error code

◆ cne_tailq_register()

CNDP_API int cne_tailq_register ( struct cne_tailq_elem *  t)

Register the given tailq entry.

tThe tailq element to register.
0 on success or -1 on error

◆ cne_dump_tailq()

CNDP_API void cne_dump_tailq ( void  )

Dump tail queues to stdout.

◆ cne_tailq_lookup()

CNDP_API struct cne_tailq_head* cne_tailq_lookup ( const char *  name)

Lookup for a tail queue.

Get a pointer to a tail queue header of a tail queue identified by the name given as an argument. Note: this function is not multi-thread safe, and should only be called from a single thread at a time

nameThe name of the queue.
A pointer to the tail queue head structure.

◆ cne_eal_tailq_register()

CNDP_API int cne_eal_tailq_register ( struct cne_tailq_elem *  t)

Register a tail queue.

Register a tail queue from shared memory. This function is mainly used by some, which is used to register tailq from the different cndp libraries. Since this macro is a constructor.

tThe tailq element which contains the name of the tailq you want to create (/retrieve when in secondary process).
0 on success or -1 in case of an error.