home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / gcc-2.3.3-src.lha / GNU / src / amiga / gcc-2.3.3 / math-convex.h < prev    next >
C/C++ Source or Header  |  1994-02-06  |  5KB  |  197 lines

  1. #ifndef __HAVE_MATH_CONVEX__
  2. #define __HAVE_MATH_CONVEX__
  3.  
  4. #define HUGE     8.98846567431157854e+307    /* max double in native mode */
  5.  
  6. #define HUGE_VAL 8.98846567431157854e+307
  7.  
  8. #define M_E        2.71828182845904523536
  9. #define M_LN10        2.30258509299404568402
  10. #define M_LN2        0.69314718055994530942
  11. #define M_LOG10E    0.43429448190325182765
  12. #define M_LOG2E        1.44269504088896340736
  13. #define M_PI        3.14159265358979323846
  14. #define M_PI_2        1.57079632679489661923
  15. #define M_PI_4        0.78539816339744830962
  16. #define M_SQRT1_2    0.70710678118654752440
  17. #define M_SQRT2        1.41421356237309504880
  18. #define M_1_PI        0.31830988618379067154
  19. #define M_2_PI        0.63661977236758134308
  20. #define M_2_SQRTPI    1.12837916709551257390
  21.  
  22. extern __const__ double acos (double);
  23. extern __const__ double asin (double);
  24. extern __const__ double atan (double);
  25. extern __const__ double atan2 (double, double);
  26. extern double atof (__const__ char *);
  27. extern __const__ double cabs ();
  28. extern __const__ double ceil (double);
  29. extern __const__ double cos (double);
  30. extern __const__ double cosh (double);
  31. extern __const__ double dcvtid (double);
  32. extern __const__ double exp (double);
  33. extern __const__ double fabs (double);
  34. extern __const__ double floor (double);
  35. extern double frexp (double, int *);
  36. extern __const__ double gamma (double);
  37. extern __const__ double hypot (double, double);
  38. extern __const__ double idcvtd (double);
  39. extern __const__ double ircvtr (double);
  40. extern __const__ double j0 (double);
  41. extern __const__ double j1 (double);
  42. extern __const__ double jn (int, double);
  43. extern __const__ double ldexp (double, int);
  44. extern __const__ double log (double);
  45. extern __const__ double log10 (double);
  46. extern __const__ double fmod (double, double);
  47. extern double modf (double, double *);
  48. extern __const__ double pow (double, double);
  49. extern __const__ double rcvtir (double);
  50. extern __const__ double sacos (double);
  51. extern __const__ double sasin (double);
  52. extern __const__ double satan (double);
  53. extern __const__ double satan2 (double);
  54. extern __const__ double scabs ();
  55. extern __const__ double scos (double);
  56. extern __const__ double scosh (double);
  57. extern __const__ double sexp (double);
  58. extern __const__ double sfabs (double);
  59. extern __const__ double shypot (double, double);
  60. extern __const__ double sin (double);
  61. extern __const__ double sinh (double);
  62. extern __const__ double slog (double);
  63. extern __const__ double slog10 (double);
  64. extern __const__ double spow (double);
  65. extern __const__ double sqrt (double);
  66. extern __const__ double ssin (double);
  67. extern __const__ double ssinh (double);
  68. extern __const__ double ssqrt (double);
  69. extern __const__ double stan (double);
  70. extern __const__ double stanh (double);
  71. extern __const__ double tan (double);
  72. extern __const__ double tanh (double);
  73. extern __const__ double y0 (double);
  74. extern __const__ double y1 (double);
  75. extern __const__ double yn (int, double);
  76. extern __const__ long int ipow (int, int);
  77. extern __const__ long long int lpow (long long int, long long int);
  78.  
  79. #define fabs(x)         __builtin_fabs(x)
  80.  
  81. #ifdef __convex__
  82.  
  83. #define frexp(x,y)    __inline_frexp(x,y)
  84. #define ldexp(x,y)    __inline_ldexp(x,y)
  85.  
  86. #ifdef __convex_c2__
  87.  
  88. #define ceil(x)        __inline_ceil (x)
  89. #define cos(x)        __inline_cos (x)
  90. #define exp(x)        __inline_exp (x)
  91. #define floor(x)    __inline_floor (x)
  92. #define log(x)        __inline_log (x)
  93. #define log10(x)    __inline_log10 (x)
  94. #define modf(x,y)    __inline_modf ((x), (y))
  95. #define sin(x)        __inline_sin (x)
  96. #define sqrt(x)        __inline_sqrt (x)
  97.  
  98. #endif __convex_c2__
  99.  
  100. __inline__ static __const__ double __inline_ceil (double x)
  101. {
  102.   double z;
  103.   __asm__ ("frint.d %1,%0" : "=d" (z) : "d" (x));
  104.   if (z < x) z += 1.0;
  105.   return z;
  106. }
  107.  
  108. __inline__ static __const__ double __inline_cos (double x)
  109. {
  110.   double z;
  111.   __asm__ ("cos.d %0" : "=d" (z) : "0" (x));
  112.   return z;
  113. }
  114.  
  115. __inline__ static __const__ double __inline_exp (double x)
  116. {
  117.   double z;
  118.   __asm__ ("exp.d %0" : "=d" (z) : "0" (x));
  119.   return z;
  120. }
  121.  
  122. __inline__ static __const__ double __inline_floor (double x)
  123. {
  124.   double z;
  125.   __asm__ ("frint.d %1,%0" : "=d" (z) : "d" (x));
  126.   if (z > x) z -= 1.0;
  127.   return z;
  128. }
  129.  
  130. __inline__ static __const__ double __inline_frexp (double x, int *np)
  131. {
  132.   union u {double d; unsigned long long ll;} u;
  133.   if ((u.d = x) == 0)
  134.     *np = 0;
  135.   else
  136.     {
  137.       *np = ((u.ll >> 52) & 03777) - 02000;
  138.       u.ll = (u.ll & 0x800fffffffffffffLL) | ((union u) {0.5}).ll;
  139.     }
  140.   return u.d;
  141. }
  142.  
  143. __inline__ static __const__ double __inline_ldexp (double x, int n)
  144. {
  145.   extern int errno;
  146.   union {double d; long long ll; unsigned sexp : 12;} u;
  147.   if ((u.d = x) != 0)
  148.     {
  149.       int exp = n + (u.sexp & 03777);
  150.       if (exp <= 0)
  151.     u.ll = 0, errno = 34;
  152.       else if (exp > 03777)
  153.     u.ll |= 0x7fffffffffffffffLL, errno = 34;
  154.       else
  155.     u.ll += (long long) n << 52;
  156.     }
  157.   return u.d;
  158. }
  159.  
  160. __inline__ static __const__ double __inline_log (double x)
  161. {
  162.   double z;
  163.   __asm__ ("ln.d %0" : "=d" (z) : "0" (x));
  164.   return z;
  165. }
  166.  
  167. __inline__ static __const__ double __inline_log10 (double x)
  168. {
  169.   return M_LOG10E * __inline_log (x);
  170. }
  171.  
  172. __inline__ static __const__ double __inline_modf (double x, double *np)
  173. {
  174.   double intpart;
  175.   __asm__ ("frint.d %1,%0" : "=d" (intpart) : "d" (x));
  176.   *np = intpart;
  177.   return x - intpart;
  178. }
  179.  
  180. __inline__ static __const__ double __inline_sin (double x)
  181. {
  182.   double z;
  183.   __asm__ ("sin.d %0" : "=d" (z) : "0" (x));
  184.   return z;
  185. }
  186.  
  187. __inline__ static __const__ double __inline_sqrt (double x)
  188. {
  189.   double z;
  190.   __asm__ ("sqrt.d %0" : "=d" (z) : "0" (x));
  191.   return z;
  192. }
  193.  
  194. #endif __convex__
  195.  
  196. #endif /* __HAVE_MATH_CONVEX__ */
  197.