_DEF macros checks if a global oplist is register if there is no one

given in the macro call. If it founds one, it will be it instead
of M_DEFAULT_OPLIST.
This commit is contained in:
Patrick Pelissier committed 2017-09-16 08:31:22 +02:00
1 parent 67b690bac8
commit 1930bdeac1
11 files changed
+135 -90

No files matched your search

+12 -8
View File
@@ -35,9 +35,9 @@
/* Define the oplist of a intrusive shared pointer.
USAGE: ISHARED_OPLIST(name [, oplist_of_the_type]) */
#define ISHARED_PTR_OPLIST(...) \
M_IF_NARGS_EQ1(__VA_ARGS__) \
(ISHAREDI_PTR_OPLIST(__VA_ARGS__, M_DEFAULT_OPLIST ), \
ISHAREDI_PTR_OPLIST(__VA_ARGS__ ))
ISHAREDI_PTR_OPLIST(M_IF_NARGS_EQ1(__VA_ARGS__) \
((__VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__) ), \
(__VA_ARGS__ )))
/* Interface to add to a structure to allow intrusive support.
name: name of the intrusive shared pointer.
@@ -48,15 +48,17 @@
/* Define the intrusive shared pointer type and its static inline functions.
USAGE: ISHARED_PTR_DEF(name[, oplist]) */
#define ISHARED_PTR_DEF(name, ...) \
M_IF_NARGS_EQ1(__VA_ARGS__) \
(ISHAREDI_PTR_DEF2(name, __VA_ARGS__, M_DEFAULT_OPLIST ), \
ISHAREDI_PTR_DEF2(name, __VA_ARGS__ ))
#define ISHARED_PTR_DEF(name, ...) \
ISHAREDI_PTR_DEF(M_IF_NARGS_EQ1(__VA_ARGS__) \
((name, __VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__) ), \
(name, __VA_ARGS__ )))
/********************************** INTERNAL ************************************/
#define ISHAREDI_PTR_OPLIST(name, oplist) ( \
#define ISHAREDI_PTR_OPLIST(arg) ISHAREDI_PTR_OPLIST2 arg
#define ISHAREDI_PTR_OPLIST2(name, oplist) ( \
INIT(M_INIT_DEFAULT), \
INIT_SET(M_C(name, _init_set2) M_IPTR), \
SET(M_C(name, _set) M_IPTR), \
@@ -70,6 +72,8 @@
,M_IF_METHOD(DEL, oplist)(DEL(M_GET_DEL oplist),) \
)
#define ISHAREDI_PTR_DEF(arg) ISHAREDI_PTR_DEF2 arg
#define ISHAREDI_PTR_DEF2(name, type, oplist) \
\
typedef type *M_C(name,_t); \