sparc64: Remove unwind information from signal return stubs [BZ#31244]
[glibc.git] / sysdeps / ieee754 / ldbl-96 / s_tanl.c
blob60f9e35170b1043ac8c135f014b14f437ad9ca50
1 /* s_tanl.c -- long double version of s_tan.c.
2 */
4 /*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
11 * is preserved.
12 * ====================================================
15 #if defined(LIBM_SCCS) && !defined(lint)
16 static char rcsid[] = "$NetBSD: $";
17 #endif
19 /* tanl(x)
20 * Return tangent function of x.
22 * kernel function:
23 * __kernel_tanl ... tangent function on [-pi/4,pi/4]
24 * __ieee754_rem_pio2l ... argument reduction routine
26 * Method.
27 * Let S,C and T denote the sin, cos and tan respectively on
28 * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2
29 * in [-pi/4 , +pi/4], and let n = k mod 4.
30 * We have
32 * n sin(x) cos(x) tan(x)
33 * ----------------------------------------------------------
34 * 0 S C T
35 * 1 C -S -1/T
36 * 2 -S -C T
37 * 3 -C S -1/T
38 * ----------------------------------------------------------
40 * Special cases:
41 * Let trig be any of sin, cos, or tan.
42 * trig(+-INF) is NaN, with signals;
43 * trig(NaN) is that NaN;
45 * Accuracy:
46 * TRIG(x) returns trig(x) nearly rounded
49 #include <errno.h>
50 #include <math.h>
51 #include <math_private.h>
52 #include <libm-alias-ldouble.h>
54 long double __tanl(long double x)
56 long double y[2],z=0.0;
57 int32_t n, se, i0, i1;
59 /* High word of x. */
60 GET_LDOUBLE_WORDS(se,i0,i1,x);
62 /* |x| ~< pi/4 */
63 se &= 0x7fff;
64 if(se <= 0x3ffe) return __kernel_tanl(x,z,1);
66 /* tan(Inf or NaN) is NaN */
67 else if (se==0x7fff) {
68 if (i1 == 0 && i0 == 0x80000000)
69 __set_errno (EDOM);
70 return x-x;
73 /* argument reduction needed */
74 else {
75 n = __ieee754_rem_pio2l(x,y);
76 return __kernel_tanl(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even
77 -1 -- n odd */
80 libm_alias_ldouble (__tan, tan)