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_scalb.S78
-rw-r--r--sysdeps/libm-i387/e_scalbf.S79
-rw-r--r--sysdeps/libm-i387/e_scalbl.S78
-rw-r--r--sysdeps/libm-i387/s_asinh.S11
-rw-r--r--sysdeps/libm-i387/s_asinhf.S11
-rw-r--r--sysdeps/libm-i387/s_asinhl.S11
-rw-r--r--sysdeps/libm-i387/s_ilogb.S12
-rw-r--r--sysdeps/libm-i387/s_ilogbf.S12
-rw-r--r--sysdeps/libm-i387/s_ilogbl.S13
-rw-r--r--sysdeps/libm-i387/s_llrint.S (renamed from sysdeps/libm-i387/s_rinttoll.S)6
-rw-r--r--sysdeps/libm-i387/s_lrint.S (renamed from sysdeps/libm-i387/s_rinttol.S)6
-rw-r--r--sysdeps/libm-i387/s_remquo.S7
-rw-r--r--sysdeps/libm-i387/s_remquof.S7
-rw-r--r--sysdeps/libm-i387/s_remquol.S7
14 files changed, 293 insertions, 45 deletions
diff --git a/sysdeps/libm-i387/e_scalb.S b/sysdeps/libm-i387/e_scalb.S
index 427a3b905e..790f1c1d56 100644
--- a/sysdeps/libm-i387/e_scalb.S
+++ b/sysdeps/libm-i387/e_scalb.S
@@ -1,16 +1,94 @@
 /*
  * Written by J.T. Conklin <jtc@netbsd.org>.
  * Public domain.
+ *
+ * Correct handling of y==-inf <drepper@gnu>
  */
 
 #include <machine/asm.h>
 
 RCSID("$NetBSD: e_scalb.S,v 1.4 1995/05/08 23:49:52 jtc Exp $")
 
+#ifdef __ELF__
+	.section .rodata
+#else
+	.text
+#endif
+
+	.align ALIGNARG(4)
+	ASM_TYPE_DIRECTIVE(zero_nan,@object)
+zero_nan:
+	.double 0.0
+nan:	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+minus_zero:
+	.byte 0, 0, 0, 0, 0, 0, 0, 0x80
+	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+	ASM_SIZE_DIRECTIVE(zero_nan)
+
+
+#ifdef PIC
+#define MO(op) op##@GOTOFF(%ecx)
+#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
+#else
+#define MO(op) op
+#define MOX(op,x,f) op(,x,f)
+#endif
+
+
 ENTRY(__ieee754_scalb)
 	fldl	12(%esp)
+	fxam
+	fnstsw
 	fldl	4(%esp)
+	andl	$0x4700, %eax
+	cmpl	$0x0700, %eax
+	je	1f
+	andl	$0x4500, %eax
+	cmpl	$0x0100, %eax
+	je	2f
+	fxam
+	fnstsw
+	andl	$0x4500, %eax
+	cmpl	$0x0100, %eax
+	je	2f
+	fld	%st(1)
+	frndint
+	fcomp	%st(2)
+	fnstsw
+	sahf
+	jne	2f
 	fscale
 	fstp	%st(1)
 	ret
+
+	/* y is -inf */
+1:	fxam
+#ifdef  PIC
+        call    1f
+1:      popl    %ecx
+        addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+	fnstsw
+	movl	8(%esp), %edx
+	shrl	$5, %eax
+	fstp	%st(1)
+	andl	$0x80000000, %edx
+	andl	$8, %eax
+	fstp	%st(1)
+	shrl	$27, %edx
+	addl	%edx, %eax
+	fldl	MOX(zero_nan, %eax, 1)
+	ret
+
+	/* The result is NaN, but we must not raise an exception.
+	   So use a variable.  */
+2:	fstp	%st
+	fstp	%st
+#ifdef  PIC
+        call    1f
+1:      popl    %ecx
+        addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+	fldl	MO(nan)
+	ret
 END(__ieee754_scalb)
