mirror of
https://github.com/lgcosta/pf-linux-port.git
synced 2026-11-15 14:24:44 -03:00
queue.h: arg-count dispatch so BSD LIST_HEAD(name,type) and Linux LIST_HEAD(name) coexist
This commit is contained in:
1 parent
f121f496b4
commit
fe6f767561
1 file changed
+24
-3
@@ -164,13 +164,34 @@ struct { \
|
|||||||
/*
|
/*
|
||||||
* List definitions.
|
* List definitions.
|
||||||
*/
|
*/
|
||||||
#define LIST_HEAD(name, type) \
|
/*
|
||||||
|
* PFLINUX: LIST_HEAD has two spellings in this tree. The ported OpenBSD
|
||||||
|
* engine uses the BSD form LIST_HEAD(name, type) (a struct with lh_first),
|
||||||
|
* while the port's own glue (pfsrc/divert_sock.c, compat/pfk_kern.c,
|
||||||
|
* compat/pfk_if.c) uses Linux's list.h form LIST_HEAD(name) (an initialised
|
||||||
|
* struct list_head). compat/sys/queue.h is included after Linux's list.h,
|
||||||
|
* so the BSD definition used to shadow the Linux one and broke the glue
|
||||||
|
* translation units. Dispatch on the argument count so both spellings
|
||||||
|
* work; LIST_HEAD_INIT is provided with Linux's exact text so that a later
|
||||||
|
* include of <linux/list.h> redefinition stays identical.
|
||||||
|
*/
|
||||||
|
#define LIST_HEAD_INITIALIZER(head) \
|
||||||
|
{ NULL }
|
||||||
|
|
||||||
|
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||||
|
|
||||||
|
#define LIST_HEAD_BSD(name, type) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct type *lh_first; /* first element */ \
|
struct type *lh_first; /* first element */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LIST_HEAD_INITIALIZER(head) \
|
#define LIST_HEAD_LINUX(name) \
|
||||||
{ NULL }
|
struct list_head name = LIST_HEAD_INIT(name)
|
||||||
|
|
||||||
|
#define LIST_HEAD_SELECT(_1, _2, NAME, ...) NAME
|
||||||
|
#define LIST_HEAD(...) \
|
||||||
|
LIST_HEAD_SELECT(__VA_ARGS__, LIST_HEAD_BSD, LIST_HEAD_LINUX) \
|
||||||
|
(__VA_ARGS__)
|
||||||
|
|
||||||
#define LIST_ENTRY(type) \
|
#define LIST_ENTRY(type) \
|
||||||
struct { \
|
struct { \
|
||||||
|
|||||||
Reference in new issue
Block a user