summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2008-06-12 15:58:00 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2008-06-12 15:58:00 +0000
commit1e72660127a56fdf02b5b43293d426076aff795f (patch)
treeb848a12220058f38f7dba2fd1b67cf6517b74714 /lib
parentbccef4d20904e9126be50edde929a5d97eb7fa9f (diff)
- no need for ifdef dance (21), we have isnan, finite for vax
- TEST_FMOD doesn't belong here, remove - remove ifdef _ANSI_SOURCE and assume it's default ok millert@
Diffstat (limited to 'lib')
-rw-r--r--lib/libm/noieee_src/n_acosh.c5
-rw-r--r--lib/libm/noieee_src/n_asincos.c14
-rw-r--r--lib/libm/noieee_src/n_asinh.c6
-rw-r--r--lib/libm/noieee_src/n_atan2.c7
-rw-r--r--lib/libm/noieee_src/n_cabs.c5
-rw-r--r--lib/libm/noieee_src/n_cosh.c6
-rw-r--r--lib/libm/noieee_src/n_exp.c14
-rw-r--r--lib/libm/noieee_src/n_expm1.c5
-rw-r--r--lib/libm/noieee_src/n_floor.c22
-rw-r--r--lib/libm/noieee_src/n_fmod.c74
-rw-r--r--lib/libm/noieee_src/n_log1p.c5
-rw-r--r--lib/libm/noieee_src/n_pow.c4
-rw-r--r--lib/libm/noieee_src/n_sinh.c7
-rw-r--r--lib/libm/noieee_src/n_tanh.c5
14 files changed, 48 insertions, 131 deletions
diff --git a/lib/libm/noieee_src/n_acosh.c b/lib/libm/noieee_src/n_acosh.c
index 9bd3d99cbec..975bb690da4 100644
--- a/lib/libm/noieee_src/n_acosh.c
+++ b/lib/libm/noieee_src/n_acosh.c
@@ -88,9 +88,8 @@ acosh(x)
{
double t,big=1.E20; /* big+1==big */
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
/* return log1p(x) + log(2) if x is large */
if(x>big) {t=log1p(x)+ln2lo; return(t+ln2hi);}
diff --git a/lib/libm/noieee_src/n_asincos.c b/lib/libm/noieee_src/n_asincos.c
index abbc6ed2d84..365ac4e5a90 100644
--- a/lib/libm/noieee_src/n_asincos.c
+++ b/lib/libm/noieee_src/n_asincos.c
@@ -91,9 +91,10 @@ asin(x)
double x;
{
double s,t,copysign(),atan2(),sqrt(),one=1.0;
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+
+ if (isnan(x))
+ return (x);
+
s=copysign(x,one);
if(s <= 0.5)
return(atan2(x,sqrt(one-x*x)));
@@ -159,9 +160,10 @@ acos(x)
double x;
{
double t,copysign(),atan2(),sqrt(),one=1.0;
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x);
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+
+ if (isnan(x))
+ return (x);
+
if( x != -1.0)
t=atan2(sqrt((one-x)/(one+x)),one);
else
diff --git a/lib/libm/noieee_src/n_asinh.c b/lib/libm/noieee_src/n_asinh.c
index 1efcf5c1a7b..c11130e58c6 100644
--- a/lib/libm/noieee_src/n_asinh.c
+++ b/lib/libm/noieee_src/n_asinh.c
@@ -85,9 +85,9 @@ double x;
big =1.0E20, /* fl(1+big) == big */
one =1.0 ;
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
+
if((t=copysign(x,one))>small)
if(t<big) {
s=one/t; return(copysign(log1p(t+t/(s+sqrt(one+s*s))),x)); }
diff --git a/lib/libm/noieee_src/n_atan2.c b/lib/libm/noieee_src/n_atan2.c
index 5c11e5f986b..0c927f2c219 100644
--- a/lib/libm/noieee_src/n_atan2.c
+++ b/lib/libm/noieee_src/n_atan2.c
@@ -176,10 +176,11 @@ double y,x;
double t,z,signy,signx,hi,lo;
int k,m;
-#if !defined(__vax__)&&!defined(tahoe)
/* if x or y is NAN */
- if(x!=x) return(x); if(y!=y) return(y);
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
+ if (isnan(y))
+ return (y);
/* copy down the sign of y and x */
signy = copysign(one,y) ;
diff --git a/lib/libm/noieee_src/n_cabs.c b/lib/libm/noieee_src/n_cabs.c
index ca155810751..5cd83739531 100644
--- a/lib/libm/noieee_src/n_cabs.c
+++ b/lib/libm/noieee_src/n_cabs.c
@@ -148,9 +148,8 @@ double x, y;
return (copysign(x,one));
else if(finite(y))
return(x); /* x is NaN, y is finite */
-#if !defined(__vax__)&&!defined(tahoe)
- else if(y!=y) return(y); /* x and y is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ else if (isnan(y))
+ return (y);
else return(copysign(y,one)); /* y is INF */
}
diff --git a/lib/libm/noieee_src/n_cosh.c b/lib/libm/noieee_src/n_cosh.c
index f1faf23c538..f956213e3e3 100644
--- a/lib/libm/noieee_src/n_cosh.c
+++ b/lib/libm/noieee_src/n_cosh.c
@@ -108,9 +108,9 @@ double x;
one=1.0, small=1.0E-18; /* fl(1+small)==1 */
double t;
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
+
if((x=copysign(x,one)) <= 22)
if(x<0.3465)
if(x<small) return(one+x);
diff --git a/lib/libm/noieee_src/n_exp.c b/lib/libm/noieee_src/n_exp.c
index a51696b58d6..d374b3e80be 100644
--- a/lib/libm/noieee_src/n_exp.c
+++ b/lib/libm/noieee_src/n_exp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_exp.c,v 1.5 2008/06/11 20:53:27 martynas Exp $ */
+/* $OpenBSD: n_exp.c,v 1.6 2008/06/12 15:57:59 martynas Exp $ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -116,9 +116,9 @@ double exp(double x)
double z, hi, lo, c;
int k;
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
+
if( x <= lnhuge ) {
if( x >= lntiny ) {
@@ -160,9 +160,9 @@ double __exp__D(double x, double c)
double z, hi, lo;
int k;
-#if !defined(__vax__)&&!defined(tahoe)
- if (x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
+
if ( x <= lnhuge ) {
if ( x >= lntiny ) {
diff --git a/lib/libm/noieee_src/n_expm1.c b/lib/libm/noieee_src/n_expm1.c
index 1b5862782a0..9ac9f1cda23 100644
--- a/lib/libm/noieee_src/n_expm1.c
+++ b/lib/libm/noieee_src/n_expm1.c
@@ -114,9 +114,8 @@ double x;
static prec=53;
#endif /* defined(__vax__)||defined(tahoe) */
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
if( x <= lnhuge ) {
if( x >= -40.0 ) {
diff --git a/lib/libm/noieee_src/n_floor.c b/lib/libm/noieee_src/n_floor.c
index 563a93679d9..c9b7f34546a 100644
--- a/lib/libm/noieee_src/n_floor.c
+++ b/lib/libm/noieee_src/n_floor.c
@@ -55,11 +55,7 @@ double x;
{
volatile double y;
- if (
-#if !defined(__vax__)&&!defined(tahoe)
- x != x || /* NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
- x >= L) /* already an even integer */
+ if (isnan(x) || x >= L) /* already an even integer */
return x;
else if (x < (double)0)
return -ceil(-x);
@@ -76,11 +72,7 @@ double x;
{
volatile double y;
- if (
-#if !defined(__vax__)&&!defined(tahoe)
- x != x || /* NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
- x >= L) /* already an even integer */
+ if (isnan(x) || x >= L) /* already an even integer */
return x;
else if (x < (double)0)
return -floor(-x);
@@ -121,12 +113,12 @@ double x;
volatile double t;
const double one = 1.0;
-#if !defined(__vax__)&&!defined(tahoe)
- if (x != x) /* NaN */
+ if (isnan(x))
return (x);
-#endif /* !defined(__vax__)&&!defined(tahoe) */
- if (copysign(x,one) >= L) /* already an integer */
- return (x);
+
+ if (copysign(x, one) >= L) /* already an integer */
+ return (x);
+
s = copysign(L,x);
t = x + s; /* x+s rounded to integer */
return (t - s);
diff --git a/lib/libm/noieee_src/n_fmod.c b/lib/libm/noieee_src/n_fmod.c
index 851908355d9..b4b1c0f8860 100644
--- a/lib/libm/noieee_src/n_fmod.c
+++ b/lib/libm/noieee_src/n_fmod.c
@@ -32,6 +32,7 @@
static char sccsid[] = "@(#)fmod.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
+#include "math.h"
#include "mathimpl.h"
/* fmod.c
@@ -60,28 +61,15 @@ static char sccsid[] = "@(#)fmod.c 8.1 (Berkeley) 6/4/93";
* fmod(x,0), fmod(INF,y) are invalid operations and NaN is returned.
*
*/
-#if !defined(__vax__) && !defined(tahoe)
-extern int isnan(),finite();
-#endif /* !defined(__vax__) && !defined(tahoe) */
-extern double frexp(),ldexp(),fabs();
-#ifdef TEST_FMOD
-static double
-_fmod(x,y)
-#else /* TEST_FMOD */
double
fmod(x,y)
-#endif /* TEST_FMOD */
double x,y;
{
int ir,iy;
double r,w;
- if (y == (double)0
-#if !defined(__vax__) && !defined(tahoe) /* per "fmod" manual entry, SunOS 4.0 */
- || isnan(y) || !finite(x)
-#endif /* !defined(__vax__) && !defined(tahoe) */
- )
+ if (y == (double)0 || isnan(y) || !finite(x))
return (x*y)/(x*y);
r = fabs(x);
@@ -94,61 +82,3 @@ double x,y;
}
return x >= (double)0 ? r : -r;
}
-
-#ifdef TEST_FMOD
-extern long random();
-extern double fmod();
-
-#define NTEST 10000
-#define NCASES 3
-
-static int nfail = 0;
-
-static void
-doit(x,y)
-double x,y;
-{
- double ro = fmod(x,y),rn = _fmod(x,y);
- if (ro != rn) {
- (void)printf(" x = 0x%08.8x %08.8x (%24.16e)\n",x,x);
- (void)printf(" y = 0x%08.8x %08.8x (%24.16e)\n",y,y);
- (void)printf(" fmod = 0x%08.8x %08.8x (%24.16e)\n",ro,ro);
- (void)printf("_fmod = 0x%08.8x %08.8x (%24.16e)\n",rn,rn);
- (void)printf("\n");
- }
-}
-
-main()
-{
- register int i,cases;
- double x,y;
-
- srandom(12345);
- for (i = 0; i < NTEST; i++) {
- x = (double)random();
- y = (double)random();
- for (cases = 0; cases < NCASES; cases++) {
- switch (cases) {
- case 0:
- break;
- case 1:
- y = (double)1/y; break;
- case 2:
- x = (double)1/x; break;
- default:
- abort(); break;
- }
- doit(x,y);
- doit(x,-y);
- doit(-x,y);
- doit(-x,-y);
- }
- }
- if (nfail)
- (void)printf("Number of failures: %d (out of a total of %d)\n",
- nfail,NTEST*NCASES*4);
- else
- (void)printf("No discrepancies were found\n");
- exit(0);
-}
-#endif /* TEST_FMOD */
diff --git a/lib/libm/noieee_src/n_log1p.c b/lib/libm/noieee_src/n_log1p.c
index 451c2d57c51..c7055fc418a 100644
--- a/lib/libm/noieee_src/n_log1p.c
+++ b/lib/libm/noieee_src/n_log1p.c
@@ -116,9 +116,8 @@ double x;
double z,s,t,c;
int k;
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
if(finite(x)) {
if( x > negone ) {
diff --git a/lib/libm/noieee_src/n_pow.c b/lib/libm/noieee_src/n_pow.c
index 52d5130f8b9..2c3ff5cc848 100644
--- a/lib/libm/noieee_src/n_pow.c
+++ b/lib/libm/noieee_src/n_pow.c
@@ -164,11 +164,7 @@ double x,y;
}
/* kernel function for x >= 0 */
static double
-#ifdef _ANSI_SOURCE
pow_P(double x, double y)
-#else
-pow_P(x, y) double x, y;
-#endif
{
struct Double s, t, __log__D();
double __exp__D(), huge = 1e300, tiny = 1e-300;
diff --git a/lib/libm/noieee_src/n_sinh.c b/lib/libm/noieee_src/n_sinh.c
index 09080e4a08d..b0206dce7bc 100644
--- a/lib/libm/noieee_src/n_sinh.c
+++ b/lib/libm/noieee_src/n_sinh.c
@@ -100,9 +100,10 @@ double x;
{
static const double one=1.0, half=1.0/2.0 ;
double t, sign;
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+
+ if (isnan(x))
+ return (x);
+
sign=copysign(one,x);
x=copysign(x,one);
if(x<lnovfl)
diff --git a/lib/libm/noieee_src/n_tanh.c b/lib/libm/noieee_src/n_tanh.c
index 68264527522..bd475ae9a67 100644
--- a/lib/libm/noieee_src/n_tanh.c
+++ b/lib/libm/noieee_src/n_tanh.c
@@ -76,9 +76,8 @@ double x;
double expm1(), t, copysign(), sign;
int finite();
-#if !defined(__vax__)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(__vax__)&&!defined(tahoe) */
+ if (isnan(x))
+ return (x);
sign=copysign(one,x);
x=copysign(x,one);