summaryrefslogtreecommitdiff
path: root/lib/libm/noieee_src
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2008-12-09 20:00:36 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2008-12-09 20:00:36 +0000
commit009c7af638fd14d259805ee9734b870b755af8a4 (patch)
tree6dff090904884ebfbb145505ec8c02b7e2b8613c /lib/libm/noieee_src
parent9e5337fc957e6c7535daf2a109184402a542f1ec (diff)
- 80-bit and quad precision trigonometric and other most
important functions: acosl, asinl, atanl, atan2l, cosl, sinl, tanl, exp2l, frexpl, ilogbl, ldexpl, logbl, scalbnl, fabsl, hypotl, powl, sqrtl, rintl, copysignl, nanl, fdiml, fmaxl, fminl. mostly taken from freebsd, needed alot of changes to adapt. note, these are all c versions; and are quite slow when architectures have, e.g. sqrt. assembly versions will be added afterwards - make them .weak/__weak_alias to the double precision versions on other archs - no need to have two finites. finite() and finitef() are non-standard 3BSD obsolete versions of isfinite. remove from libm. make them weak_alias in libc to __isfinite and __isfinitef instead. similarly make 3BSD obsolete versions of isinf, isinff, isnan, isnanf weak_aliases to C99's __isinf, __isinff, __isnan, __isnanf - remove unused infinity.c. the c library has infinities for each supported platform - use STRICT_ASSIGN cast hack for _kernel_rem_pio2, so that the double version has a chance of working on i386 with extra precision - avoid storing multiple copies of the pi/2 array, since it won't vary - bump major due to removed finite/finitef. although they will be in libc, which anything is linked to, minor bump might be enough ok millert@. tested by sthen@, jsg@, ajacoutot@, kili@, naddy@
Diffstat (limited to 'lib/libm/noieee_src')
-rw-r--r--lib/libm/noieee_src/n_asincos.c14
-rw-r--r--lib/libm/noieee_src/n_atan.c9
-rw-r--r--lib/libm/noieee_src/n_atan2.c10
-rw-r--r--lib/libm/noieee_src/n_fdim.c5
-rw-r--r--lib/libm/noieee_src/n_floor.c10
-rw-r--r--lib/libm/noieee_src/n_fmax.c5
-rw-r--r--lib/libm/noieee_src/n_fmin.c7
-rw-r--r--lib/libm/noieee_src/n_sincos.c14
-rw-r--r--lib/libm/noieee_src/n_support.c32
-rw-r--r--lib/libm/noieee_src/n_tan.c10
10 files changed, 86 insertions, 30 deletions
diff --git a/lib/libm/noieee_src/n_asincos.c b/lib/libm/noieee_src/n_asincos.c
index 40cc86bcabb..6b720021291 100644
--- a/lib/libm/noieee_src/n_asincos.c
+++ b/lib/libm/noieee_src/n_asincos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_asincos.c,v 1.7 2008/06/21 08:26:19 martynas Exp $ */
+/* $OpenBSD: n_asincos.c,v 1.8 2008/12/09 20:00:35 martynas Exp $ */
/* $NetBSD: n_asincos.c,v 1.1 1995/10/10 23:36:34 ragge Exp $ */
/*
* Copyright (c) 1985, 1993
@@ -85,7 +85,9 @@ static char sccsid[] = "@(#)asincos.c 8.1 (Berkeley) 6/4/93";
* 1.99 ulps.
*/
-#include "math.h"
+#include <machine/cdefs.h>
+#include <math.h>
+
#include "mathimpl.h"
double
@@ -104,6 +106,10 @@ asin(double x)
}
+#ifdef __weak_alias
+__weak_alias(asinl, asin);
+#endif /* __weak_alias */
+
/* ACOS(X)
* RETURNS ARC COS OF X
* DOUBLE PRECISION (IEEE DOUBLE 53 bits, VAX D FORMAT 56 bits)
@@ -170,3 +176,7 @@ acos(double x)
t=atan2(one,0.0); /* t = PI/2 */
return(t+t);
}
+
+#ifdef __weak_alias
+__weak_alias(acosl, acos);
+#endif /* __weak_alias */
diff --git a/lib/libm/noieee_src/n_atan.c b/lib/libm/noieee_src/n_atan.c
index f2dd0a684bf..9a0df75b1d2 100644
--- a/lib/libm/noieee_src/n_atan.c
+++ b/lib/libm/noieee_src/n_atan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_atan.c,v 1.5 2008/06/21 08:26:19 martynas Exp $ */
+/* $OpenBSD: n_atan.c,v 1.6 2008/12/09 20:00:35 martynas Exp $ */
/* $NetBSD: n_atan.c,v 1.1 1995/10/10 23:36:36 ragge Exp $ */
/*
* Copyright (c) 1985, 1993
@@ -77,7 +77,8 @@ static char sccsid[] = "@(#)atan.c 8.1 (Berkeley) 6/4/93";
* 0.85 ulps.
*/
-#include "math.h"
+#include <machine/cdefs.h>
+#include <math.h>
double
atan(double x)
@@ -85,3 +86,7 @@ atan(double x)
double one=1.0;
return(atan2(x,one));
}
+
+#ifdef __weak_alias
+__weak_alias(atanl, atan);
+#endif /* __weak_alias */
diff --git a/lib/libm/noieee_src/n_atan2.c b/lib/libm/noieee_src/n_atan2.c
index 873946aabf2..919e2c662da 100644
--- a/lib/libm/noieee_src/n_atan2.c
+++ b/lib/libm/noieee_src/n_atan2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_atan2.c,v 1.9 2008/07/17 15:36:28 martynas Exp $ */
+/* $OpenBSD: n_atan2.c,v 1.10 2008/12/09 20:00:35 martynas Exp $ */
/* $NetBSD: n_atan2.c,v 1.1 1995/10/10 23:36:37 ragge Exp $ */
/*
* Copyright (c) 1985, 1993
@@ -107,7 +107,9 @@ static char sccsid[] = "@(#)atan2.c 8.1 (Berkeley) 6/4/93";
* shown.
*/
-#include "math.h"
+#include <machine/cdefs.h>
+#include <math.h>
+
#include "mathimpl.h"
vc(athfhi, 4.6364760900080611433E-1 ,6338,3fed,da7b,2b0d, -1, .ED63382B0DDA7B)
@@ -281,3 +283,7 @@ begin:
return(copysign((signx>zero)?z:PI-z,signy));
}
+
+#ifdef __weak_alias
+__weak_alias(atan2l, atan2);
+#endif /* __weak_alias */
diff --git a/lib/libm/noieee_src/n_fdim.c b/lib/libm/noieee_src/n_fdim.c
index 09644101820..409816672d0 100644
--- a/lib/libm/noieee_src/n_fdim.c
+++ b/lib/libm/noieee_src/n_fdim.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_fdim.c,v 1.1 2008/09/11 19:19:34 martynas Exp $ */
+/* $OpenBSD: n_fdim.c,v 1.2 2008/12/09 20:00:35 martynas Exp $ */
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
@@ -25,6 +25,7 @@
* SUCH DAMAGE.
*/
+#include <machine/cdefs.h>
#include <math.h>
#define DECL(type, fn) \
@@ -41,4 +42,4 @@ fn(type x, type y) \
DECL(double, fdim)
DECL(float, fdimf)
-DECL(long double, fdiml)
+__weak_alias(fdiml, fdim);
diff --git a/lib/libm/noieee_src/n_floor.c b/lib/libm/noieee_src/n_floor.c
index 3e45d05e159..7a9f3d66399 100644
--- a/lib/libm/noieee_src/n_floor.c
+++ b/lib/libm/noieee_src/n_floor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_floor.c,v 1.8 2008/06/25 17:49:31 martynas Exp $ */
+/* $OpenBSD: n_floor.c,v 1.9 2008/12/09 20:00:35 martynas Exp $ */
/* $NetBSD: n_floor.c,v 1.1 1995/10/10 23:36:48 ragge Exp $ */
/*
* Copyright (c) 1985, 1993
@@ -33,7 +33,9 @@
static char sccsid[] = "@(#)floor.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
-#include "math.h"
+#include <machine/cdefs.h>
+#include <math.h>
+
#include "mathimpl.h"
vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */
@@ -121,3 +123,7 @@ rint(double x)
t = x + s; /* x+s rounded to integer */
return (t - s);
}
+
+#ifdef __weak_alias
+__weak_alias(rintl, rint);
+#endif /* __weak_alias */
diff --git a/lib/libm/noieee_src/n_fmax.c b/lib/libm/noieee_src/n_fmax.c
index 057e09faa18..f1f2c28d908 100644
--- a/lib/libm/noieee_src/n_fmax.c
+++ b/lib/libm/noieee_src/n_fmax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_fmax.c,v 1.1 2008/09/11 19:19:34 martynas Exp $ */
+/* $OpenBSD: n_fmax.c,v 1.2 2008/12/09 20:00:35 martynas Exp $ */
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
@@ -25,6 +25,7 @@
* SUCH DAMAGE.
*/
+#include <machine/cdefs.h>
#include <math.h>
double
@@ -45,3 +46,5 @@ fmax(double x, double y)
return (x > y ? x : y);
}
+
+__weak_alias(fmaxl, fmax);
diff --git a/lib/libm/noieee_src/n_fmin.c b/lib/libm/noieee_src/n_fmin.c
index 3ecaf8d1da4..7929997da0b 100644
--- a/lib/libm/noieee_src/n_fmin.c
+++ b/lib/libm/noieee_src/n_fmin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_fmin.c,v 1.1 2008/09/11 19:19:34 martynas Exp $ */
+/* $OpenBSD: n_fmin.c,v 1.2 2008/12/09 20:00:35 martynas Exp $ */
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
@@ -25,6 +25,7 @@
* SUCH DAMAGE.
*/
+#include <machine/cdefs.h>
#include <math.h>
double
@@ -45,3 +46,7 @@ fmin(double x, double y)
return (x < y ? x : y);
}
+
+#ifdef __weak_alias
+__weak_alias(fminl, fmin);
+#endif /* __weak_alias */
diff --git a/lib/libm/noieee_src/n_sincos.c b/lib/libm/noieee_src/n_sincos.c
index 44627cd2bc5..2da035851ca 100644
--- a/lib/libm/noieee_src/n_sincos.c
+++ b/lib/libm/noieee_src/n_sincos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_sincos.c,v 1.6 2008/06/25 17:49:31 martynas Exp $ */
+/* $OpenBSD: n_sincos.c,v 1.7 2008/12/09 20:00:35 martynas Exp $ */
/* $NetBSD: n_sincos.c,v 1.1 1995/10/10 23:37:04 ragge Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -33,7 +33,9 @@
static char sccsid[] = "@(#)sincos.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
-#include "math.h"
+#include <machine/cdefs.h>
+#include <math.h>
+
#include "mathimpl.h"
double
@@ -65,6 +67,10 @@ sin(double x)
return x+x*sin__S(x*x);
}
+#ifdef __weak_alias
+__weak_alias(sinl, sin);
+#endif /* __weak_alias */
+
double
cos(double x)
{
@@ -94,3 +100,7 @@ cos(double x)
a = (z >= thresh ? half-((z-half)-c) : one-(z-c));
return copysign(a,s);
}
+
+#ifdef __weak_alias
+__weak_alias(cosl, cos);
+#endif /* __weak_alias */
diff --git a/lib/libm/noieee_src/n_support.c b/lib/libm/noieee_src/n_support.c
index 63c6706d588..36123fc055e 100644
--- a/lib/libm/noieee_src/n_support.c
+++ b/lib/libm/noieee_src/n_support.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_support.c,v 1.15 2008/07/24 09:40:16 martynas Exp $ */
+/* $OpenBSD: n_support.c,v 1.16 2008/12/09 20:00:35 martynas Exp $ */
/* $NetBSD: n_support.c,v 1.1 1995/10/10 23:37:06 ragge Exp $ */
/*
* Copyright (c) 1985, 1993
@@ -62,16 +62,15 @@ static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 6/4/93";
* returns the unbiased exponent of x, a signed integer in
* double precision, except that logb(0) is -INF, logb(INF)
* is +INF, and logb(NAN) is that NAN.
- * (d) finite(x)
- * returns the value TRUE if -INF < x < +INF and returns
- * FALSE otherwise.
*
*
* CODED IN C BY K.C. NG, 11/25/84;
* REVISED BY K.C. NG on 1/22/85, 2/13/85, 3/24/85.
*/
-#include "math.h"
+#include <machine/cdefs.h>
+#include <math.h>
+
#include "mathimpl.h"
#if defined(__vax__) /* VAX D format */
@@ -122,6 +121,9 @@ scalbn(double x, int N)
return(x);
}
+#ifdef __weak_alias
+__weak_alias(scalbnl, scalbn);
+#endif /* __weak_alias */
double
copysign(double x, double y)
@@ -137,6 +139,10 @@ copysign(double x, double y)
return(x);
}
+#ifdef __weak_alias
+__weak_alias(copysignl, copysign);
+#endif /* __weak_alias */
+
double
logb(double x)
{
@@ -160,15 +166,9 @@ logb(double x)
#endif /* defined(__vax__) */
}
-int
-finite(double x)
-{
-#if defined(__vax__)
- return(1);
-#else /* defined(__vax__) */
- return( (*((short *) &x ) & mexp ) != mexp );
-#endif /* defined(__vax__) */
-}
+#ifdef __weak_alias
+__weak_alias(logbl, logb);
+#endif /* __weak_alias */
double
remainder(double x, double p)
@@ -319,6 +319,10 @@ sqrt(double x)
end: return(scalbn(q,n));
}
+#ifdef __weak_alias
+__weak_alias(sqrtl, sqrt);
+#endif /* __weak_alias */
+
#if 0
/* REMAINDER(X,Y)
* RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE)
diff --git a/lib/libm/noieee_src/n_tan.c b/lib/libm/noieee_src/n_tan.c
index bd3d97b96ef..e344a84b013 100644
--- a/lib/libm/noieee_src/n_tan.c
+++ b/lib/libm/noieee_src/n_tan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: n_tan.c,v 1.6 2008/06/25 17:49:31 martynas Exp $ */
+/* $OpenBSD: n_tan.c,v 1.7 2008/12/09 20:00:35 martynas Exp $ */
/* $NetBSD: n_tan.c,v 1.1 1995/10/10 23:37:07 ragge Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -33,7 +33,9 @@
static char sccsid[] = "@(#)tan.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
-#include "math.h"
+#include <machine/cdefs.h>
+#include <math.h>
+
#include "mathimpl.h"
double
@@ -67,3 +69,7 @@ tan(double x)
else
return c/(x+x*ss); /* ... cos/sin */
}
+
+#ifdef __weak_alias
+__weak_alias(tanl, tan);
+#endif /* __weak_alias */