cdefs-compat.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _CDEFS_COMPAT_H_
  2. #define _CDEFS_COMPAT_H_
  3. #if defined(__cplusplus)
  4. #define __BEGIN_DECLS extern "C" {
  5. #define __END_DECLS }
  6. #else
  7. #define __BEGIN_DECLS
  8. #define __END_DECLS
  9. #endif
  10. #ifdef __GNUC__
  11. #ifndef __strong_reference
  12. #ifdef __APPLE__
  13. #define __strong_reference(sym,aliassym) __weak_reference(sym,aliassym)
  14. #else
  15. #define __strong_reference(sym,aliassym) \
  16. OLM_DLLEXPORT extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
  17. #endif /* __APPLE__ */
  18. #endif /* __strong_reference */
  19. #ifndef __weak_reference
  20. #ifdef __ELF__
  21. #ifdef __STDC__
  22. #define __weak_reference(sym,alias) \
  23. __asm__(".weak " #alias); \
  24. __asm__(".equ " #alias ", " #sym)
  25. #define __warn_references(sym,msg) \
  26. __asm__(".section .gnu.warning." #sym); \
  27. __asm__(".asciz \"" msg "\""); \
  28. __asm__(".previous")
  29. #else
  30. #define __weak_reference(sym,alias) \
  31. __asm__(".weak alias"); \
  32. __asm__(".equ alias, sym")
  33. #define __warn_references(sym,msg) \
  34. __asm__(".section .gnu.warning.sym"); \
  35. __asm__(".asciz \"msg\""); \
  36. __asm__(".previous")
  37. #endif /* __STDC__ */
  38. #elif defined(__clang__) /* CLANG */
  39. #ifdef __STDC__
  40. #define __weak_reference(sym,alias) \
  41. __asm__(".weak_reference " #alias); \
  42. __asm__(".set " #alias ", " #sym)
  43. #else
  44. #define __weak_reference(sym,alias) \
  45. __asm__(".weak_reference alias");\
  46. __asm__(".set alias, sym")
  47. #endif
  48. #else /* !__ELF__ */
  49. #ifdef __STDC__
  50. #define __weak_reference(sym,alias) \
  51. __asm__(".stabs \"_" #alias "\",11,0,0,0"); \
  52. __asm__(".stabs \"_" #sym "\",1,0,0,0")
  53. #define __warn_references(sym,msg) \
  54. __asm__(".stabs \"" msg "\",30,0,0,0"); \
  55. __asm__(".stabs \"_" #sym "\",1,0,0,0")
  56. #else
  57. #define __weak_reference(sym,alias) \
  58. __asm__(".stabs \"_/**/alias\",11,0,0,0"); \
  59. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  60. #define __warn_references(sym,msg) \
  61. __asm__(".stabs msg,30,0,0,0"); \
  62. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  63. #endif /* __STDC__ */
  64. #endif /* __ELF__ */
  65. #endif /* __weak_reference */
  66. #endif /* __GNUC__ */
  67. #endif /* _CDEFS_COMPAT_H_ */