Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/complex/clogl.c
+++ new/usr/src/lib/libm/common/complex/clogl.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.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
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 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 +
25 26 /*
26 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 28 * Use is subject to license terms.
28 29 */
29 30
30 31 #pragma weak __clogl = clogl
31 32
32 33 #include "libm.h" /* atan2l/fabsl/isinfl/log1pl/logl/__k_clog_rl */
33 34 #include "complex_wrapper.h"
34 35 #include "longdouble.h"
35 36
36 37 #if defined(__sparc)
37 -#define SIGP7 120
38 -#define HSIGP7 60
38 +#define SIGP7 120
39 +#define HSIGP7 60
39 40 #elif defined(__x86)
40 -#define SIGP7 70
41 -#define HSIGP7 35
41 +#define SIGP7 70
42 +#define HSIGP7 35
42 43 #endif
43 44
44 -/* INDENT OFF */
45 45 static const long double zero = 0.0L, half = 0.5L, one = 1.0L;
46 -/* INDENT ON */
46 +
47 47
48 48 ldcomplex
49 -clogl(ldcomplex z) {
49 +clogl(ldcomplex z)
50 +{
50 51 ldcomplex ans;
51 52 long double x, y, t, ax, ay;
52 53 int n, ix, iy, hx, hy;
53 54
54 55 x = LD_RE(z);
55 56 y = LD_IM(z);
56 57 hx = HI_XWORD(x);
57 58 hy = HI_XWORD(y);
58 59 ix = hx & 0x7fffffff;
59 60 iy = hy & 0x7fffffff;
60 61 ay = fabsl(y);
61 62 ax = fabsl(x);
62 63 LD_IM(ans) = atan2l(y, x);
64 +
63 65 if (ix < iy || (ix == iy && ix < 0x7fff0000 && ax < ay)) {
64 - /* swap x and y to force ax>=ay */
66 + /* swap x and y to force ax>=ay */
65 67 t = ax;
66 68 ax = ay;
67 69 ay = t;
68 70 n = ix, ix = iy;
69 71 iy = n;
70 72 }
73 +
71 74 n = (ix - iy) >> 16;
72 - if (ix >= 0x7fff0000) { /* x or y is Inf or NaN */
75 +
76 + if (ix >= 0x7fff0000) { /* x or y is Inf or NaN */
73 77 if (isinfl(ax))
74 78 LD_RE(ans) = ax;
75 79 else if (isinfl(ay))
76 80 LD_RE(ans) = ay;
77 81 else
78 82 LD_RE(ans) = ax + ay;
79 - } else if (ay == zero)
83 + } else if (ay == zero) {
80 84 LD_RE(ans) = logl(ax);
81 - else if (((0x3fffffff - ix) ^ (ix - 0x3ffe0000)) >= 0) {
82 - /* 0.5 <= x < 2 */
85 + } else if (((0x3fffffff - ix) ^ (ix - 0x3ffe0000)) >= 0) {
86 + /* 0.5 <= x < 2 */
83 87 if (ix >= 0x3fff0000) {
84 88 if (ax == one)
85 89 LD_RE(ans) = half * log1pl(ay * ay);
86 90 else if (n >= SIGP7)
87 91 LD_RE(ans) = logl(ax);
88 92 else
89 93 LD_RE(ans) = half * (log1pl(ay * ay + (ax -
90 - one) * (ax + one)));
91 - } else if (n >= SIGP7)
94 + one) * (ax + one)));
95 + } else if (n >= SIGP7) {
92 96 LD_RE(ans) = logl(ax);
93 - else
97 + } else {
94 98 LD_RE(ans) = __k_clog_rl(x, y, &t);
95 - } else if (n >= HSIGP7)
99 + }
100 + } else if (n >= HSIGP7) {
96 101 LD_RE(ans) = logl(ax);
97 - else if (ix < 0x5f3f0000 && iy >= 0x20bf0000)
102 + } else if (ix < 0x5f3f0000 && iy >= 0x20bf0000) {
98 103 /* 2**-8000 < y < x < 2**8000 */
99 104 LD_RE(ans) = half * logl(ax * ax + ay * ay);
100 - else {
105 + } else {
101 106 t = ay / ax;
102 107 LD_RE(ans) = logl(ax) + half * log1pl(t * t);
103 108 }
109 +
104 110 return (ans);
105 111 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX