rtm.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * RT-Thread RuiChing
  3. *
  4. * COPYRIGHT (C) 2024-2025 Shanghai Real-Thread Electronic Technology Co., Ltd.
  5. * All rights reserved.
  6. *
  7. * The license and distribution terms for this file may be
  8. * found in the file LICENSE in this distribution.
  9. */
  10. #ifndef __RTM_H__
  11. #define __RTM_H__
  12. #include <rtdef.h>
  13. #include <rtthread.h>
  14. #ifdef RT_USING_MODULE
  15. struct rt_module_symtab
  16. {
  17. void *addr;
  18. const char *name;
  19. };
  20. #if defined(_MSC_VER)
  21. #pragma section("RTMSymTab$f",read)
  22. #define RTM_EXPORT(symbol) \
  23. __declspec(allocate("RTMSymTab$f"))const char __rtmsym_##symbol##_name[] = "__vs_rtm_"#symbol;
  24. #pragma comment(linker, "/merge:RTMSymTab=mytext")
  25. #elif defined(__MINGW32__)
  26. #define RTM_EXPORT(symbol)
  27. #else
  28. #define RTM_EXPORT(symbol) \
  29. const char __rtmsym_##symbol##_name[] rt_section(".rodata.name") = #symbol; \
  30. const struct rt_module_symtab __rtmsym_##symbol rt_section("RTMSymTab")= \
  31. { \
  32. (void *)&symbol, \
  33. __rtmsym_##symbol##_name \
  34. };
  35. #endif
  36. #else
  37. #define RTM_EXPORT(symbol)
  38. #endif
  39. #endif