diff --git a/sysdeps/libm-i387/e_scalbf.S b/sysdeps/libm-i387/e_scalbf.S
index 4c62134a0c..c869da9b38 100644
--- a/sysdeps/libm-i387/e_scalbf.S
+++ b/sysdeps/libm-i387/e_scalbf.S
@@ -2,16 +2,95 @@
  * Written by J.T. Conklin <jtc@netbsd.org>.
  * Public domain.
  * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>.
+ *
+ * Correct handling of y==-inf <drepper@gnu>
  */
 
 #include <machine/asm.h>
 
 RCSID("$NetBSD: $")
 
+#ifdef __ELF__
+	.section .rodata
+#else
+	.text
+#endif
+
+	.align ALIGNARG(4)
+	ASM_TYPE_DIRECTIVE(zero_nan,@object)
+zero_nan:
+	.double 0.0
+nan:	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+minus_zero:
+	.byte 0, 0, 0, 0, 0, 0, 0, 0x80
+	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+	ASM_SIZE_DIRECTIVE(zero_nan)
+
+
+#ifdef PIC
+#define MO(op) op##@GOTOFF(%ecx)
+#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
+#else
+#define MO(op) op
+#define MOX(op,x,f) op(,x,f)
+#endif
+
+
+	.text
 ENTRY(__ieee754_scalbf)
 	flds	8(%esp)
+	fxam
+	fnstsw
 	flds	4(%esp)
+	andl	$0x4700, %eax
+	cmpl	$0x0700, %eax
+	je	1f
+	andl	$0x4500, %eax
+	cmpl	$0x0100, %eax
+	je	2f
+	fxam
+	fnstsw
+	andl	$0x4500, %eax
+	cmpl	$0x0100, %eax
+	je	2f
+	fld	%st(1)
+	frndint
+	fcomp	%st(2)
+	fnstsw
+	sahf
+	jne	2f
 	fscale
 	fstp	%st(1)
 	ret
+
+	/* y is -inf */
+1:	fxam
+#ifdef  PIC
+        call    1f
+1:      popl    %ecx
+        addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+	fnstsw
+	movl	4(%esp), %edx
+	shrl	$5, %eax
+	fstp	%st(1)
+	andl	$0x80000000, %edx
+	andl	$8, %eax
+	fstp	%st(1)
+	shrl	$27, %edx
+	addl	%edx, %eax
+	fldl	MOX(zero_nan, %eax, 1)
+	ret
+
+	/* The result is NaN, but we must not raise an exception.
+	   So use a variable.  */
+2:	fstp	%st
+	fstp	%st
+#ifdef  PIC
+        call    1f
+1:      popl    %ecx
+        addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+	fldl	MO(nan)
+	ret
 END(__ieee754_scalbf)
diff --git a/sysdeps/libm-i387/e_scalbl.S b/sysdeps/libm-i387/e_scalbl.S
index 3b746ad363..e272614acf 100644
--- a/sysdeps/libm-i387/e_scalbl.S
+++ b/sysdeps/libm-i387/e_scalbl.S
@@ -3,16 +3,94 @@
  * Public domain.
  *
  * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
+ *
+ * Correct handling of y==-inf <drepper@gnu>
  */
 
 #include <machine/asm.h>
 
 RCSID("$NetBSD: $")
 
+#ifdef __ELF__
+	.section .rodata
+#else
+	.text
+#endif
+
+	.align ALIGNARG(4)
+	ASM_TYPE_DIRECTIVE(zero_nan,@object)
+zero_nan:
+	.double 0.0
+nan:	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+minus_zero:
+	.byte 0, 0, 0, 0, 0, 0, 0, 0x80
+	.byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+	ASM_SIZE_DIRECTIVE(zero_nan)
+
+
+#ifdef PIC
+#define MO(op) op##@GOTOFF(%ecx)
+#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
+#else
+#define MO(op) op
+#define MOX(op,x,f) op(,x,f)
+#endif
+
+
 ENTRY(__ieee754_scalbl)
 	fldt	16(%esp)
