mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-03 15:41:54 +00:00
Typed lists: enabled defining the list structure independently on the node
This commit is contained in:
parent
85c144f8ac
commit
a6f65d99b4
12
lib/tlists.h
12
lib/tlists.h
@ -71,15 +71,14 @@
|
|||||||
|
|
||||||
#define TLIST_NAME(x) MACRO_CONCAT_AFTER(TLIST_PREFIX,_##x)
|
#define TLIST_NAME(x) MACRO_CONCAT_AFTER(TLIST_PREFIX,_##x)
|
||||||
#ifndef TLIST_LIST_STRUCT
|
#ifndef TLIST_LIST_STRUCT
|
||||||
#define TLIST_LIST_STRUCT TLIST_NAME(list)
|
#define TLIST_LIST_STRUCT struct TLIST_NAME(list)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct TLIST_LIST_STRUCT {
|
#ifndef TLIST_DEFINED_BEFORE
|
||||||
TLIST_TYPE *first;
|
TLIST_STRUCT_DEF(TLIST_PREFIX, TLIST_TYPE);
|
||||||
TLIST_TYPE *last;
|
#endif
|
||||||
} TLIST_LIST_STRUCT;
|
|
||||||
|
|
||||||
static inline struct TLIST_LIST_STRUCT * TLIST_NAME(enlisted)(TLIST_TYPE *node)
|
static inline TLIST_LIST_STRUCT * TLIST_NAME(enlisted)(TLIST_TYPE *node)
|
||||||
{
|
{
|
||||||
return node->TLIST_ITEM.list;
|
return node->TLIST_ITEM.list;
|
||||||
}
|
}
|
||||||
@ -206,6 +205,7 @@ static inline void TLIST_NAME(rem_node)(TLIST_LIST_STRUCT *list, TLIST_TYPE *nod
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TLIST_LIST(_name) struct _name##_list
|
#define TLIST_LIST(_name) struct _name##_list
|
||||||
|
#define TLIST_STRUCT_DEF(_name, _type) TLIST_LIST(_name) { _type *first, *last; }
|
||||||
|
|
||||||
#define TLIST_NODE_IN(_name, _type) { _type *next; _type *prev; TLIST_LIST(_name) *list; }
|
#define TLIST_NODE_IN(_name, _type) { _type *next; _type *prev; TLIST_LIST(_name) *list; }
|
||||||
#define TLIST_NODE(_name, _type) struct _name##_node TLIST_NODE_IN(_name, _type)
|
#define TLIST_NODE(_name, _type) struct _name##_node TLIST_NODE_IN(_name, _type)
|
||||||
|
Loading…
Reference in New Issue
Block a user