diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | math/libm-test.inc | 6 | ||||
-rw-r--r-- | sysdeps/i386/fpu/s_tan.S | 27 | ||||
-rw-r--r-- | sysdeps/i386/fpu/s_tanf.S | 27 | ||||
-rw-r--r-- | sysdeps/i386/fpu/s_tanl.S | 29 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/s_tan.c | 10 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/s_tanf.c | 9 | ||||
-rw-r--r-- | sysdeps/x86_64/fpu/s_tanl.S | 14 |
8 files changed, 121 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog index 3019b4b7ab..9731ec602c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2009-04-25 Ulrich Drepper <drepper@redhat.com> + * sysdeps/i386/fpu/s_tan.S: Set errno for ±Inf. + * sysdeps/i386/fpu/s_tanf.S: Likewise. + * sysdeps/i386/fpu/s_tanl.S: Likewise. + * sysdeps/ieee754/dbl-64/s_tan.c: Likewise. + * sysdeps/ieee754/flt-32/s_tanf.c: Likewise. + * sysdeps/x86_64/fpu/s_tanl.S: Likewise. + * math/libm-test.inc: Add tests for errno after tan calls with + ±Inf. + * sysdeps/ieee754/k_standard.c (__kernel_standard): Use correct errno value vor pow(+-0,neg). * math/libm-test.inc (pow_test): Add tests for errno value for diff --git a/math/libm-test.inc b/math/libm-test.inc index 19025ecebe..8c5727ca27 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -5653,9 +5653,15 @@ tan_test (void) TEST_f_f (tan, 0, 0); TEST_f_f (tan, minus_zero, minus_zero); + errno = 0; TEST_f_f (tan, plus_infty, nan_value, INVALID_EXCEPTION); + check_int ("errno for tan(Inf) == EDOM", errno, EDOM, 0, 0, 0); + errno = 0; TEST_f_f (tan, minus_infty, nan_value, INVALID_EXCEPTION); + check_int ("errno for tan(-Inf) == EDOM", errno, EDOM, 0, 0, 0); + errno = 0; TEST_f_f (tan, nan_value, nan_value); + check_int ("errno for tan(NaN) == 0", errno, 0, 0, 0, 0); TEST_f_f (tan, M_PI_4l, 1); TEST_f_f (tan, 0.75L, 0.931596459944072461165202756573936428L); diff --git a/sysdeps/i386/fpu/s_tan.S b/sysdeps/i386/fpu/s_tan.S index 7b3547af4c..b35bb835de 100644 --- a/sysdeps/i386/fpu/s_tan.S +++ b/sysdeps/i386/fpu/s_tan.S @@ -1,15 +1,24 @@ /* * Written by J.T. Conklin <jtc@netbsd.org>. + * Fixed errno handling by Ulrich Drepper <drepper@redhat.com>. * Public domain. */ +#define __need_Emath +#include <bits/errno.h> #include <machine/asm.h> RCSID("$NetBSD: s_tan.S,v 1.5 1995/05/09 00:30:00 jtc Exp $") ENTRY(__tan) fldl 4(%esp) - fptan + fxam + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 3f +4: fptan fnstsw %ax testl $0x400,%eax jnz 1f @@ -26,5 +35,21 @@ ENTRY(__tan) fptan fstp %st(0) ret +3: +#ifdef PIC + pushl %ebx + cfi_adjust_cfa_offset (4) + cfi_rel_offset (ebx, 0) + LOAD_PIC_REG (bx) + call __errno_location@PLT + movl $EDOM, (%eax) + popl %ebx + cfi_adjust_cfa_offset (-4) + cfi_restore (ebx) +#else + call __errno_location@PLT + movl $EDOM, (%eax) +#endif + jmp 4b END (__tan) weak_alias (__tan, tan) diff --git a/sysdeps/i386/fpu/s_tanf.S b/sysdeps/i386/fpu/s_tanf.S index 355dff9c8d..74bc22fceb 100644 --- a/sysdeps/i386/fpu/s_tanf.S +++ b/sysdeps/i386/fpu/s_tanf.S @@ -1,15 +1,24 @@ /* * Written by J.T. Conklin <jtc@netbsd.org>. + * Fixed errno handling by Ulrich Drepper <drepper@redhat.com>. * Public domain. */ +#define __need_Emath +#include <bits/errno.h> #include <machine/asm.h> RCSID("$NetBSD: s_tanf.S,v 1.3 1995/05/09 00:31:09 jtc Exp $") ENTRY(__tanf) flds 4(%esp) - fptan + fxam + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 3f +4: fptan fnstsw %ax testl $0x400,%eax jnz 1f @@ -26,5 +35,21 @@ ENTRY(__tanf) fptan fstp %st(0) ret +3: +#ifdef PIC + pushl %ebx + cfi_adjust_cfa_offset (4) + cfi_rel_offset (ebx, 0) + LOAD_PIC_REG (bx) + call __errno_location@PLT + movl $EDOM, (%eax) + popl %ebx + cfi_adjust_cfa_offset (-4) + cfi_restore (ebx) +#else + call __errno_location@PLT + movl $EDOM, (%eax) +#endif + jmp 4b END (__tanf) weak_alias (__tanf, tanf) diff --git a/sysdeps/i386/fpu/s_tanl.S b/sysdeps/i386/fpu/s_tanl.S index f2bdd6a605..151b77113f 100644 --- a/sysdeps/i386/fpu/s_tanl.S +++ b/sysdeps/i386/fpu/s_tanl.S @@ -3,15 +3,22 @@ * Public domain. * * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + * Fixed errno handling by Ulrich Drepper <drepper@redhat.com>. */ +#define __need_Emath +#include <bits/errno.h> #include <machine/asm.h> -RCSID("$NetBSD: $") - ENTRY(__tanl) fldt 4(%esp) - fptan + fxam + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 3f +4: fptan fnstsw %ax testl $0x400,%eax jnz 1f @@ -28,5 +35,21 @@ ENTRY(__tanl) fptan fstp %st(0) ret +3: +#ifdef PIC + pushl %ebx + cfi_adjust_cfa_offset (4) + cfi_rel_offset (ebx, 0) + LOAD_PIC_REG (bx) + call __errno_location@PLT + movl $EDOM, (%eax) + popl %ebx + cfi_adjust_cfa_offset (-4) + cfi_restore (ebx) +#else + call __errno_location@PLT + movl $EDOM, (%eax) +#endif + jmp 4b END (__tanl) weak_alias (__tanl, tanl) diff --git a/sysdeps/ieee754/dbl-64/s_tan.c b/sysdeps/ieee754/dbl-64/s_tan.c index cf8d4d0267..6e0f7d2f6f 100644 --- a/sysdeps/ieee754/dbl-64/s_tan.c +++ b/sysdeps/ieee754/dbl-64/s_tan.c @@ -1,7 +1,7 @@ /* * IBM Accurate Mathematical Library * written by International Business Machines Corp. - * Copyright (C) 2001 Free Software Foundation + * Copyright (C) 2001, 2009 Free Software Foundation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -33,6 +33,8 @@ /* round to nearest mode of IEEE 754 standard. */ /* */ /*********************************************************************/ + +#include <errno.h> #include "endian.h" #include "dla.h" #include "mpa.h" @@ -61,7 +63,11 @@ double tan(double x) { /* x=+-INF, x=NaN */ num.d = x; ux = num.i[HIGH_HALF]; - if ((ux&0x7ff00000)==0x7ff00000) return x-x; + if ((ux&0x7ff00000)==0x7ff00000) { + if ((ux&0x7fffffff)==0x7ff00000) + __set_errno (EDOM); + return x-x; + } w=(x<ZERO) ? -x : x; diff --git a/sysdeps/ieee754/flt-32/s_tanf.c b/sysdeps/ieee754/flt-32/s_tanf.c index e8f6016c32..4a852cb1f4 100644 --- a/sysdeps/ieee754/flt-32/s_tanf.c +++ b/sysdeps/ieee754/flt-32/s_tanf.c @@ -8,7 +8,7 @@ * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice + * software is freely granted, provided that this notice * is preserved. * ==================================================== */ @@ -17,6 +17,7 @@ static char rcsid[] = "$NetBSD: s_tanf.c,v 1.4 1995/05/10 20:48:20 jtc Exp $"; #endif +#include <errno.h> #include "math.h" #include "math_private.h" @@ -37,7 +38,11 @@ static char rcsid[] = "$NetBSD: s_tanf.c,v 1.4 1995/05/10 20:48:20 jtc Exp $"; if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1); /* tan(Inf or NaN) is NaN */ - else if (ix>=0x7f800000) return x-x; /* NaN */ + else if (ix>=0x7f800000) { + if (ix==0x7f800000) + __set_errno (EDOM); + return x-x; /* NaN */ + } /* argument reduction needed */ else { diff --git a/sysdeps/x86_64/fpu/s_tanl.S b/sysdeps/x86_64/fpu/s_tanl.S index 674e908acc..6427e3f6f0 100644 --- a/sysdeps/x86_64/fpu/s_tanl.S +++ b/sysdeps/x86_64/fpu/s_tanl.S @@ -4,15 +4,24 @@ * * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>. + * Fixed errno handling by Ulrich Drepper <drepper@redhat.com>. */ +#define __need_Emath +#include <bits/errno.h> #include <machine/asm.h> RCSID("$NetBSD: $") ENTRY(__tanl) fldt 8(%rsp) - fptan + fxam + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 3f +4: fptan fnstsw %ax testl $0x400,%eax jnz 1f @@ -29,5 +38,8 @@ ENTRY(__tanl) fptan fstp %st(0) ret +3: call __errno_location@PLT + movl $EDOM, (%rax) + jmp 4b END (__tanl) weak_alias (__tanl, tanl) |