about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/i386/fpu/e_atan2.S35
-rw-r--r--sysdeps/i386/fpu/e_atan2f.S35
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps24
-rw-r--r--sysdeps/i386/fpu/s_atan.S33
-rw-r--r--sysdeps/i386/fpu/s_atanf.S33
-rw-r--r--sysdeps/ieee754/dbl-64/e_atan2.c14
-rw-r--r--sysdeps/ieee754/dbl-64/s_atan.c11
-rw-r--r--sysdeps/ieee754/flt-32/s_atanf.c6
-rw-r--r--sysdeps/ieee754/ldbl-128/s_atanl.c7
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_atanl.c6
-rw-r--r--sysdeps/x86/fpu/bits/mathinline.h12
-rw-r--r--sysdeps/x86_64/fpu/multiarch/e_atan2.c1
12 files changed, 192 insertions, 25 deletions
diff --git a/sysdeps/i386/fpu/e_atan2.S b/sysdeps/i386/fpu/e_atan2.S
index e76f8e2a78..6f5481fb5c 100644
--- a/sysdeps/i386/fpu/e_atan2.S
+++ b/sysdeps/i386/fpu/e_atan2.S
@@ -7,10 +7,43 @@
 
 RCSID("$NetBSD: e_atan2.S,v 1.4 1995/05/08 23:46:28 jtc Exp $")
 
+	.section .rodata.cst8,"aM",@progbits,8
+
+	.p2align 3
+	.type dbl_min,@object
+dbl_min:	.byte 0, 0, 0, 0, 0, 0, 0x10, 0
+	ASM_SIZE_DIRECTIVE(dbl_min)
+
+#ifdef PIC
+# define MO(op) op##@GOTOFF(%ecx)
+#else
+# define MO(op) op
+#endif
+
+	.text
 ENTRY(__ieee754_atan2)
+#ifdef  PIC
+	LOAD_PIC_REG (cx)
+#endif
 	fldl	 4(%esp)
 	fldl	12(%esp)
 	fpatan
-	ret
+	fldl	MO(dbl_min)
+	fld	%st(1)
+	fabs
+	fucompp
+	fnstsw
+	sahf
+	jnc 1f
+	subl	$8, %esp
+	cfi_adjust_cfa_offset (8)
+	fld	%st(0)
+	fmul	%st(0)
+	fstpl	(%esp)
+	fstpl	(%esp)
+	fldl	(%esp)
+	addl	$8, %esp
+	cfi_adjust_cfa_offset (-8)
+1:	ret
 END (__ieee754_atan2)
 strong_alias (__ieee754_atan2, __atan2_finite)
diff --git a/sysdeps/i386/fpu/e_atan2f.S b/sysdeps/i386/fpu/e_atan2f.S
index 9ffa6373be..ec0eb3fd71 100644
--- a/sysdeps/i386/fpu/e_atan2f.S
+++ b/sysdeps/i386/fpu/e_atan2f.S
@@ -7,10 +7,43 @@
 
 RCSID("$NetBSD: e_atan2f.S,v 1.1 1995/05/08 23:35:10 jtc Exp $")
 
+	.section .rodata.cst4,"aM",@progbits,4
+
+	.p2align 2
+	.type flt_min,@object
+flt_min:	.byte 0, 0, 0x80, 0
+	ASM_SIZE_DIRECTIVE(flt_min)
+
+#ifdef PIC
+# define MO(op) op##@GOTOFF(%ecx)
+#else
+# define MO(op) op
+#endif
+
+	.text
 ENTRY(__ieee754_atan2f)
+#ifdef  PIC
+	LOAD_PIC_REG (cx)
+#endif
 	flds	4(%esp)
 	flds	8(%esp)
 	fpatan
