From: Maria Matejka Date: Tue, 31 Jan 2023 13:30:35 +0000 (+0100) Subject: Typed lists: shortcut for simple nodes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f9772863c39fbe52a55cd2a2a193d1b080ebe1c;p=thirdparty%2Fbird.git Typed lists: shortcut for simple nodes --- diff --git a/lib/tlists.h b/lib/tlists.h index e1ed79ea4..1437e17e4 100644 --- a/lib/tlists.h +++ b/lib/tlists.h @@ -147,9 +147,14 @@ static inline void TLIST_NAME(rem_node)(TLIST_LIST_STRUCT *list, TLIST_TYPE *nod #error "You should first include lib/tlists.h without requesting a TLIST" #endif -#define TLIST_NODE(_name, _type) struct _name##_node { _type *next; _type *prev; } +#define TLIST_NODE_CONTENTS(_type) { _type *next; _type *prev; } +#define TLIST_NODE(_name, _type) struct _name##_node TLIST_NODE_CONTENTS(_type) +#define TLIST_DEFAULT_NODE struct MACRO_CONCAT_AFTER(TLIST_PREFIX,_node) \ + TLIST_NODE_CONTENTS(TLIST_TYPE) TLIST_ITEM + #define TLIST_LIST(_name) struct _name##_list + /* Use ->first and ->last to access HEAD and TAIL */ #define THEAD(_name, _list) (_list)->first #define TTAIL(_name, _list) (_list)->last