cdefs-compat.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef _CDEFS_COMPAT_H_
  2. #define _CDEFS_COMPAT_H_
  3. #ifdef __MINIOS__
  4. /* No stdio.h on Mini-OS. */
  5. #include <sys/cdefs.h>
  6. #else
  7. /*
  8. * We cannot be certain that this operating system has <sys/cdefs.h>.
  9. * Instead, include a header file that is likely to pull in this header.
  10. */
  11. #include <stdio.h>
  12. #endif
  13. #if defined(__cplusplus)
  14. #define __BEGIN_DECLS extern "C" {
  15. #define __END_DECLS }
  16. #else
  17. #define __BEGIN_DECLS
  18. #define __END_DECLS
  19. #endif
  20. #ifdef __GNUC__
  21. #ifndef __strong_reference
  22. #ifdef __APPLE__
  23. #define __strong_reference(sym,aliassym) __weak_reference(sym,aliassym)
  24. #else
  25. #define __strong_reference(sym,aliassym) \
  26. DLLEXPORT extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
  27. #endif /* __APPLE__ */
  28. #endif /* __strong_reference */
  29. #ifndef __weak_reference
  30. #ifdef __ELF__
  31. #ifdef __STDC__
  32. #define __weak_reference(sym,alias) \
  33. __asm__(".weak " #alias); \
  34. __asm__(".equ " #alias ", " #sym)
  35. #define __warn_references(sym,msg) \
  36. __asm__(".section .gnu.warning." #sym); \
  37. __asm__(".asciz \"" msg "\""); \
  38. __asm__(".previous")
  39. #else
  40. #define __weak_reference(sym,alias) \
  41. __asm__(".weak alias"); \
  42. __asm__(".equ alias, sym")
  43. #define __warn_references(sym,msg) \
  44. __asm__(".section .gnu.warning.sym"); \
  45. __asm__(".asciz \"msg\""); \
  46. __asm__(".previous")
  47. #endif /* __STDC__ */
  48. #elif defined(__clang__) /* CLANG */
  49. #ifdef __STDC__
  50. #define __weak_reference(sym,alias) \
  51. __asm__(".weak_reference " #alias); \
  52. __asm__(".set " #alias ", " #sym)
  53. #else
  54. #define __weak_reference(sym,alias) \
  55. __asm__(".weak_reference alias");\
  56. __asm__(".set alias, sym")
  57. #endif
  58. #else /* !__ELF__ */
  59. #ifdef __STDC__
  60. #define __weak_reference(sym,alias) \
  61. __asm__(".stabs \"_" #alias "\",11,0,0,0"); \
  62. __asm__(".stabs \"_" #sym "\",1,0,0,0")
  63. #define __warn_references(sym,msg) \
  64. __asm__(".stabs \"" msg "\",30,0,0,0"); \
  65. __asm__(".stabs \"_" #sym "\",1,0,0,0")
  66. #else
  67. #define __weak_reference(sym,alias) \
  68. __asm__(".stabs \"_/**/alias\",11,0,0,0"); \
  69. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  70. #define __warn_references(sym,msg) \
  71. __asm__(".stabs msg,30,0,0,0"); \
  72. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  73. #endif /* __STDC__ */
  74. #endif /* __ELF__ */
  75. #endif /* __weak_reference */
  76. #endif /* __GNUC__ */
  77. #endif /* _CDEFS_COMPAT_H_ */