openlibm_compat.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef _OPENLIBM_COMPAT_H_
  2. #define _OPENLIBM_COMPAT_H_
  3. #define DLLEXPORT
  4. #define __FBSDID(s)
  5. #ifdef __MINIOS__
  6. /* No stdio.h on Mini-OS. */
  7. #include <sys/cdefs.h>
  8. #else
  9. /*
  10. * We cannot be certain that this operating system has <sys/cdefs.h>.
  11. * Instead, include a header file that is likely to pull in this header.
  12. */
  13. #include <stdio.h>
  14. #endif
  15. #if defined(__cplusplus)
  16. #define __BEGIN_DECLS extern "C" {
  17. #define __END_DECLS }
  18. #else
  19. #define __BEGIN_DECLS
  20. #define __END_DECLS
  21. #endif
  22. #ifdef __GNUC__
  23. #ifndef __strong_reference
  24. #ifdef __APPLE__
  25. #define __strong_reference(sym,aliassym) __weak_reference(sym,aliassym)
  26. #else
  27. #define __strong_reference(sym,aliassym) \
  28. DLLEXPORT extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
  29. #endif /* __APPLE__ */
  30. #endif /* __strong_reference */
  31. #ifndef __weak_reference
  32. #ifdef __ELF__
  33. #ifdef __STDC__
  34. #define __weak_reference(sym,alias) \
  35. __asm__(".weak " #alias); \
  36. __asm__(".equ " #alias ", " #sym)
  37. #define __warn_references(sym,msg) \
  38. __asm__(".section .gnu.warning." #sym); \
  39. __asm__(".asciz \"" msg "\""); \
  40. __asm__(".previous")
  41. #else
  42. #define __weak_reference(sym,alias) \
  43. __asm__(".weak alias"); \
  44. __asm__(".equ alias, sym")
  45. #define __warn_references(sym,msg) \
  46. __asm__(".section .gnu.warning.sym"); \
  47. __asm__(".asciz \"msg\""); \
  48. __asm__(".previous")
  49. #endif /* __STDC__ */
  50. #elif defined(__clang__) /* CLANG */
  51. #ifdef __STDC__
  52. #define __weak_reference(sym,alias) \
  53. __asm__(".weak_reference " #alias); \
  54. __asm__(".set " #alias ", " #sym)
  55. #else
  56. #define __weak_reference(sym,alias) \
  57. __asm__(".weak_reference alias");\
  58. __asm__(".set alias, sym")
  59. #endif
  60. #else /* !__ELF__ */
  61. #ifdef __STDC__
  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. #else
  69. #define __weak_reference(sym,alias) \
  70. __asm__(".stabs \"_/**/alias\",11,0,0,0"); \
  71. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  72. #define __warn_references(sym,msg) \
  73. __asm__(".stabs msg,30,0,0,0"); \
  74. __asm__(".stabs \"_/**/sym\",1,0,0,0")
  75. #endif /* __STDC__ */
  76. #endif /* __ELF__ */
  77. #endif /* __weak_reference */
  78. #endif /* __GNUC__ */
  79. #include <stdint.h>
  80. #include <limits.h>
  81. #include <stdint.h>
  82. #ifdef __GLIBC__
  83. /* Not sure what to do about __pure2 on linux */
  84. #define __pure2
  85. #endif
  86. #ifdef _WIN32
  87. /* Not sure what to do about __pure2 on windows */
  88. #define __pure2
  89. #endif
  90. typedef uint8_t u_int8_t;
  91. typedef uint16_t u_int16_t;
  92. typedef uint32_t u_int32_t;
  93. typedef uint64_t u_int64_t;
  94. typedef float float_t;
  95. #ifndef __always_inline
  96. # define __always_inline __inline __attribute__ ((__always_inline__))
  97. #endif
  98. #endif