cdefs-compat.h 2.1 KB

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