-	ret
+	flds	MO(flt_min)
+	fld	%st(1)
+	fabs
+	fucompp
+	fnstsw
+	sahf
+	jnc 1f
+	subl	$4, %esp
+	cfi_adjust_cfa_offset (4)
+	fld	%st(0)
+	fmul	%st(0)
+	fstps	(%esp)
+	fstps	(%esp)
+	flds	(%esp)
+	addl	$4, %esp
+	cfi_adjust_cfa_offset (-4)
+1:	ret
 END (__ieee754_atan2f)
 strong_alias (__ieee754_atan2f, __atan2f_finite)
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index a408a82615..5e79307f30 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -324,10 +324,10 @@ ildouble: 2
 ldouble: 2
 
 Function: Real part of "casin_downward":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
 ildouble: 2
 ldouble: 2
 
@@ -357,9 +357,9 @@ ldouble: 5
 
 Function: Real part of "casin_upward":
 double: 2
-float: 1
+float: 2
 idouble: 2
-ifloat: 1
+ifloat: 2
 ildouble: 2
 ldouble: 2
 
@@ -396,10 +396,10 @@ ildouble: 5
 ldouble: 5
 
 Function: Imaginary part of "casinh_downward":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
 ildouble: 2
 ldouble: 2
 
@@ -429,9 +429,9 @@ ldouble: 5
 
 Function: Imaginary part of "casinh_upward":
 double: 2
-float: 1
+float: 2
 idouble: 2
-ifloat: 1
+ifloat: 2
 ildouble: 2
 ldouble: 2
 
diff --git a/sysdeps/i386/fpu/s_atan.S b/sysdeps/i386/fpu/s_atan.S
index 7502f6d828..c28b73ce75 100644
--- a/sysdeps/i386/fpu/s_atan.S
+++ b/sysdeps/i386/fpu/s_atan.S
@@ -7,10 +7,41 @@
 
 RCSID("$NetBSD: s_atan.S,v 1.4 1995/05/08 23:50:41 jtc Exp $")
 
+	.section .rodata.cst8,"aM",@progbits,8
+
+	.p2align 3
+	.type dbl_min,@object
+dbl_min:	.byte 0, 0, 0, 0, 0, 0, 0x10, 0
+	ASM_SIZE_DIRECTIVE(dbl_min)
+
+#ifdef PIC
+# define MO(op) op##@GOTOFF(%ecx)
+#else
+# define MO(op) op
+#endif
+
+	.text
 ENTRY(__atan)
+#ifdef  PIC
+	LOAD_PIC_REG (cx)
+#endif
 	fldl	4(%esp)
 	fld1
 	fpatan
-	ret
+	fldl	MO(dbl_min)
+	fld	%st(1)
+	fabs
+	fucompp
+	fnstsw
+	sahf
+	jnc 1f
+	subl	$8, %esp
+	cfi_adjust_cfa_offset (8)
+	fld	%st(0)
+	fmul	%st(0)
+	fstpl	(%esp)
+	addl	$8, %esp
+	cfi_adjust_cfa_offset (-8)
+1:	ret
 END (__atan)
 weak_alias (__atan, atan)
diff --git a/sysdeps/i386/fpu/s_atanf.S b/sysdeps/i386/fpu/s_atanf.S
index 70232c8240..da3c2a64b5 100644
--- a/sysdeps/i386/fpu/s_atanf.S
+++ b/sysdeps/i386/fpu/s_atanf.S
@@ -7,10 +7,41 @@
 
 RCSID("$NetBSD: s_atanf.S,v 1.3 1995/05/08 23:51:33 jtc Exp $")
 
+	.section .rodata.cst4,"aM",@progbits,4
+
+	.p2align 2
+	.type flt_min,@object
+flt_min:	.byte 0, 0, 0x80, 0
+	ASM_SIZE_DIRECTIVE(flt_min)
+
+#ifdef PIC
+# define MO(op) op##@GOTOFF(%ecx)
+#else
+# define MO(op) op
+#endif
+
+	.text
 ENTRY(__atanf)
