PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/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. #ifndef _CL_MODULES_H
  3. #define _CL_MODULES_H
  4. // global constructor/destructor naming.
  5. #include "cln/config.h"
  6. // Concatenation of macroexpanded tokens.
  7. // Equivalent to CL_CONCAT in src/base/cl_macros.h which we do not want
  8. // to expose, however.
  9. #define CL_CONCATENATE_(xxx,yyy) xxx##yyy
  10. #define CL_CONCATENATE(xxx,yyy) CL_CONCATENATE_(xxx,yyy)
  11. // Sometimes a link time dependency is needed, but without requirements
  12. // on initialization order.
  13. //
  14. // CL_FORCE_LINK(dummy,external_variable)
  15. // forces a link time reference to the external_variable.
  16. #include <cstdlib>
  17. #if 0
  18. // This definition does not work. It gets optimized away by g++ 3.1.
  19. #define CL_FORCE_LINK(dummy,external_variable) \
  20. static const void* const dummy[] = { &dummy, &external_variable };
  21. #else
  22. #define CL_FORCE_LINK(dummy,external_variable) \
  23. static const \
  24. struct dummy { \
  25. inline dummy () { \
  26. if ((void*) &external_variable == (void*) this) \
  27. abort(); \
  28. } \
  29. } \
  30. CL_CONCATENATE(dummy,_instance);
  31. #endif
  32. #endif /* _CL_MODULES_H */