You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

25 years ago
25 years ago
  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 */