Commit 294d0b3d by Charles Hannum

entered into RCS

From-SVN: r1067
parent 93639b52
/******************************************************************\ /******************************************************************\
* * * *
* <math-68881.h> last modified: 18 May 1989. * * <math-68881.h> last modified: 23 May 1992. *
* * * *
* Copyright (C) 1989 by Matthew Self. * * Copyright (C) 1989 by Matthew Self. *
* You may freely distribute verbatim copies of this software * * You may freely distribute verbatim copies of this software *
...@@ -19,9 +19,13 @@ ...@@ -19,9 +19,13 @@
* * * *
\******************************************************************/ \******************************************************************/
/* If you find this in GCC,
please send bug reports to bug-gcc@prep.ai.mit.edu. */
/* Changed by Richard Stallman: % inserted before a #. /* Changed by Richard Stallman: % inserted before a #.
New function `hypot' added. New function `hypot' added.
Nans written in hex to avoid 0rnan. Nans written in hex to avoid 0rnan.
May 1992, use %! for fpcr register. Break lines before function names.
December 1989, add parens around `&' in pow. December 1989, add parens around `&' in pow.
November 1990, added alternate definition of HUGE_VAL for Sun. */ November 1990, added alternate definition of HUGE_VAL for Sun. */
...@@ -48,7 +52,8 @@ ...@@ -48,7 +52,8 @@
#endif #endif
#endif #endif
__inline static const double sin (double x) __inline static const double
sin (double x)
{ {
double value; double value;
...@@ -58,7 +63,8 @@ __inline static const double sin (double x) ...@@ -58,7 +63,8 @@ __inline static const double sin (double x)
return value; return value;
} }
__inline static const double cos (double x) __inline static const double
cos (double x)
{ {
double value; double value;
...@@ -68,7 +74,8 @@ __inline static const double cos (double x) ...@@ -68,7 +74,8 @@ __inline static const double cos (double x)
return value; return value;
} }
__inline static const double tan (double x) __inline static const double
tan (double x)
{ {
double value; double value;
...@@ -78,7 +85,8 @@ __inline static const double tan (double x) ...@@ -78,7 +85,8 @@ __inline static const double tan (double x)
return value; return value;
} }
__inline static const double asin (double x) __inline static const double
asin (double x)
{ {
double value; double value;
...@@ -88,7 +96,8 @@ __inline static const double asin (double x) ...@@ -88,7 +96,8 @@ __inline static const double asin (double x)
return value; return value;
} }
__inline static const double acos (double x) __inline static const double
acos (double x)
{ {
double value; double value;
...@@ -98,7 +107,8 @@ __inline static const double acos (double x) ...@@ -98,7 +107,8 @@ __inline static const double acos (double x)
return value; return value;
} }
__inline static const double atan (double x) __inline static const double
atan (double x)
{ {
double value; double value;
...@@ -108,7 +118,8 @@ __inline static const double atan (double x) ...@@ -108,7 +118,8 @@ __inline static const double atan (double x)
return value; return value;
} }
__inline static const double atan2 (double y, double x) __inline static const double
atan2 (double y, double x)
{ {
double pi, pi_over_2; double pi, pi_over_2;
...@@ -164,7 +175,8 @@ __inline static const double atan2 (double y, double x) ...@@ -164,7 +175,8 @@ __inline static const double atan2 (double y, double x)
} }
} }
__inline static const double sinh (double x) __inline static const double
sinh (double x)
{ {
double value; double value;
...@@ -174,7 +186,8 @@ __inline static const double sinh (double x) ...@@ -174,7 +186,8 @@ __inline static const double sinh (double x)
return value; return value;
} }
__inline static const double cosh (double x) __inline static const double
cosh (double x)
{ {
double value; double value;
...@@ -184,7 +197,8 @@ __inline static const double cosh (double x) ...@@ -184,7 +197,8 @@ __inline static const double cosh (double x)
return value; return value;
} }
__inline static const double tanh (double x) __inline static const double
tanh (double x)
{ {
double value; double value;
...@@ -194,7 +208,8 @@ __inline static const double tanh (double x) ...@@ -194,7 +208,8 @@ __inline static const double tanh (double x)
return value; return value;
} }
__inline static const double atanh (double x) __inline static const double
atanh (double x)
{ {
double value; double value;
...@@ -204,7 +219,8 @@ __inline static const double atanh (double x) ...@@ -204,7 +219,8 @@ __inline static const double atanh (double x)
return value; return value;
} }
__inline static const double exp (double x) __inline static const double
exp (double x)
{ {
double value; double value;
...@@ -214,7 +230,8 @@ __inline static const double exp (double x) ...@@ -214,7 +230,8 @@ __inline static const double exp (double x)
return value; return value;
} }
__inline static const double expm1 (double x) __inline static const double
expm1 (double x)
{ {
double value; double value;
...@@ -224,7 +241,8 @@ __inline static const double expm1 (double x) ...@@ -224,7 +241,8 @@ __inline static const double expm1 (double x)
return value; return value;
} }
__inline static const double log (double x) __inline static const double
log (double x)
{ {
double value; double value;
...@@ -234,7 +252,8 @@ __inline static const double log (double x) ...@@ -234,7 +252,8 @@ __inline static const double log (double x)
return value; return value;
} }
__inline static const double log1p (double x) __inline static const double
log1p (double x)
{ {
double value; double value;
...@@ -244,7 +263,8 @@ __inline static const double log1p (double x) ...@@ -244,7 +263,8 @@ __inline static const double log1p (double x)
return value; return value;
} }
__inline static const double log10 (double x) __inline static const double
log10 (double x)
{ {
double value; double value;
...@@ -254,7 +274,8 @@ __inline static const double log10 (double x) ...@@ -254,7 +274,8 @@ __inline static const double log10 (double x)
return value; return value;
} }
__inline static const double sqrt (double x) __inline static const double
sqrt (double x)
{ {
double value; double value;
...@@ -264,12 +285,14 @@ __inline static const double sqrt (double x) ...@@ -264,12 +285,14 @@ __inline static const double sqrt (double x)
return value; return value;
} }
__inline static const double hypot (const double x, const double y) __inline static const double
hypot (const double x, const double y)
{ {
return sqrt (x*x + y*y); return sqrt (x*x + y*y);
} }
__inline static const double pow (const double x, const double y) __inline static const double
pow (const double x, const double y)
{ {
if (x > 0) if (x > 0)
return exp (y * log (x)); return exp (y * log (x));
...@@ -317,7 +340,8 @@ __inline static const double pow (const double x, const double y) ...@@ -317,7 +340,8 @@ __inline static const double pow (const double x, const double y)
} }
} }
__inline static const double fabs (double x) __inline static const double
fabs (double x)
{ {
double value; double value;
...@@ -327,71 +351,75 @@ __inline static const double fabs (double x) ...@@ -327,71 +351,75 @@ __inline static const double fabs (double x)
return value; return value;
} }
__inline static const double ceil (double x) __inline static const double
ceil (double x)
{ {
int rounding_mode, round_up; int rounding_mode, round_up;
double value; double value;
__asm volatile ("fmove%.l fpcr,%0" __asm volatile ("fmove%.l %!,%0"
: "=dm" (rounding_mode) : "=dm" (rounding_mode)
: /* no inputs */ ); : /* no inputs */ );
round_up = rounding_mode | 0x30; round_up = rounding_mode | 0x30;
__asm volatile ("fmove%.l %0,fpcr" __asm volatile ("fmove%.l %0,%!"
: /* no outputs */ : /* no outputs */
: "dmi" (round_up)); : "dmi" (round_up));
__asm volatile ("fint%.x %1,%0" __asm volatile ("fint%.x %1,%0"
: "=f" (value) : "=f" (value)
: "f" (x)); : "f" (x));
__asm volatile ("fmove%.l %0,fpcr" __asm volatile ("fmove%.l %0,%!"
: /* no outputs */ : /* no outputs */
: "dmi" (rounding_mode)); : "dmi" (rounding_mode));
return value; return value;
} }
__inline static const double floor (double x) __inline static const double
floor (double x)
{ {
int rounding_mode, round_down; int rounding_mode, round_down;
double value; double value;
__asm volatile ("fmove%.l fpcr,%0" __asm volatile ("fmove%.l %!,%0"
: "=dm" (rounding_mode) : "=dm" (rounding_mode)
: /* no inputs */ ); : /* no inputs */ );
round_down = (rounding_mode & ~0x10) round_down = (rounding_mode & ~0x10)
| 0x20; | 0x20;
__asm volatile ("fmove%.l %0,fpcr" __asm volatile ("fmove%.l %0,%!"
: /* no outputs */ : /* no outputs */
: "dmi" (round_down)); : "dmi" (round_down));
__asm volatile ("fint%.x %1,%0" __asm volatile ("fint%.x %1,%0"
: "=f" (value) : "=f" (value)
: "f" (x)); : "f" (x));
__asm volatile ("fmove%.l %0,fpcr" __asm volatile ("fmove%.l %0,%!"
: /* no outputs */ : /* no outputs */
: "dmi" (rounding_mode)); : "dmi" (rounding_mode));
return value; return value;
} }
__inline static const double rint (double x) __inline static const double
rint (double x)
{ {
int rounding_mode, round_nearest; int rounding_mode, round_nearest;
double value; double value;
__asm volatile ("fmove%.l fpcr,%0" __asm volatile ("fmove%.l %!,%0"
: "=dm" (rounding_mode) : "=dm" (rounding_mode)
: /* no inputs */ ); : /* no inputs */ );
round_nearest = rounding_mode & ~0x30; round_nearest = rounding_mode & ~0x30;
__asm volatile ("fmove%.l %0,fpcr" __asm volatile ("fmove%.l %0,%!"
: /* no outputs */ : /* no outputs */
: "dmi" (round_nearest)); : "dmi" (round_nearest));
__asm volatile ("fint%.x %1,%0" __asm volatile ("fint%.x %1,%0"
: "=f" (value) : "=f" (value)
: "f" (x)); : "f" (x));
__asm volatile ("fmove%.l %0,fpcr" __asm volatile ("fmove%.l %0,%!"
: /* no outputs */ : /* no outputs */
: "dmi" (rounding_mode)); : "dmi" (rounding_mode));
return value; return value;
} }
__inline static const double fmod (double x, double y) __inline static const double
fmod (double x, double y)
{ {
double value; double value;
...@@ -402,7 +430,8 @@ __inline static const double fmod (double x, double y) ...@@ -402,7 +430,8 @@ __inline static const double fmod (double x, double y)
return value; return value;
} }
__inline static const double drem (double x, double y) __inline static const double
drem (double x, double y)
{ {
double value; double value;
...@@ -413,7 +442,8 @@ __inline static const double drem (double x, double y) ...@@ -413,7 +442,8 @@ __inline static const double drem (double x, double y)
return value; return value;
} }
__inline static const double scalb (double x, int n) __inline static const double
scalb (double x, int n)
{ {
double value; double value;
...@@ -424,7 +454,8 @@ __inline static const double scalb (double x, int n) ...@@ -424,7 +454,8 @@ __inline static const double scalb (double x, int n)
return value; return value;
} }
__inline static double logb (double x) __inline static double
logb (double x)
{ {
double exponent; double exponent;
...@@ -434,7 +465,8 @@ __inline static double logb (double x) ...@@ -434,7 +465,8 @@ __inline static double logb (double x)
return exponent; return exponent;
} }
__inline static const double ldexp (double x, int n) __inline static const double
ldexp (double x, int n)
{ {
double value; double value;
...@@ -445,7 +477,8 @@ __inline static const double ldexp (double x, int n) ...@@ -445,7 +477,8 @@ __inline static const double ldexp (double x, int n)
return value; return value;
} }
__inline static double frexp (double x, int *exp) __inline static double
frexp (double x, int *exp)
{ {
double float_exponent; double float_exponent;
int int_exponent; int int_exponent;
...@@ -469,7 +502,8 @@ __inline static double frexp (double x, int *exp) ...@@ -469,7 +502,8 @@ __inline static double frexp (double x, int *exp)
return mantissa; return mantissa;
} }
__inline static double modf (double x, double *ip) __inline static double
modf (double x, double *ip)
{ {
double temp; double temp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment