about summary refs log tree commit diff
path: root/sysdeps/libm-i387
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-i387')
-rw-r--r--sysdeps/libm-i387/e_acosl.S21
-rw-r--r--sysdeps/libm-i387/e_exp.S17
-rw-r--r--sysdeps/libm-i387/s_ceil.S10
-rw-r--r--sysdeps/libm-i387/s_ceilf.S10
-rw-r--r--sysdeps/libm-i387/s_ceill.S30
-rw-r--r--sysdeps/libm-i387/s_copysignl.S20
-rw-r--r--sysdeps/libm-i387/s_finitel.S19
-rw-r--r--sysdeps/libm-i387/s_floor.S10
-rw-r--r--sysdeps/libm-i387/s_floorf.S10
-rw-r--r--sysdeps/libm-i387/s_floorl.S30
-rw-r--r--sysdeps/libm-i387/s_isinfl.c36
-rw-r--r--sysdeps/libm-i387/s_isnanl.c46
-rw-r--r--sysdeps/libm-i387/s_nextafterl.c102
-rw-r--r--sysdeps/libm-i387/s_rintl.S15
-rw-r--r--sysdeps/libm-i387/s_significandl.S16
15 files changed, 365 insertions, 27 deletions
diff --git a/sysdeps/libm-i387/e_acosl.S b/sysdeps/libm-i387/e_acosl.S
new file mode 100644
index 0000000000..3779fa7861
--- /dev/null
+++ b/sysdeps/libm-i387/e_acosl.S
@@ -0,0 +1,21 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ *
+ * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
+ */
+
+#include <machine/asm.h>
+
+
+/* acosl = atanl (sqrtl(1 - x^2) / x) */
+ENTRY(__ieee754_acos)
+	fldt	4(%esp)			/* x */
+	fst	%st(1)
+	fmul	%st(0)			/* x^2 */
+	fld1
+	fsubp				/* 1 - x^2 */
+	fsqrt				/* sqrtl (1 - x^2) */
+	fxch	%st(1)
+	fpatan
+	ret
diff --git a/sysdeps/libm-i387/e_exp.S b/sysdeps/libm-i387/e_exp.S
index 3ed039bc87..144748e820 100644
--- a/sysdeps/libm-i387/e_exp.S
+++ b/sysdeps/libm-i387/e_exp.S
@@ -10,12 +10,15 @@ RCSID("$NetBSD: e_exp.S,v 1.4 1995/05/08 23:47:04 jtc Exp $")
 /* e^x = 2^(x * log2(e)) */
 ENTRY(__ieee754_exp)
 	fldl	4(%esp)
-	fxam
+/* I added the following ugly construct because exp(+-Inf) resulted
+   in NaN.  The ugliness results from the bright minds at Intel.
+   -- drepper@cygnus.com.  */
+	fxam				/* Is NaN or +-Inf?  */
 	fstsw	%ax
 	sahf
-	jnc	.LnoInf
-	jp	.LisInf
-.LnoInf:
+	jnc	.LnoInfNaN		/* No, jump.   */
+	jp	.LisInf			/* Is +-Inf, jump.  */
+.LnoInfNaN:
 	fldl2e
 	fmulp				/* x * log2(e) */
 	fstl	%st(1)
@@ -29,7 +32,7 @@ ENTRY(__ieee754_exp)
 	ret
 
 .LisInf:
-	andb	$2, %ah
-	jz	.LpInf
-	fldz
+	andb	$2, %ah			/* Test sign.  */
+	jz	.LpInf			/* If positive, jump.  */
+	fldz				/* Set result to 0.  */
 .LpInf:	ret
diff --git a/sysdeps/libm-i387/s_ceil.S b/sysdeps/libm-i387/s_ceil.S
index 2fd813dcd7..eabe662a6c 100644
--- a/sysdeps/libm-i387/s_ceil.S
+++ b/sysdeps/libm-i387/s_ceil.S
@@ -12,17 +12,17 @@ ENTRY(__ceil)
 	movl	%esp,%ebp
 	subl	$8,%esp
 
-	fstcw	-12(%ebp)		/* store fpu control word */
-	movw	-12(%ebp),%dx
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
 	orw	$0x0800,%dx		/* round towards +oo */
 	andw	$0xfbff,%dx
-	movw	%dx,-16(%ebp)
-	fldcw	-16(%ebp)		/* load modfied control word */
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
 
 	fldl	8(%ebp);		/* round */
 	frndint
 
-	fldcw	-12(%ebp)		/* restore original control word */
+	fldcw	-4(%ebp)		/* restore original control word */
 
 	leave
 	ret
diff --git a/sysdeps/libm-i387/s_ceilf.S b/sysdeps/libm-i387/s_ceilf.S
index 6458b45e8f..c2163abef1 100644
--- a/sysdeps/libm-i387/s_ceilf.S
+++ b/sysdeps/libm-i387/s_ceilf.S
@@ -12,17 +12,17 @@ ENTRY(__ceilf)
 	movl	%esp,%ebp
 	subl	$8,%esp
 
-	fstcw	-12(%ebp)		/* store fpu control word */
-	movw	-12(%ebp),%dx
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
 	orw	$0x0800,%dx		/* round towards +oo */
 	andw	$0xfbff,%dx
-	movw	%dx,-16(%ebp)
-	fldcw	-16(%ebp)		/* load modfied control word */
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
 
 	flds	8(%ebp);		/* round */
 	frndint
 
-	fldcw	-12(%ebp)		/* restore original control word */
+	fldcw	-4(%ebp)		/* restore original control word */
 
 	leave
 	ret
diff --git a/sysdeps/libm-i387/s_ceill.S b/sysdeps/libm-i387/s_ceill.S
new file mode 100644
index 0000000000..fd7bd38752
--- /dev/null
+++ b/sysdeps/libm-i387/s_ceill.S
@@ -0,0 +1,30 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+ENTRY(__ceill)
+	pushl	%ebp
+	movl	%esp,%ebp
+	subl	$8,%esp
+
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
+	orw	$0x0800,%dx		/* round towards +oo */
+	andw	$0xfbff,%dx
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
+
+	fldt	8(%ebp);		/* round */
+	frndint
+
+	fldcw	-4(%ebp)		/* restore original control word */
+
+	leave
+	ret
+weak_alias (__ceill, ceill)
diff --git a/sysdeps/libm-i387/s_copysignl.S b/sysdeps/libm-i387/s_copysignl.S
new file mode 100644
index 0000000000..f65f6842ea
--- /dev/null
+++ b/sysdeps/libm-i387/s_copysignl.S
@@ -0,0 +1,20 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+ENTRY(__copysignl)
+	movl	24(%esp),%edx
+	movl	12(%esp),%eax
+	andl	$0x8000,%edx
+	andl	$0x7fff,%eax
+	orl	%edx,%eax
+	movl	%eax,12(%esp)
+	fldl	4(%esp)
+	ret
+weak_alias (__copysignl, copysignl)
diff --git a/sysdeps/libm-i387/s_finitel.S b/sysdeps/libm-i387/s_finitel.S
new file mode 100644
index 0000000000..d163965c0d
--- /dev/null
+++ b/sysdeps/libm-i387/s_finitel.S
@@ -0,0 +1,19 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ *
+ * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+ENTRY(__finitel)
+	movl	12(%esp),%eax
+	andl	$0x7fff, %eax
+	cmpl	$0x7fff, %eax
+	setne	%al
+	andl	$0x000000ff, %eax
+	ret
+weak_alias (__finitel, finitel)
diff --git a/sysdeps/libm-i387/s_floor.S b/sysdeps/libm-i387/s_floor.S
index 33d5dbcc70..66e688f7f7 100644
--- a/sysdeps/libm-i387/s_floor.S
+++ b/sysdeps/libm-i387/s_floor.S
@@ -12,17 +12,17 @@ ENTRY(__floor)
 	movl	%esp,%ebp
 	subl	$8,%esp
 
-	fstcw	-12(%ebp)		/* store fpu control word */
-	movw	-12(%ebp),%dx
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
 	orw	$0x0400,%dx		/* round towards -oo */
 	andw	$0xf7ff,%dx
-	movw	%dx,-16(%ebp)
-	fldcw	-16(%ebp)		/* load modfied control word */
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
 
 	fldl	8(%ebp);		/* round */
 	frndint
 
-	fldcw	-12(%ebp)		/* restore original control word */
+	fldcw	-4(%ebp)		/* restore original control word */
 
 	leave
 	ret
