62 */
63 /* INDENT ON */
64
65 #include "libm.h"
66 #include "libm_synonyms.h"
67 #include "longdouble.h"
68
69 #include <sys/isa_defs.h>
70
71 long double
72 cosl(long double x) {
73 long double y[2], z = 0.0L;
74 int n, ix;
75 int *px = (int *) &x;
76
77 /* trig(Inf or NaN) is NaN */
78 if (!finitel(x))
79 return x - x;
80
81 /* High word of x. */
82 #if defined(_BIG_ENDIAN)
83 ix = px[0];
84 #else
85 XTOI(px, ix);
86 #endif
87
88 /* |x| ~< pi/4 */
89 ix &= 0x7fffffff;
90 if (ix <= 0x3ffe9220)
91 return __k_cosl(x, z);
92
93 /* argument reduction needed */
94 else {
95 n = __rem_pio2l(x, y);
96 switch (n & 3) {
97 case 0:
98 return __k_cosl(y[0], y[1]);
99 case 1:
100 return -__k_sinl(y[0], y[1]);
101 case 2:
102 return -__k_cosl(y[0], y[1]);
103 case 3:
104 return __k_sinl(y[0], y[1]);
105 /* NOTREACHED */
|
62 */
63 /* INDENT ON */
64
65 #include "libm.h"
66 #include "libm_synonyms.h"
67 #include "longdouble.h"
68
69 #include <sys/isa_defs.h>
70
71 long double
72 cosl(long double x) {
73 long double y[2], z = 0.0L;
74 int n, ix;
75 int *px = (int *) &x;
76
77 /* trig(Inf or NaN) is NaN */
78 if (!finitel(x))
79 return x - x;
80
81 /* High word of x. */
82 #if defined(__i386) || defined(__amd64)
83 XTOI(px, ix);
84 #else
85 ix = px[0];
86 #endif
87
88 /* |x| ~< pi/4 */
89 ix &= 0x7fffffff;
90 if (ix <= 0x3ffe9220)
91 return __k_cosl(x, z);
92
93 /* argument reduction needed */
94 else {
95 n = __rem_pio2l(x, y);
96 switch (n & 3) {
97 case 0:
98 return __k_cosl(y[0], y[1]);
99 case 1:
100 return -__k_sinl(y[0], y[1]);
101 case 2:
102 return -__k_cosl(y[0], y[1]);
103 case 3:
104 return __k_sinl(y[0], y[1]);
105 /* NOTREACHED */
|