Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/complex/csinhf.c
+++ new/usr/src/lib/libm/common/complex/csinhf.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 23 */
24 24 /*
25 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 27 */
28 28
29 -#pragma weak csinhf = __csinhf
29 +#pragma weak __csinhf = csinhf
30 30
31 31 #include "libm.h"
32 32 #include "complex_wrapper.h"
33 33
34 34 #if defined(__i386) && !defined(__amd64)
35 35 extern int __swapRP(int);
36 36 #endif
37 37
38 38 static const float zero = 0.0F, half = 0.5F;
39 39
40 40 fcomplex
41 41 csinhf(fcomplex z) {
42 42 float x, y, S, C;
43 43 double t;
44 44 int hx, ix, hy, iy, n;
45 45 fcomplex ans;
46 46
47 47 x = F_RE(z);
48 48 y = F_IM(z);
49 49 hx = THE_WORD(x);
50 50 ix = hx & 0x7fffffff;
51 51 hy = THE_WORD(y);
52 52 iy = hy & 0x7fffffff;
53 53 x = fabsf(x);
54 54 y = fabsf(y);
55 55
56 56 sincosf(y, &S, &C);
57 57 if (ix >= 0x41600000) { /* |x| > 14 = prec/2 (14,28,34,60) */
58 58 if (ix >= 0x42B171AA) { /* |x| > 88.722... ~ log(2**128) */
59 59 if (ix >= 0x7f800000) { /* |x| is inf or NaN */
60 60 if (iy == 0) {
61 61 F_RE(ans) = x;
62 62 F_IM(ans) = y;
63 63 } else if (iy >= 0x7f800000) {
64 64 F_RE(ans) = x;
65 65 F_IM(ans) = x - y;
66 66 } else {
67 67 F_RE(ans) = C * x;
68 68 F_IM(ans) = S * x;
69 69 }
70 70 } else {
71 71 #if defined(__i386) && !defined(__amd64)
72 72 int rp = __swapRP(fp_extended);
73 73 #endif
74 74 /* return (C, S) * exp(x) / 2 */
75 75 t = __k_cexp((double)x, &n);
76 76 F_RE(ans) = (float)scalbn(C * t, n - 1);
77 77 F_IM(ans) = (float)scalbn(S * t, n - 1);
78 78 #if defined(__i386) && !defined(__amd64)
79 79 if (rp != fp_extended)
80 80 (void) __swapRP(rp);
81 81 #endif
82 82 }
83 83 } else {
84 84 t = expf(x) * half;
85 85 F_RE(ans) = C * t;
86 86 F_IM(ans) = S * t;
87 87 }
88 88 } else {
89 89 if (ix == 0) { /* x = 0, return (0,S) */
90 90 F_RE(ans) = zero;
91 91 F_IM(ans) = S;
92 92 } else {
93 93 F_RE(ans) = C * sinhf(x);
94 94 F_IM(ans) = S * coshf(x);
95 95 }
96 96 }
97 97 if (hx < 0)
98 98 F_RE(ans) = -F_RE(ans);
99 99 if (hy < 0)
100 100 F_IM(ans) = -F_IM(ans);
101 101 return (ans);
102 102 }
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX