timath.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef __TIMATH
  2. #define __TIMATH
  3. #include <default.h>
  4. /* Begin Auto-Generated Part */
  5. #define FIVE (5.)
  6. #define FOUR (4.)
  7. #define HALF_PI (1.570796326794897)
  8. #define HALF (0.5)
  9. #define MINUS_ONE (-1.)
  10. #define NAN (0./0.)
  11. #define NEGATIVE_INF (1/NEGATIVE_ZERO)
  12. #define NEGATIVE_ZERO (-POSITIVE_ZERO)
  13. #define ONE (1.)
  14. #define PI (3.141592653589793)
  15. #define POSITIVE_INF (1/POSITIVE_ZERO)
  16. #define POSITIVE_ZERO (1.e-8192*1.e-8192)
  17. #define TEN (10.)
  18. #define THREE (3.)
  19. #define TWO (2.)
  20. #define UNSIGNED_INF (1/UNSIGNED_ZERO)
  21. #define UNSIGNED_ZERO (0.)
  22. #define ZERO (0.)
  23. #ifndef __HAVE_Bool
  24. #define __HAVE_Bool
  25. enum Bool{FALSE,TRUE};
  26. #endif
  27. #ifndef __HAVE_bcd
  28. #define __HAVE_bcd
  29. typedef struct{unsigned short exponent;unsigned long long mantissa;}bcd __attribute__((__may_alias__));
  30. #endif
  31. #ifndef __HAVE_ti_float
  32. #define __HAVE_ti_float
  33. typedef float ti_float;
  34. #endif
  35. #define abs(x) ({typeof(x) __x = (x); __x >= 0 ? __x : -__x;})
  36. #define acos(x) _tios_float_1(F5,x,float)
  37. #define acosh(x) _tios_float_1(288,x,float)
  38. #define asin(x) _tios_float_1(F6,x,float)
  39. #define asinh(x) _tios_float_1(287,x,float)
  40. #define atan2(x,y) _tios_float_2(F8,x,y,float,float)
  41. #define atan(x) _tios_float_1(F7,x,float)
  42. #define atanh(x) _tios_float_1(289,x,float)
  43. #define bcd_to_float(a) ({bcd __a=(a);*(float*)&__a;})
  44. #define bcd_var(a) (*(bcd*)&(a))
  45. #define bcdadd(x,y) ({bcd __x=(x),__y=(y);float __z=fadd(*(float*)&__x,*(float*)&__y);*(bcd*)&__z;})
  46. #define bcdbcd(x) ({float __x=flt(x);*(bcd*)&__x;})
  47. #define bcdcmp(x,y) ({bcd __x=(x),__y=(y);fcmp(*(float*)&__x,*(float*)&__y);})
  48. #define bcddiv(x,y) ({bcd __x=(x),__y=(y);float __z=fdiv(*(float*)&__x,*(float*)&__y);*(bcd*)&__z;})
  49. #define bcdlong(x) ({bcd __x=(x);trunc(*(float*)&__x);})
  50. #define bcdmul(x,y) ({bcd __x=(x),__y=(y);float __z=fmul(*(float*)&__x,*(float*)&__y);*(bcd*)&__z;})
  51. #define bcdneg(x) ({bcd __x=(x);float __y=fneg(*(float*)&__x);*(bcd*)&__y;})
  52. #define bcdsub(x,y) ({bcd __x=(x),__y=(y);float __z=fsub(*(float*)&__x,*(float*)&__y);*(bcd*)&__z;})
  53. #define cacos _rom_call(void,(float,float,float*,float*),13A)
  54. #define cacosh _rom_call(void,(float,float,float*,float*),13D)
  55. #define casin _rom_call(void,(float,float,float*,float*),13B)
  56. #define casinh _rom_call(void,(float,float,float*,float*),13E)
  57. #define catan _rom_call(void,(float,float,float*,float*),13C)
  58. #define catanh _rom_call(void,(float,float,float*,float*),13F)
  59. #define ccos _rom_call(void,(float,float,float*,float*),140)
  60. #define ccosh _rom_call(void,(float,float,float*,float*),143)
  61. #define ceil(x) _tios_float_1(105,x,float)
  62. #define cexp _rom_call(void,(float,float,float*,float*),149)
  63. #define cln _rom_call(void,(float,float,float*,float*),147)
  64. #define clog10 _rom_call(void,(float,float,float*,float*),148)
  65. #define cos(x) _tios_float_1(F9,x,float)
  66. #define cosh(x) _tios_float_1(FC,x,float)
  67. #define csin _rom_call(void,(float,float,float*,float*),141)
  68. #define csinh _rom_call(void,(float,float,float*,float*),144)
  69. #define csqrt _rom_call(void,(float,float,float*,float*),146)
  70. #define ctan _rom_call(void,(float,float,float*,float*),142)
  71. #define ctanh _rom_call(void,(float,float,float*,float*),145)
  72. #define exp(x) _tios_float_1(FF,x,float)
  73. #define fabs(x) _tios_float_1(106,x,float)
  74. #define fadd(x,y) _tios_float_2(B6,x,y,float,float)
  75. #define fcmp _rom_call(long,(float,float),BB)
  76. #define fdiv(x,y) _tios_float_2(B9,x,y,float,float)
  77. #define FEXP_NEG(x,y) (*(float*)&(bcd){0xC000+y,0x##x##LL<<4*(17-sizeof(#x))})
  78. #define FEXP(x,y) (*(float*)&(bcd){0x4000+y,0x##x##LL<<4*(17-sizeof(#x))})
  79. #define float_to_bcd(a) ({float __a=(a);*(bcd*)&__a;})
  80. #define floor(x) _tios_float_1(107,x,float)
  81. #define FLT_NEG(x,y...) ((sizeof(#y)==1)?-x##.0:-x##.##y)
  82. #define flt(x) _tios_float_1(BD,x,long)
  83. #define FLT(x,y...) ((sizeof(#y)==1)?x##.0:x##.##y)
  84. #define fmod(x,y) _tios_float_2(108,x,y,float,float)
  85. #define fmul(x,y) _tios_float_2(B8,x,y,float,float)
  86. #define fneg(x) _tios_float_1(BA,x,float)
  87. #define fpisanint _rom_call(short,(unsigned long long*,short),172)
  88. #define fpisodd _rom_call(short,(const unsigned long long*,short),173)
  89. #define fsub(x,y) _tios_float_2(B7,x,y,float,float)
  90. #define hypot(x,y) ({float __x=(x),__y=(y);sqrt(fadd(fmul((__x),(__x)),fmul((__y),(__y))));})
  91. #define init_float() ((void)0)
  92. #define itrig _rom_call(void,(short,short,float*,float*),28A)
  93. #ifndef __HAVE_labs
  94. #define __HAVE_labs
  95. long labs(long)__ATTR_GCC__;
  96. #endif
  97. #define ldexp10(x,e) ({float __f=(x);((bcd*)&__f)->exponent+=(e);__f;})
  98. #define log(x) _tios_float_1(100,x,float)
  99. #define log10(x) _tios_float_1(101,x,float)
  100. #define modf(x,y) _tios_float_2(102,x,y,float,float*)
  101. #define pow(x,y) _tios_float_2(103,x,y,float,float)
  102. #define round12_err(x,y) _tios_float_2(227,x,y,float,short)
  103. #define round12(x) _tios_float_1(174,x,float)
  104. #define round14(x) _tios_float_1(175,x,float)
  105. #define sin(x) _tios_float_1(FA,x,float)
  106. #define sincos _rom_call(void,(float,short,float*,float*),286)
  107. #define sinh(x) _tios_float_1(FD,x,float)
  108. #define sqrt(x) _tios_float_1(104,x,float)
  109. #define tan(x) _tios_float_1(FB,x,float)
  110. #define tanh(x) _tios_float_1(FE,x,float)
  111. #define trig _rom_call(void,(short,short,const float*,float*,float*,float*),28B)
  112. #define trunc _rom_call(long,(float),BC)
  113. #if MIN_AMS>=101
  114. #ifndef __HAVE_atof
  115. #define __HAVE_atof
  116. extern float atof(const char*)__ATTR_LIB_ASM__;
  117. #endif
  118. #define float_class _rom_call(short,(float),2FA)
  119. #define frexp10(x,y) _tios_float_2(2FB,x,y,float,__pshort)
  120. #define is_float_infinity _rom_call(short,(float),2FF)
  121. #define is_float_negative_zero _rom_call(short,(float),300)
  122. #define is_float_positive_zero _rom_call(short,(float),301)
  123. #define is_float_signed_infinity _rom_call(short,(float),302)
  124. #define is_float_transfinite _rom_call(short,(float),303)
  125. #define is_float_unsigned_inf_or_nan _rom_call(short,(float),304)
  126. #define is_float_unsigned_zero _rom_call(short,(float),305)
  127. #define is_inf _rom_call(short,(float),2FF)
  128. #define is_nan _rom_call(short,(float),306)
  129. #define is_nzero _rom_call(short,(float),300)
  130. #define is_pzero _rom_call(short,(float),301)
  131. #define is_sinf _rom_call(short,(float),302)
  132. #define is_transfinite _rom_call(short,(float),303)
  133. #define is_uinf_or_nan _rom_call(short,(float),304)
  134. #define is_uzero _rom_call(short,(float),305)
  135. #endif
  136. /* End Auto-Generated Part */
  137. #endif