diff --git a/sysdeps/libm-i387/s_floorf.S b/sysdeps/libm-i387/s_floorf.S
index dd290fa818..4b10f74e4f 100644
--- a/sysdeps/libm-i387/s_floorf.S
+++ b/sysdeps/libm-i387/s_floorf.S
@@ -12,17 +12,17 @@ ENTRY(__floorf)
 	movl	%esp,%ebp
 	subl	$8,%esp
 
-	fstcw	-12(%ebp)		/* store fpu control word */
-	movw	-12(%ebp),%dx
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
 	orw	$0x0400,%dx		/* round towards -oo */
 	andw	$0xf7ff,%dx
-	movw	%dx,-16(%ebp)
-	fldcw	-16(%ebp)		/* load modfied control word */
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
 
 	flds	8(%ebp);		/* round */
 	frndint
 
-	fldcw	-12(%ebp)		/* restore original control word */
+	fldcw	-4(%ebp)		/* restore original control word */
 
 	leave
 	ret
diff --git a/sysdeps/libm-i387/s_floorl.S b/sysdeps/libm-i387/s_floorl.S
new file mode 100644
index 0000000000..af52ffcacf
--- /dev/null
+++ b/sysdeps/libm-i387/s_floorl.S
@@ -0,0 +1,30 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+ENTRY(__floorl)
+	pushl	%ebp
+	movl	%esp,%ebp
+	subl	$8,%esp
+
+	fstcw	-4(%ebp)		/* store fpu control word */
+	movw	-4(%ebp),%dx
+	orw	$0x0400,%dx		/* round towards -oo */
+	andw	$0xf7ff,%dx
+	movw	%dx,-8(%ebp)
+	fldcw	-8(%ebp)		/* load modfied control word */
+
+	fldt	8(%ebp)			/* round */
+	frndint
+
+	fldcw	-4(%ebp)		/* restore original control word */
+
+	leave
+	ret
+weak_alias (__floorl, floorl)
diff --git a/sysdeps/libm-i387/s_isinfl.c b/sysdeps/libm-i387/s_isinfl.c
new file mode 100644
index 0000000000..3ee53d5ecc
--- /dev/null
+++ b/sysdeps/libm-i387/s_isinfl.c
@@ -0,0 +1,36 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Change for long double by Ulrich Drepper <drepper@cygnus.com>.
+ * Intel i387 specific version.
+ * Public domain.
+ */
+
+#if defined(LIBM_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: $";
+#endif
+
+/*
+ * isinfl(x) returns 1 is x is inf, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef __STDC__
+	int __isinfl(long double x)
+#else
+	int __isinfl(x)
+	long double x;
+#endif
+{
+	int32_t se,hx,lx;
+	GET_LDOUBLE_WORDS(se,hx,lx,x);
+	se &= 0x7fff;
+	se ^= 0x7fff;
+	/* This additional ^ 0x80000000 is necessary because in Intel's
+	   internal representation the implicit one is explicit.  */
+	se |= (hx ^ 0x80000000) | lx;
+	return (se == 0);
+}
+weak_alias (__isinfl, isinfl)
diff --git a/sysdeps/libm-i387/s_isnanl.c b/sysdeps/libm-i387/s_isnanl.c
new file mode 100644
index 0000000000..768ea2164b
--- /dev/null
+++ b/sysdeps/libm-i387/s_isnanl.c
@@ -0,0 +1,46 @@
+/* s_isnanl.c -- long double version for i387 of s_isnan.c.
+ * Conversion to long double by Ulrich Drepper,
+ * Cygnus Support, drepper@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#if defined(LIBM_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: $";
+#endif
+
+/*
+ * isnanl(x) returns 1 is x is nan, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef __STDC__
+	int __isnanl(long double x)
+#else
+	int __isnanl(x)
+	long double x;
+#endif
+{
+	int32_t se,hx,lx;
+	GET_LDOUBLE_WORDS(se,hx,lx,x);
+	se = (se & 0x7fff) << 1;
+	lx |= hx;
+	/* The additional &hx is required because Intel's extended format
+	   has the normally implicit 1 explicit present.  Sigh!  */
+	se |= (u_int32_t)((lx|(-lx))&hx)>>31;
+	se = 0xfffe - se;
+	return (int)((u_int32_t)(se))>>16;
+}
+weak_alias (__isnanl, isnanl)
diff --git a/sysdeps/libm-i387/s_nextafterl.c b/sysdeps/libm-i387/s_nextafterl.c
new file mode 100644
index 0000000000..b574430832
--- /dev/null
+++ b/sysdeps/libm-i387/s_nextafterl.c
@@ -0,0 +1,102 @@
+/* s_nextafterl.c -- long double version of s_nextafter.c.
+ * Special version for i387.
+ * Conversion to long double by Ulrich Drepper,
+ * Cygnus Support, drepper@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#if defined(LIBM_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: $";
+#endif
+
+/* IEEE functions
+ *	nextafterl(x,y)
+ *	return the next machine floating-point number of x in the
+ *	direction toward y.
+ *   Special cases:
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef __STDC__
+	long double __nextafterl(long double x, long double y)
+#else
+	long double __nextafterl(x,y)
+	long double x,y;
+#endif
+{
+	int32_t hx,hy,ix,iy;
+	u_int32_t lx,ly,esx,esy;
+
+	GET_LDOUBLE_WORDS(esx,hx,lx,x);
+	GET_LDOUBLE_WORDS(esy,hy,ly,y);
+	ix = esx&0x7fff;		/* |x| */
+	iy = esy&0x7fff;		/* |y| */
+
+	/* The additional &hx/&hy is required because Intel's extended format
+           has the normally implicit 1 explicit present.  Sigh!  */
+	if(((ix==0x7fff)&&(((hx|lx)|-(hx|lx))&hx)>>31!=0) ||   /* x is nan */
+	   ((iy==0x7fff)&&(((hy|ly)|-(hy|ly))&hy)>>31!=0))     /* y is nan */
+	   return x+y;
+	if(x==y) return x;		/* x=y, return x */
+	if((ix|hx|lx)==0) {			/* x == 0 */
+	    SET_LDOUBLE_WORDS(x,esx&0x8000,0,1);/* return +-minsubnormal */
+	    y = x*x;
+	    if(y==x) return y; else return x;	/* raise underflow flag */
+	}
+	if(esx<0x8000) {			/* x > 0 */
+	    if(ix>iy||((ix==iy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
+	      /* x > y, x -= ulp */
+		if(lx==0) {
+		    if (hx==0) esx -= 1;
+		    hx -= 1;
+		}
+		lx -= 1;
+	    } else {				/* x < y, x += ulp */
+		lx += 1;
+		if(lx==0) {
+		    hx += 1;
+		    if (hx==0)
+			esx += 1;
+		}
+	    }
+	} else {				/* x < 0 */
+	    if(esy>=0||(ix>iy||((ix==iy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){
+	      /* x < y, x -= ulp */
+		if(lx==0) {
+		    if (hx==0) esx -= 1;
+		    hx -= 1;
+		}
+		lx -= 1;
+	    } else {				/* x > y, x += ulp */
+		lx += 1;
+		if(lx==0) {
+		    hx += 1;
+		    if (hx==0) esx += 1;
+		}
+	    }
+	}
+	esy = esx&0x7fff;
+	if(esy==0x7fff) return x+x;	/* overflow  */
+	if(esy==0) {			/* underflow */
+	    y = x*x;
+	    if(y!=x) {		/* raise underflow flag */
+	        SET_LDOUBLE_WORDS(y,esx,hx,lx);
+		return y;
+	    }
+	}
+	SET_LDOUBLE_WORDS(x,esx,hx,lx);
+	return x;
+}
+weak_alias (__nextafterl, nextafterl)
diff --git a/sysdeps/libm-i387/s_rintl.S b/sysdeps/libm-i387/s_rintl.S
new file mode 100644
index 0000000000..aec09a6ec4
--- /dev/null
+++ b/sysdeps/libm-i387/s_rintl.S
@@ -0,0 +1,15 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+ENTRY(__rintl)
+	fldt	4(%esp)
+	frndint
+	ret
+weak_alias (__rintl, rintl)
diff --git a/sysdeps/libm-i387/s_significandl.S b/sysdeps/libm-i387/s_significandl.S
new file mode 100644
index 0000000000..e512f54fb2
--- /dev/null
+++ b/sysdeps/libm-i387/s_significandl.S
@@ -0,0 +1,16 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+ENTRY(__significandl)
+	fldt	4(%esp)
+	fxtract
+	fstpt	%st(1)
+	ret
+weak_alias (__significandl, significandl)