+	fxam
+	fnstsw
 	fldt	4(%esp)
+	andl	$0x4700, %eax
+	cmpl	$0x0700, %eax
+	je	1f
+	andl	$0x4500, %eax
+	cmpl	$0x0100, %eax
+	je	2f
+	fxam
+	fnstsw
+	andl	$0x4500, %eax
+	cmpl	$0x0100, %eax
+	je	2f
+	fld	%st(1)
+	frndint
+	fcomp	%st(2)
+	fnstsw
+	sahf
+	jne	2f
 	fscale
 	fstp	%st(1)
 	ret
+
+	/* y is -inf */
+1:	fxam
+#ifdef  PIC
+        call    1f
+1:      popl    %ecx
+        addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+	fnstsw
+	movl	12(%esp), %edx
+	shrl	$5, %eax
+	fstp	%st(1)
+	andl	$0x8000, %edx
+	andl	$8, %eax
+	fstp	%st(1)
+	shrl	$11, %edx
+	addl	%edx, %eax
+	fldl	MOX(zero_nan, %eax, 1)
+	ret
+
+	/* The result is NaN, but we must not raise an exception.
+	   So use a variable.  */
+2:	fstp	%st
+	fstp	%st
+#ifdef  PIC
+        call    1f
+1:      popl    %ecx
+        addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+	fldl	MO(nan)
+	ret
 END(__ieee754_scalbl)
diff --git a/sysdeps/libm-i387/s_asinh.S b/sysdeps/libm-i387/s_asinh.S
index 45153fe2d3..a4c52cb67c 100644
--- a/sysdeps/libm-i387/s_asinh.S
+++ b/sysdeps/libm-i387/s_asinh.S
@@ -49,14 +49,14 @@ ENTRY(__asinh)
 	movl	$0x7fffffff, %eax
 	andl	%ecx, %eax
 	andl	$0x80000000, %ecx
+	movl	%eax, %edx
+	orl	$0x800fffff, %edx
+	incl	%edx
+	jz	7f			// x in ħInf or NaN
 	xorl	%ecx, 8(%esp)
 	fldl	4(%esp)			// |x|
-	movl	%eax, %edx
 	cmpl	$0x3e300000, %eax
 	jb	2f			// |x| < 2^-28
-	orl	$0x800fffff, %edx
-	incl	%edx
-	jz	4f			// x in ħInf or NaN
 	fldln2				// log(2) : |x|
 	cmpl	$0x41b00000, %eax
 	fxch				// |x| : log(2)
@@ -87,6 +87,9 @@ ENTRY(__asinh)
 	fchs
 4:	ret
 
+7:	fldl	4(%esp)
+	ret
+
 6:	faddl	MO(one)
 	fyl2x
 	jecxz	4f
diff --git a/sysdeps/libm-i387/s_asinhf.S b/sysdeps/libm-i387/s_asinhf.S
index 7e5176c4a6..6369e19ac6 100644
--- a/sysdeps/libm-i387/s_asinhf.S
+++ b/sysdeps/libm-i387/s_asinhf.S
@@ -49,14 +49,14 @@ ENTRY(__asinhf)
 	movl	$0x7fffffff, %eax
 	andl	%ecx, %eax
 	andl	$0x80000000, %ecx
+	movl	%eax, %edx
+	orl	$0x807fffff, %edx
+	incl	%edx
+	jz	7f			// x in ħInf or NaN
 	xorl	%ecx, 8(%esp)
 	flds	4(%esp)			// |x|
-	movl	%eax, %edx
 	cmpl	$0x38000000, %eax
 	jb	2f			// |x| < 2^-14
-	orl	$0x807fffff, %edx
-	incl	%edx
-	jz	4f			// x in ħInf or NaN
 	fldln2				// log(2) : |x|
 	cmpl	$0x47000000, %eax
 	fxch				// |x| : log(2)
@@ -87,6 +87,9 @@ ENTRY(__asinhf)
 	fchs
 4:	ret
 
+7:	flds	4(%esp)
+	ret
+
 6:	faddl	MO(one)
 	fyl2x
 	jecxz	4f
diff --git a/sysdeps/libm-i387/s_asinhl.S b/sysdeps/libm-i387/s_asinhl.S
index f764381aab..62e29bc58e 100644
--- a/sysdeps/libm-i387/s_asinhl.S
+++ b/sysdeps/libm-i387/s_asinhl.S
@@ -56,14 +56,14 @@ ENTRY(__asinhl)
 	movl	$0x7fff, %eax
 	andl	%ecx, %eax
 	andl	$0x8000, %ecx
+	movl	%eax, %edx
+	orl	$0xffff8000, %edx
+	incl	%edx
+	jz	7f			// x in ħInf or NaN
 	xorl	%ecx, 12(%esp)
 	fldt	4(%esp)			// |x|
-	movl	%eax, %edx
 	cmpl	$0x3fde, %eax
 	jb	2f			// |x| < 2^-34
-	orl	$0xffff8000, %edx
-	incl	%edx
-	jz	4f			// x in ħInf or NaN
 	fldln2				// log(2) : |x|
 	cmpl	$0x4020, %eax
 	fxch				// |x| : log(2)
@@ -94,6 +94,9 @@ ENTRY(__asinhl)
 	fchs
 4:	ret
 
+7:	fldt	4(%esp)
+	ret
+
 6:	faddl	MO(one)
 	fyl2x
 	jecxz	4f
diff --git a/sysdeps/libm-i387/s_ilogb.S b/sysdeps/libm-i387/s_ilogb.S
index 01b8afac10..6c125586c7 100644
--- a/sysdeps/libm-i387/s_ilogb.S
+++ b/sysdeps/libm-i387/s_ilogb.S
@@ -8,18 +8,14 @@
 RCSID("$NetBSD: s_ilogb.S,v 1.5 1995/10/12 15:53:09 jtc Exp $")
 
 ENTRY(__ilogb)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$4,%esp
-
-	fldl	8(%ebp)
+	fldl	4(%esp)
 	fxtract
+	pushl	%eax
 	fstpl	%st
 
-	fistpl	-4(%ebp)
-	movl	-4(%ebp),%eax
+	fistpl	(%esp)
+	popl	%eax
 
-	leave
 	ret
 END (__ilogb)
 weak_alias (__ilogb, ilogb)
diff --git a/sysdeps/libm-i387/s_ilogbf.S b/sysdeps/libm-i387/s_ilogbf.S
index 6a943265b2..b08a32f4ef 100644
--- a/sysdeps/libm-i387/s_ilogbf.S
+++ b/sysdeps/libm-i387/s_ilogbf.S
@@ -8,18 +8,14 @@
 RCSID("$NetBSD: s_ilogbf.S,v 1.4 1995/10/22 20:32:43 pk Exp $")
 
 ENTRY(__ilogbf)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$4,%esp
-
-	flds	8(%ebp)
+	flds	4(%esp)
 	fxtract
+	pushl	%eax
 	fstpl	%st
 
-	fistpl	-4(%ebp)
-	movl	-4(%ebp),%eax
+	fistpl	(%esp)
+	popl	%eax
 
-	leave
 	ret
 END (__ilogbf)
 weak_alias (__ilogbf, ilogbf)
diff --git a/sysdeps/libm-i387/s_ilogbl.S b/sysdeps/libm-i387/s_ilogbl.S
index 2422a41355..adc88aabab 100644
--- a/sysdeps/libm-i387/s_ilogbl.S
+++ b/sysdeps/libm-i387/s_ilogbl.S
@@ -9,17 +9,14 @@
 RCSID("$NetBSD: $")
 
 ENTRY(__ilogbl)
-	pushl	%ebp
-	movl	%esp,%ebp
-	subl	$4,%esp
-
-	fldt	8(%ebp)
+	fldt	4(%esp)
 	fxtract
+	pushl	%eax
+	fstp	%st
 
-	fistpl	-4(%ebp)
-	movl	-4(%ebp),%eax
+	fistpl	(%esp)
+	popl	%eax
 
