/cln-1.3.2/include/cln/modules.h
C Header | 37 lines | 21 code | 5 blank | 11 comment | 2 complexity | 3d23d79569c9df74a24623f3444daec6 MD5 | raw file
Possible License(s): GPL-2.0
1// Macros for correct module ordering.
2
3#ifndef _CL_MODULES_H
4#define _CL_MODULES_H
5
6// global constructor/destructor naming.
7#include "cln/config.h"
8
9// Concatenation of macroexpanded tokens.
10// Equivalent to CL_CONCAT in src/base/cl_macros.h which we do not want
11// to expose, however.
12#define CL_CONCATENATE_(xxx,yyy) xxx##yyy
13#define CL_CONCATENATE(xxx,yyy) CL_CONCATENATE_(xxx,yyy)
14
15// Sometimes a link time dependency is needed, but without requirements
16// on initialization order.
17//
18// CL_FORCE_LINK(dummy,external_variable)
19// forces a link time reference to the external_variable.
20#include <cstdlib>
21#if 0
22// This definition does not work. It gets optimized away by g++ 3.1.
23#define CL_FORCE_LINK(dummy,external_variable) \
24 static const void* const dummy[] = { &dummy, &external_variable };
25#else
26#define CL_FORCE_LINK(dummy,external_variable) \
27 static const \
28 struct dummy { \
29 inline dummy () { \
30 if ((void*) &external_variable == (void*) this) \
31 abort(); \
32 } \
33 } \
34 CL_CONCATENATE(dummy,_instance);
35#endif
36
37#endif /* _CL_MODULES_H */