cdefs-compat.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _CDEFS_COMPAT_H_
  2. #define _CDEFS_COMPAT_H_
  3. #if (defined(_WIN32) || defined (_MSC_VER)) && !defined(__WIN32__)
  4. #define __WIN32__
  5. #endif
  6. #ifndef __WIN32__
  7. #include "sys/cdefs.h"
  8. #else //__WIN32__
  9. #if defined(__cplusplus)
  10. #define __BEGIN_DECLS extern "C" {
  11. #define __END_DECLS }
  12. #else
  13. #define __BEGIN_DECLS
  14. #define __END_DECLS
  15. #endif
  16. #ifdef __GNUC__
  17. #define __strong_reference(sym,aliassym) \
  18. extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
  19. #ifdef __ELF__
  20. #ifdef __STDC__
  21. #define __weak_reference(sym,alias) \
  22. __asm__(".weak " #alias); \
  23. __asm__(".equ " #alias ", " #sym)
  24. #define __warn_references(sym,msg) \
  25. __asm__(".section .gnu.warning." #sym); \
  26. __asm__(".asciz \"" msg "\""); \
  27. __asm__(".previous")
  28. #else
  29. #define __weak_reference(sym,alias) \
  30. __asm__(".weak alias"); \
  31. __asm__(".equ alias, sym")
  32. #define __warn_references(sym,msg) \
  33. __asm__(".section .gnu.warning.sym"); \
  34. __asm__(".asciz \"msg\""); \
  35. __asm__(".previous")
  36. #endif /* __STDC__ */
  37. #else /* !__ELF__ */
  38. #ifdef __STDC__
  39. #define __weak_reference(sym,alias) \
  40. __asm__(".stabs \"_" #alias "\",11,0,0,0"); \
  41. __asm__(".stabs \"_" #sym "\",1,0,0,0")
  42. #define __warn_references(sym,msg) \
  43. __asm__(".stabs \"" msg "\",30,0,0,0"); \
  44. __asm__(".stabs \"_" #sym "\",1,0,0,0")
  45. #else
  46. #define __weak_reference(sym,alias) \
  47. __asm__(".stabs \"_/**/alias\",11,0,0,0"); \
  48. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  49. #define __warn_references(sym,msg) \
  50. __asm__(".stabs msg,30,0,0,0"); \
  51. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  52. #endif /* __STDC__ */
  53. #endif /* __ELF__ */
  54. #endif /* __GNUC__ */
  55. #endif
  56. #endif