-	leave
 	ret
 END (__ilogbl)
 weak_alias (__ilogbl, ilogbl)
diff --git a/sysdeps/libm-i387/s_rinttoll.S b/sysdeps/libm-i387/s_llrint.S
index 99395052de..cfb8e86f7d 100644
--- a/sysdeps/libm-i387/s_rinttoll.S
+++ b/sysdeps/libm-i387/s_llrint.S
@@ -22,12 +22,12 @@
 #include <sysdep.h>
 
 	.text
-ENTRY(__rinttoll)
+ENTRY(__llrint)
 	fldt	4(%esp)
 	subl	$8, %esp
 	fistpll	(%esp)
 	popl	%eax
 	popl	%edx
 	ret
-END(__rinttoll)
-weak_alias (__rinttoll, rinttoll)
+END(__llrint)
+weak_alias (__llrint, llrint)
diff --git a/sysdeps/libm-i387/s_rinttol.S b/sysdeps/libm-i387/s_lrint.S
index 22a3e46bd6..19241456a8 100644
--- a/sysdeps/libm-i387/s_rinttol.S
+++ b/sysdeps/libm-i387/s_lrint.S
@@ -22,11 +22,11 @@
 #include <sysdep.h>
 
 	.text
-ENTRY(__rinttol)
+ENTRY(__lrint)
 	fldt	4(%esp)
 	subl	$4, %esp
 	fistpl	(%esp)
 	popl	%eax
 	ret
-END(__rinttol)
-weak_alias (__rinttol, rinttol)
+END(__lrint)
+weak_alias (__lrint, lrint)
diff --git a/sysdeps/libm-i387/s_remquo.S b/sysdeps/libm-i387/s_remquo.S
index a4c5a35468..252bf2678a 100644
--- a/sysdeps/libm-i387/s_remquo.S
+++ b/sysdeps/libm-i387/s_remquo.S
@@ -25,7 +25,12 @@ ENTRY(__remquo)
 	shrl	%cl, %eax
 	andl	$3, %eax
 	movl	20(%esp), %ecx
-	movl	%eax, (%ecx)
+	movl	8(%esp), %edx
+	xorl	16(%esp), %edx
+	testl	$0x80000000, %edx
+	jz	1f
+	negl	%eax
+1:	movl	%eax, (%ecx)
 	ret
 END (__remquo)
 weak_alias (__remquo, remquo)
diff --git a/sysdeps/libm-i387/s_remquof.S b/sysdeps/libm-i387/s_remquof.S
index 56954323a6..144eb3034c 100644
--- a/sysdeps/libm-i387/s_remquof.S
+++ b/sysdeps/libm-i387/s_remquof.S
@@ -25,7 +25,12 @@ ENTRY(__remquof)
 	shrl	%cl, %eax
 	andl	$3, %eax
 	movl	12(%esp), %ecx
-	movl	%eax, (%ecx)
+	movl	4(%esp), %edx
+	xorl	8(%esp), %edx
+	testl	$0x80000000, %edx
+	jz	1f
+	negl	%eax
+1:	movl	%eax, (%ecx)
 	ret
 END (__remquof)
 weak_alias (__remquof, remquof)
diff --git a/sysdeps/libm-i387/s_remquol.S b/sysdeps/libm-i387/s_remquol.S
index 9c91d90c45..2cbcdf18af 100644
--- a/sysdeps/libm-i387/s_remquol.S
+++ b/sysdeps/libm-i387/s_remquol.S
@@ -25,7 +25,12 @@ ENTRY(__remquol)
 	shrl	%cl, %eax
 	andl	$3, %eax
 	movl	28(%esp), %ecx
-	movl	%eax, (%ecx)
+	movl	12(%esp), %edx
+	xorl	24(%esp), %edx
+	testl	$0x8000, %edx
+	jz	1f
+	negl	%eax
+1:	movl	%eax, (%ecx)
 	ret
 END (__remquol)
 weak_alias (__remquol, remquol)