* 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.
This commit is contained in:
Ulrich Drepper 2009-04-26 05:42:49 +00:00
parent 002a604fd6
commit 337c270829
8 changed files with 121 additions and 10 deletions

View File

@ -1,5 +1,14 @@
2009-04-25 Ulrich Drepper <drepper@redhat.com> 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 * sysdeps/ieee754/k_standard.c (__kernel_standard): Use correct
errno value vor pow(+-0,neg). errno value vor pow(+-0,neg).
* math/libm-test.inc (pow_test): Add tests for errno value for * math/libm-test.inc (pow_test): Add tests for errno value for

View File

@ -5653,9 +5653,15 @@ tan_test (void)
TEST_f_f (tan, 0, 0); TEST_f_f (tan, 0, 0);
TEST_f_f (tan, minus_zero, minus_zero); TEST_f_f (tan, minus_zero, minus_zero);
errno = 0;
TEST_f_f (tan, plus_infty, nan_value, INVALID_EXCEPTION); 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); 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); 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, M_PI_4l, 1);
TEST_f_f (tan, 0.75L, 0.931596459944072461165202756573936428L); TEST_f_f (tan, 0.75L, 0.931596459944072461165202756573936428L);

View File

@ -1,15 +1,24 @@
/* /*
* Written by J.T. Conklin <jtc@netbsd.org>. * Written by J.T. Conklin <jtc@netbsd.org>.
* Fixed errno handling by Ulrich Drepper <drepper@redhat.com>.
* Public domain. * Public domain.
*/ */
#define __need_Emath
#include <bits/errno.h>
#include <machine/asm.h> #include <machine/asm.h>
RCSID("$NetBSD: s_tan.S,v 1.5 1995/05/09 00:30:00 jtc Exp $") RCSID("$NetBSD: s_tan.S,v 1.5 1995/05/09 00:30:00 jtc Exp $")
ENTRY(__tan) ENTRY(__tan)
fldl 4(%esp) fldl 4(%esp)
fptan fxam
fstsw %ax
movb $0x45, %dh
andb %ah, %dh
cmpb $0x05, %dh
je 3f
4: fptan
fnstsw %ax fnstsw %ax
testl $0x400,%eax testl $0x400,%eax
jnz 1f jnz 1f
@ -26,5 +35,21 @@ ENTRY(__tan)
fptan fptan
fstp %st(0) fstp %st(0)
ret 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) END (__tan)
weak_alias (__tan, tan) weak_alias (__tan, tan)

View File

@ -1,15 +1,24 @@
/* /*
* Written by J.T. Conklin <jtc@netbsd.org>. * Written by J.T. Conklin <jtc@netbsd.org>.
* Fixed errno handling by Ulrich Drepper <drepper@redhat.com>.
* Public domain. * Public domain.
*/ */
#define __need_Emath
#include <bits/errno.h>
#include <machine/asm.h> #include <machine/asm.h>
RCSID("$NetBSD: s_tanf.S,v 1.3 1995/05/09 00:31:09 jtc Exp $") RCSID("$NetBSD: s_tanf.S,v 1.3 1995/05/09 00:31:09 jtc Exp $")
ENTRY(__tanf) ENTRY(__tanf)
flds 4(%esp) flds 4(%esp)
fptan fxam
fstsw %ax
movb $0x45, %dh
andb %ah, %dh
cmpb $0x05, %dh
je 3f
4: fptan
fnstsw %ax fnstsw %ax
testl $0x400,%eax testl $0x400,%eax
jnz 1f jnz 1f
@ -26,5 +35,21 @@ ENTRY(__tanf)
fptan fptan
fstp %st(0) fstp %st(0)
ret 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) END (__tanf)
weak_alias (__tanf, tanf) weak_alias (__tanf, tanf)

View File

@ -3,15 +3,22 @@
* Public domain. * Public domain.
* *
* Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. * 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> #include <machine/asm.h>
RCSID("$NetBSD: $")
ENTRY(__tanl) ENTRY(__tanl)
fldt 4(%esp) fldt 4(%esp)
fptan fxam
fstsw %ax
movb $0x45, %dh
andb %ah, %dh
cmpb $0x05, %dh
je 3f
4: fptan
fnstsw %ax fnstsw %ax
testl $0x400,%eax testl $0x400,%eax
jnz 1f jnz 1f
@ -28,5 +35,21 @@ ENTRY(__tanl)
fptan fptan
fstp %st(0) fstp %st(0)
ret 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) END (__tanl)
weak_alias (__tanl, tanl) weak_alias (__tanl, tanl)

View File

@ -1,7 +1,7 @@
/* /*
* IBM Accurate Mathematical Library * IBM Accurate Mathematical Library
* written by International Business Machines Corp. * 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 * 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 * 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. */ /* round to nearest mode of IEEE 754 standard. */
/* */ /* */
/*********************************************************************/ /*********************************************************************/
#include <errno.h>
#include "endian.h" #include "endian.h"
#include "dla.h" #include "dla.h"
#include "mpa.h" #include "mpa.h"
@ -61,7 +63,11 @@ double tan(double x) {
/* x=+-INF, x=NaN */ /* x=+-INF, x=NaN */
num.d = x; ux = num.i[HIGH_HALF]; 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; w=(x<ZERO) ? -x : x;

View File

@ -8,7 +8,7 @@
* *
* Developed at SunPro, a Sun Microsystems, Inc. business. * Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this * 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. * is preserved.
* ==================================================== * ====================================================
*/ */
@ -17,6 +17,7 @@
static char rcsid[] = "$NetBSD: s_tanf.c,v 1.4 1995/05/10 20:48:20 jtc Exp $"; static char rcsid[] = "$NetBSD: s_tanf.c,v 1.4 1995/05/10 20:48:20 jtc Exp $";
#endif #endif
#include <errno.h>
#include "math.h" #include "math.h"
#include "math_private.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); if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1);
/* tan(Inf or NaN) is NaN */ /* 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 */ /* argument reduction needed */
else { else {

View File

@ -4,15 +4,24 @@
* *
* Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
* Adapted for x86-64 by Andreas Jaeger <aj@suse.de>. * 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> #include <machine/asm.h>
RCSID("$NetBSD: $") RCSID("$NetBSD: $")
ENTRY(__tanl) ENTRY(__tanl)
fldt 8(%rsp) fldt 8(%rsp)
fptan fxam
fstsw %ax
movb $0x45, %dh
andb %ah, %dh
cmpb $0x05, %dh
je 3f
4: fptan
fnstsw %ax fnstsw %ax
testl $0x400,%eax testl $0x400,%eax
jnz 1f jnz 1f
@ -29,5 +38,8 @@ ENTRY(__tanl)
fptan fptan
fstp %st(0) fstp %st(0)
ret ret
3: call __errno_location@PLT
movl $EDOM, (%rax)
jmp 4b
END (__tanl) END (__tanl)
weak_alias (__tanl, tanl) weak_alias (__tanl, tanl)