Blog
Community
Development
Documentation
CNDP
22.08.0
cne_tailq.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2019-2022 Intel Corporation
3
*/
4
5
#ifndef _CNE_TAILQ_H_
6
#define _CNE_TAILQ_H_
7
17
#include <sys/queue.h>
18
#include <stdio.h>
19
20
#include <
cne_common.h
>
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
27
struct
cne_tailq_entry
{
28
TAILQ_ENTRY
(
cne_tailq_entry
) next;
29
void
*
data
;
30
};
32
TAILQ_HEAD
(cne_tailq_entry_head,
cne_tailq_entry
);
33
34
#define CNE_MAX_TAILQS 32
35
#define CNE_TAILQ_NAMESIZE 32
36
43
struct
cne_tailq_head
{
44
struct
cne_tailq_entry_head
tailq_head
;
45
char
name[CNE_TAILQ_NAMESIZE];
46
};
47
48
struct
cne_tailq_elem {
52
struct
cne_tailq_head
*head;
53
TAILQ_ENTRY(cne_tailq_elem) next;
54
const
char
name[CNE_TAILQ_NAMESIZE];
55
};
56
57
#define CNE_REGISTER_TAILQ(t) \
58
CNE_INIT(tailqinitfn_##t) \
59
{ \
60
if (cne_tailq_register(&t) < 0) \
61
cne_panic("Cannot initialize tailq: %s\n"
, t.name); \
62
}
63
67
#define CNE_TAILQ_CAST(tailq_entry, struct_name) (struct struct_name *)&(tailq_entry)->tailq_head
68
85
#define CNE_TAILQ_LOOKUP(name, struct_name) CNE_TAILQ_CAST(cne_tailq_lookup(name), struct_name)
86
93
CNDP_API
int
cne_tailqs_init
(
void
);
94
103
CNDP_API
int
cne_tailq_register
(
struct
cne_tailq_elem *t);
104
109
CNDP_API
void
cne_dump_tailq
(
void
);
110
124
CNDP_API
struct
cne_tailq_head
*
cne_tailq_lookup
(
const
char
*name);
125
140
CNDP_API
int
cne_eal_tailq_register
(
struct
cne_tailq_elem *t);
141
145
#ifndef TAILQ_FOREACH_SAFE
146
// clang-format off
147
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
148
for ((var) = TAILQ_FIRST((head)); \
149
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
150
(var) = (tvar))
151
// clang-format on
152
#endif
153
154
#ifdef __cplusplus
155
}
156
#endif
157
158
#endif
/* _CNE_TAILQ_H_ */
cne_common.h
TAILQ_HEAD
TAILQ_HEAD(cne_tailq_entry_head, cne_tailq_entry)
cne_eal_tailq_register
CNDP_API int cne_eal_tailq_register(struct cne_tailq_elem *t)
cne_dump_tailq
CNDP_API void cne_dump_tailq(void)
cne_tailqs_init
CNDP_API int cne_tailqs_init(void)
cne_tailq_register
CNDP_API int cne_tailq_register(struct cne_tailq_elem *t)
cne_tailq_lookup
CNDP_API struct cne_tailq_head * cne_tailq_lookup(const char *name)
cne_tailq_entry
Definition:
cne_tailq.h:27
cne_tailq_entry::TAILQ_ENTRY
TAILQ_ENTRY(cne_tailq_entry) next
cne_tailq_entry::data
void * data
Definition:
cne_tailq.h:29
cne_tailq_head
Definition:
cne_tailq.h:43
cne_tailq_head::tailq_head
struct cne_tailq_entry_head tailq_head
Definition:
cne_tailq.h:44
lib
include
cne_tailq.h
Generated by
1.9.1