+#ifdef  PIC
+	LOAD_PIC_REG (cx)
+#endif
 	flds	4(%esp)
 	fld1
 	fpatan
-	ret
+	flds	MO(flt_min)
+	fld	%st(1)
+	fabs
+	fucompp
+	fnstsw
+	sahf
+	jnc 1f
+	subl	$4, %esp
+	cfi_adjust_cfa_offset (4)
+	fld	%st(0)
+	fmul	%st(0)
+	fstps	(%esp)
+	addl	$4, %esp
+	cfi_adjust_cfa_offset (-4)
+1:	ret
 END (__atanf)
 weak_alias (__atanf, atanf)
diff --git a/sysdeps/ieee754/dbl-64/e_atan2.c b/sysdeps/ieee754/dbl-64/e_atan2.c
index 425da22719..a03ce3e4a6 100644
--- a/sysdeps/ieee754/dbl-64/e_atan2.c
+++ b/sysdeps/ieee754/dbl-64/e_atan2.c
@@ -41,6 +41,8 @@
 #include "MathLib.h"
 #include "uatan.tbl"
 #include "atnat2.h"
+#include <float.h>
+#include <math.h>
 #include <math_private.h>
 #include <stap-probe.h>
 
@@ -202,10 +204,18 @@ __ieee754_atan2 (double y, double x)
     {
       if (x > 0)
 	{
+	  double ret;
 	  if ((z = ay / ax) < TWOM1022)
-	    return normalized (ax, ay, y, z);
+	    ret = normalized (ax, ay, y, z);
 	  else
-	    return signArctan2 (y, z);
+	    ret = signArctan2 (y, z);
+	  if (fabs (ret) < DBL_MIN)
+	    {
+	      double vret = ret ? ret : DBL_MIN;
+	      double force_underflow = vret * vret;
+	      math_force_eval (force_underflow);
+	    }
+	  return ret;
 	}
       else
 	{
diff --git a/sysdeps/ieee754/dbl-64/s_atan.c b/sysdeps/ieee754/dbl-64/s_atan.c
index a482badc56..7b598f14a9 100644
--- a/sysdeps/ieee754/dbl-64/s_atan.c
+++ b/sysdeps/ieee754/dbl-64/s_atan.c
@@ -41,7 +41,9 @@
 #include "MathLib.h"
 #include "uatan.tbl"
 #include "atnat.h"
+#include <float.h>
 #include <math.h>
+#include <math_private.h>
 #include <stap-probe.h>
 
 void __mpatan (mp_no *, mp_no *, int);	/* see definition in mpatan.c */
@@ -85,7 +87,14 @@ atan (double x)
       if (u < B)
 	{
 	  if (u < A)
-	    return x;
+	    {
+	      if (u < DBL_MIN)
+		{
+		  double force_underflow = x * x;
+		  math_force_eval (force_underflow);
+		}
+	      return x;
+	    }
 	  else
 	    {			/* A <= u < B */
 	      v = x * x;
diff --git a/sysdeps/ieee754/flt-32/s_atanf.c b/sysdeps/ieee754/flt-32/s_atanf.c
index 02c5e46287..159391894f 100644
--- a/sysdeps/ieee754/flt-32/s_atanf.c
+++ b/sysdeps/ieee754/flt-32/s_atanf.c
@@ -17,6 +17,7 @@
 static char rcsid[] = "$NetBSD: s_atanf.c,v 1.4 1995/05/10 20:46:47 jtc Exp $";
 #endif
 
+#include <float.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -66,6 +67,11 @@ float __atanf(float x)
 	    else     return -atanhi[3]-atanlo[3];
 	} if (ix < 0x3ee00000) {	/* |x| < 0.4375 */
 	    if (ix < 0x31000000) {	/* |x| < 2^-29 */
+		if (fabsf (x) < FLT_MIN)
+		  {
+		    float force_underflow = x * x;
+		    math_force_eval (force_underflow);
+		  }
 		if(huge+x>one) return x;	/* raise inexact */
 	    }
 	    id = -1;
diff --git a/sysdeps/ieee754/ldbl-128/s_atanl.c b/sysdeps/ieee754/ldbl-128/s_atanl.c
index dc5e7ef462..1367b6b15d 100644
--- a/sysdeps/ieee754/ldbl-128/s_atanl.c
+++ b/sysdeps/ieee754/ldbl-128/s_atanl.c
@@ -59,6 +59,8 @@
     <http://www.gnu.org/licenses/>.  */
 
 
+#include <float.h>
+#include <math.h>
 #include <math_private.h>
 
 /* arctan(k/8), k = 0, ..., 82 */
@@ -200,6 +202,11 @@ __atanl (long double x)
 
   if (k <= 0x3fc50000) /* |x| < 2**-58 */
     {
+      if (fabsl (x) < LDBL_MIN)
+	{
+	  long double force_underflow = x * x;
+	  math_force_eval (force_underflow);
+	}
       /* Raise inexact. */
       if (huge + x > 0.0)
 	return x;
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_atanl.c b/sysdeps/ieee754/ldbl-128ibm/s_atanl.c
index 41dde23998..6ddf4b1c5e 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_atanl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_atanl.c
@@ -59,6 +59,7 @@
     <http://www.gnu.org/licenses/>.  */
 
 
+#include <float.h>
 #include <math.h>
 #include <math_private.h>
 #include <math_ldbl_opt.h>
@@ -198,6 +199,11 @@ __atanl (long double x)
 
   if (k <= 0x3c800000) /* |x| <= 2**-55.  */
     {
+      if (fabsl (x) < LDBL_MIN)
+	{
+	  long double force_underflow = x * x;
+	  math_force_eval (force_underflow);
+	}
       /* Raise inexact.  */
       if (1e300L + x > 0.0)
 	return x;
diff --git a/sysdeps/x86/fpu/bits/mathinline.h b/sysdeps/x86/fpu/bits/mathinline.h
index 6a7489114c..c87300f7b8 100644
--- a/sysdeps/x86/fpu/bits/mathinline.h
+++ b/sysdeps/x86/fpu/bits/mathinline.h
@@ -965,12 +965,12 @@ __NTH (__finite (double __x))
 /* This code is used internally in the GNU libc.  */
 # ifdef __LIBC_INTERNAL_MATH_INLINES
 __inline_mathop (__ieee754_sqrt, "fsqrt")
-__inline_mathcode2 (__ieee754_atan2, __y, __x,
-		    register long double __value;
-		    __asm __volatile__ ("fpatan\n\t"
-					: "=t" (__value)
-					: "0" (__x), "u" (__y) : "st(1)");
-		    return __value;)
+__inline_mathcode2_ (long double, __ieee754_atan2l, __y, __x,
+		     register long double __value;
+		     __asm __volatile__ ("fpatan\n\t"
+					 : "=t" (__value)
+					 : "0" (__x), "u" (__y) : "st(1)");
+		     return __value;)
 # endif
 
 #endif /* !__SSE2_MATH__ && !__x86_64__ */
diff --git a/sysdeps/x86_64/fpu/multiarch/e_atan2.c b/sysdeps/x86_64/fpu/multiarch/e_atan2.c
index 6867c6e64e..547681cb59 100644
--- a/sysdeps/x86_64/fpu/multiarch/e_atan2.c
+++ b/sysdeps/x86_64/fpu/multiarch/e_atan2.c
@@ -1,5 +1,6 @@
 #if defined HAVE_FMA4_SUPPORT || defined HAVE_AVX_SUPPORT
 # include <init-arch.h>
+# include <math.h>
 # include <math_private.h>
 
 extern double __ieee754_atan2_sse2 (double, double);