because some compilers do not use this feature, it is provided an API that forces the user to call its mem group and memtypes init.
Signed-off-by: Philippe Guibert <philippe.guib...@6wind.com> --- lib/memory.h | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/lib/memory.h b/lib/memory.h index 0c4a1ef56ccc..86971ccd5e90 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -41,27 +41,9 @@ struct memgroup { const char *name; }; -#if defined(__clang__) -# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5) -# define _RET_NONNULL , returns_nonnull -# endif -# define _CONSTRUCTOR(x) constructor(x) -#elif defined(__GNUC__) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) -# define _RET_NONNULL , returns_nonnull -# endif -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -# define _CONSTRUCTOR(x) constructor(x) -# define _ALLOC_SIZE(x) alloc_size(x) -# endif -#endif - #ifndef _RET_NONNULL # define _RET_NONNULL #endif -#ifndef _CONSTRUCTOR -# define _CONSTRUCTOR(x) constructor -#endif #ifndef _ALLOC_SIZE # define _ALLOC_SIZE(x) #endif @@ -100,12 +82,11 @@ struct memgroup { .types = NULL, .next = NULL, .insert = NULL, \ }; \ static void _mginit_##mname (void) \ - __attribute__ ((_CONSTRUCTOR (1000))); \ - static void _mginit_##mname (void) \ { extern struct memgroup **mg_insert; \ *mg_insert = &_mg_##mname; \ mg_insert = &_mg_##mname.next; } +#define INIT_MGROUP(mname) _mginit_##mname () #define DECLARE_MTYPE(name) \ extern struct memtype _mt_##name; \ @@ -118,8 +99,6 @@ struct memgroup { .next = NULL, .n_alloc = 0, .size = 0, \ }; \ static void _mtinit_##mname (void) \ - __attribute__ ((_CONSTRUCTOR (1001))); \ - static void _mtinit_##mname (void) \ { if (_mg_##group.insert == NULL) \ _mg_##group.insert = &_mg_##group.types; \ *_mg_##group.insert = &_mt_##mname; \ @@ -131,6 +110,7 @@ struct memgroup { DEFINE_MTYPE_ATTR(group, name, static, desc) \ static struct memtype * const MTYPE_ ## name = &_mt_##name; +#define INIT_MTYPE(mname) _mtinit_##mname () extern void *qmalloc (struct memtype *mt, size_t size) __attribute__ ((malloc, _ALLOC_SIZE(2), nonnull (1) _RET_NONNULL)); -- 2.1.4 _______________________________________________ Quagga-dev mailing list Quagga-dev@lists.quagga.net https://lists.quagga.net/mailman/listinfo/quagga-dev